22 #include <emscripten/emscripten.h> 30 #define EVENT_BUF_SIZE 256 39 static int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF};
74 a = (float)((col>>24)&0xFF);
77 r = (
Uint8)(r*(1-a) + ((col>>16)&0xFF)*(
a));
78 g = (
Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(
a));
79 b = (
Uint8)(b*(1-a) + ((col>> 0)&0xFF)*(
a));
89 setpix(screen,x1+t*(x0-x1),y1+t*(y0-
y1),col);
99 for(tx=-xr+.5
f;tx<=xr-.5;tx++) {
100 setpix(screen,x+tx,y+ty,c);
104 setpix(screen,x-xr+.5
f,y+ty,c);
105 setpix(screen,x+xr-.5
f,y+ty,c);
123 for(y = 0;y < screen->
h;y++)
124 for(x = 0;x < screen->
w;x++)
125 setpix(screen,(
float)x,(
float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
130 const SDL_Event *
event = &events[i&(EVENT_BUF_SIZE-1)];
138 x =
event->tfinger.x;
139 y =
event->tfinger.y;
142 c =
colors[
event->tfinger.fingerId%7];
143 col = ((
unsigned int)(c*(.1+.85))) | (
unsigned int)(0xFF*age)<<24;
245 SDL_Log(
"Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f",
252 knob.
p.
x =
event.mgesture.x;
253 knob.
p.
y =
event.mgesture.y;
254 knob.
ang +=
event.mgesture.dTheta;
255 knob.
r +=
event.mgesture.dDist;
269 #ifdef __EMSCRIPTEN__ 271 emscripten_cancel_main_loop();
276 int main(
int argc,
char* argv[])
298 #ifdef __EMSCRIPTEN__ 299 emscripten_set_main_loop(
loop, 0, 1);
SDL_Window * initWindow(SDL_Window *window, int width, int height)
GLdouble GLdouble GLdouble r
#define SDL_WINDOWPOS_CENTERED
GLuint GLfloat GLfloat GLfloat x1
SDL_DollarGestureEvent dgesture
GLint GLint GLint GLint GLint x
#define SDL_RecordGesture
static SDL_Event events[EVENT_BUF_SIZE]
A collection of pixels used in software blitting.
int main(int argc, char *argv[])
void drawCircle(SDL_Surface *screen, float x, float y, float r, unsigned int c)
#define SDL_GetNumTouchDevices
GLint GLint GLsizei width
#define SDL_UpdateWindowSurface
#define SDL_GetTouchDevice
SDL_MultiGestureEvent mgesture
void drawLine(SDL_Surface *screen, float x0, float y0, float x1, float y1, unsigned int col)
#define SDL_SaveAllDollarTemplates
#define SDL_GetWindowSurface
GLint GLint GLint GLint GLint GLint y
#define SDL_GetNumTouchFingers
void drawKnob(SDL_Surface *screen, Knob k)
void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_LogSetPriority
GLuint GLfloat GLfloat y0
#define SDL_LoadDollarTemplates
GLint GLint GLsizei GLsizei height
The type used to identify a window.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int return Display Window int return XExtensionInfo Display char XExtensionHooks int XPointer return XExtensionInfo XExtensionInfo Display return Display return Display unsigned long Display GC Display char long Display xReply int Bool return Display Bool return Display int SDL_X11_XESetEventToWireRetType return Display Window Window Window Window unsigned int return Display XShmSegmentInfo return Display Drawable GC XImage int int int int unsigned int unsigned int Boo k)
GLboolean GLboolean GLboolean GLboolean a
void DrawScreen(SDL_Surface *screen, SDL_Window *window)
GLboolean GLboolean GLboolean b
SDL_TouchFingerEvent tfinger