22 #include <emscripten/emscripten.h> 31 #define EVENT_BUF_SIZE 256 40 static int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF};
75 a = (float)((col>>24)&0xFF);
78 r = (
Uint8)(r*(1-a) + ((col>>16)&0xFF)*(
a));
79 g = (
Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(
a));
80 b = (
Uint8)(b*(1-a) + ((col>> 0)&0xFF)*(
a));
90 setpix(screen,x1+t*(x0-x1),y1+t*(y0-
y1),col);
100 for(tx=-xr+.5
f;tx<=xr-.5;tx++) {
101 setpix(screen,x+tx,y+ty,c);
105 setpix(screen,x-xr+.5
f,y+ty,c);
106 setpix(screen,x+xr-.5
f,y+ty,c);
124 for(y = 0;y < screen->
h;y++)
125 for(x = 0;x < screen->
w;x++)
126 setpix(screen,(
float)x,(
float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
131 const SDL_Event *
event = &events[i&(EVENT_BUF_SIZE-1)];
139 x =
event->tfinger.x;
140 y =
event->tfinger.y;
143 c =
colors[
event->tfinger.fingerId%7];
144 col = ((
unsigned int)(c*(.1+.85))) | (
unsigned int)(0xFF*age)<<24;
246 SDL_Log(
"Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f",
253 knob.
p.
x =
event.mgesture.x;
254 knob.
p.
y =
event.mgesture.y;
255 knob.
ang +=
event.mgesture.dTheta;
256 knob.
r +=
event.mgesture.dDist;
270 #ifdef __EMSCRIPTEN__ 272 emscripten_cancel_main_loop();
277 int main(
int argc,
char* argv[])
299 #ifdef __EMSCRIPTEN__ 300 emscripten_set_main_loop(
loop, 0, 1);
SDL_Window * initWindow(SDL_Window *window, int width, int height)
#define SDL_WINDOWPOS_CENTERED
GLuint GLfloat GLfloat GLfloat x1
GLdouble GLdouble GLdouble r
SDL_DollarGestureEvent dgesture
GLint GLint GLsizei width
uint32_t Uint32
An unsigned 32-bit integer type.
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 GLsizei height
#define SDL_UpdateWindowSurface
#define SDL_GetTouchDevice
GLint GLint GLint GLint GLint GLint y
uint8_t Uint8
An unsigned 8-bit integer type.
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
#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
The type used to identify a window.
GLboolean GLboolean GLboolean GLboolean a
void DrawScreen(SDL_Surface *screen, SDL_Window *window)
GLboolean GLboolean GLboolean b
SDL_TouchFingerEvent tfinger