implementing points and lines

This commit is contained in:
Florian Stecker
2018-08-14 13:20:54 +02:00
parent a373a8ccf7
commit 09a43c7ac3
3 changed files with 257 additions and 96 deletions

View File

@@ -80,7 +80,7 @@ void waitUpdateTimer(GraphicsInfo *info)
info->frames++;
}
int processStandardEvent(GraphicsInfo *info, XEvent *ev, void (*draw)(void*), void *data)
int processStandardEvent(GraphicsInfo *info, XEvent *ev, void (*draw)(cairo_t *, void*), void *data)
{
int state;
static int last_x, last_y;
@@ -88,7 +88,7 @@ int processStandardEvent(GraphicsInfo *info, XEvent *ev, void (*draw)(void*), vo
switch(ev->type) {
case Expose:
draw(data);
draw(info->ctx, data);
break;
case ConfigureNotify:
@@ -124,7 +124,7 @@ int processStandardEvent(GraphicsInfo *info, XEvent *ev, void (*draw)(void*), vo
}
last_x = ev->xbutton.x;
last_y = ev->xbutton.y;
draw(data);
draw(info->ctx, data);
break;
case MotionNotify:
@@ -139,7 +139,7 @@ int processStandardEvent(GraphicsInfo *info, XEvent *ev, void (*draw)(void*), vo
printf("Button1Motion Event, dx: %d, dy: %d\n", dx, dy);
draw(data);
draw(info->ctx, data);
} else if(ev->xmotion.state & Button1Mask && ev->xmotion.state & ShiftMask) {
double angle =
atan2((double)ev->xmotion.y - (double)info->height/2, (double)ev->xmotion.x - (double)info->width/2)-
@@ -154,7 +154,7 @@ int processStandardEvent(GraphicsInfo *info, XEvent *ev, void (*draw)(void*), vo
printf("Button1Motion Event, angle: %f\n", angle);
draw(data);
draw(info->ctx, data);
}
last_x = ev->xmotion.x;
last_y = ev->xmotion.y;
@@ -172,7 +172,7 @@ int processStandardEvent(GraphicsInfo *info, XEvent *ev, void (*draw)(void*), vo
}
int checkEvents(GraphicsInfo *info, int (*process)(GraphicsInfo*, XEvent*, void*), void (*draw)(void*), void *data) // get any events from the queue and the server, process them if neccessary, quit if wanted
int checkEvents(GraphicsInfo *info, int (*process)(GraphicsInfo*, XEvent*, void*), void (*draw)(cairo_t *, void*), void *data) // get any events from the queue and the server, process them if neccessary, quit if wanted
{
XEvent ev;