/* * Dots * ---- * A program to draw different coloured dots on a window, using the * mouse buttons to control colour. Try using the mouse to draw in * the drawing area, and use different mouse buttons to select * different colours. */ #include void mouse_click(drawing d, int buttons, point p) { if (buttons & LeftButton) setcolour(Red); else if (buttons & MiddleButton) setcolour(Green); else if (buttons & RightButton) setcolour(Blue); drawpoint(p); } void main(void) { window w; drawing d; w = newwindow("Dots", rect(50,50,200,200), StandardWindow); d = newdrawing(rect(10,10,180,180), NULL); setbackground(w, LightGrey); setmousedown(d, mouse_click); setmousedrag(d, mouse_click); show(w); mainloop(); }