ref: f585b0a86cdefdc185e562d284bebde7e7d71bd7
dir: /0paint.c/
/* * written in plan 9 c dialect * thedaemon */ #include <u.h> #include <libc.h> #include <draw.h> #include <event.h> #include <keyboard.h> void main(void) { Mouse m; Point prevm; /* previous mouse position */ initdraw(0, 0, "0 Paint"); eresized(0); einit(Emouse); int brush = 1; int eraser = 4; for(;;){ m = emouse(); if(m.buttons & 2) break; if(m.buttons & 4) { line(screen, prevm.x == -1 ? m.xy : prevm, m.xy, Enddisc, Enddisc, eraser, display->white, ZP); prevm = m.xy; } if(m.buttons & 1) { /* Paint Function ? : means this if else true and false*/ line(screen, prevm.x == -1 ? m.xy : prevm, m.xy, Enddisc, Enddisc, brush, display->black, ZP); /* ZP is a constant point (0,0) */ prevm = m.xy; } else { prevm = Pt(-1, -1); } } } void eresized(int new) { USED(new); if(getwindow(display, Refnone) < 0) sysfatal("resize failed: %r"); }