Difference between revisions of "Drawing Pictures"

From CodeStuff
Jump to: navigation, search
Line 45: Line 45:
 
fillRectangle(0,260,640,500);
 
fillRectangle(0,260,640,500);
  
setColour("white");
+
setColour("grey");
drawRectangle(200,200,250,250);
+
fillRectangle(200,200,250,250);
  
drawLine(200,200,325,50);
+
setColour("purple");
drawLine(325,50,450,200);
+
  
drawRectangle(300,300,100,150);
+
fillPolygon(200,200,325,50,450,200);
  
 +
setColour("chocolate");
 +
fillRectangle(300,300,100,150);
 +
 +
setColour("white");
 
drawCircle(375,375,10);
 
drawCircle(375,375,10);
 
    
 
    
Line 63: Line 66:
 
setColour("white");
 
setColour("white");
 
print("My Home",280,220);
 
print("My Home",280,220);
 +
 
</edcode>
 
</edcode>

Revision as of 02:17, 8 March 2012

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.