#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>
void
main()
{
Event e;
Point last;
int haslast;
haslast = 0;
initdraw(0, 0, 0);
einit(Emouse | Ekeyboard);
draw(screen, screen->r, display->white, 0, ZP);
flushimage(display, 1);
while(1) {
switch(event(&e)) {
case Emouse:
if(e.mouse.buttons & 1) {
if(haslast)
line(screen, last, e.mouse.xy, Enddisc, Enddisc, 5, display->black, ZP);
else
fillellipse(screen, e.mouse.xy, 5, 5, display->black, ZP);
last = e.mouse.xy;
haslast = 1;
flushimage(display, 1);
} else haslast = 0;
if(e.mouse.buttons & 4) {
fillellipse(screen, e.mouse.xy, 5, 5, display->white, ZP);
flushimage(display, 1);
}
break;
case Ekeyboard:
if(e.kbdc == 'q') exits(nil);
if(e.kbdc == 'c')
draw(screen, screen->r, display->white, 0, ZP);
break;
}
}
}
void
eresized(int)
{
if(getwindow(display, Refnone) < 0)
sysfatal("resize failed");
}
|