Drawing Pictures

From CodeStuff
Revision as of 02:17, 8 March 2012 by 140.200.212.34 (Talk)

Jump to: navigation, search

You can draw on the canvas very easily. You can draw using these commands

setColour(colour)
sets the colour of the next thing to be drawn. Colour names that your browser should know can be found at http://en.wikipedia.org/wiki/X11_color_names#Color_name_charts

examples

   setColour("red");
   setColour("green");
   setColour("#FF0080");
drawLine(x1,y1,x2,y2)
draws a straight line from x1,y1 to x2,y2

examples

   drawLine(50,10,300,240);
   drawLine(40,30,10,10);
   drawLine(ax,bx,ax+10,bx+32);
drawCircle(centerX,centerY,radius);
draws a circle centered at centerX,centerY with a size of radius.

examples

   drawCircle(30,150,10);
   drawCircle(400,150,100);
fillCircle(centerX,centerY,radius);
identical to drawCircle except the circle is filled with color rather than just an outline.
drawRectangle(left,top,width,height);
draws a rectangle with the top-left corner at left,top and a size of width and height.

examples

   drawRectangle(300,15,20,10);
   drawRectangle(0,0,300,200);
fillRectangle(left,top,width,height);
identical to drawRectangle except the rectangle is filled width color rather than just an outline.