diff options
Diffstat (limited to 'p9c/draw/draw.c')
-rw-r--r-- | p9c/draw/draw.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/p9c/draw/draw.c b/p9c/draw/draw.c new file mode 100644 index 0000000..696ce30 --- /dev/null +++ b/p9c/draw/draw.c @@ -0,0 +1,36 @@ +#include <u.h> +#include <libc.h> +#include <draw.h> +#include <event.h> + +void +eresized(int new) +{ + if(new&& getwindow(display, Refnone) < 0) + sysfatal("can't reattach to window"); +} + +void +main(int argc, char* argv[]) +{ + Mouse m; + Point prevm; + initdraw(0, 0, "Example: Mouse"); + eresized(0); + einit(Emouse); + + /* Main loop */ + for(;;) { + m = emouse(); + if(m.buttons & 4) + break; + if(m.buttons & 1) { + line(screen, + prevm.x == -1 ? m.xy : prevm, + m.xy, Enddisc, Enddisc, 1, display->black, ZP); + prevm = m.xy; + } else { + prevm = Pt(-1, -1); + } + } +} \ No newline at end of file |