Picture Class

The various functions of the picture class

Drawing Shapes

drawOval(x,y,hrad,vrad), drawOvalFill(x,y,hrad,vrad): Draws an empty or filled oval centered at x,y with a horizontal radius of hrad and a vertical radius of vrad.

drawCircle(x,y,r), drawCircleFill(x,y,r): Draws a circle centered at x,y, with radius r.

drawRect(x,y,w,h), drawRectFill(x,y,w,h): Draws a rectangle with its upper lefthand corner at x,y, with width w and height h.

drawSquare(x,y,side), drawSquareFill(x,y,side): Draws a square with its upper lefthand corner at x,y, with side length side.

drawPolygon(vertices), drawPolygonFill(vertices): Vertices is a list of x,y coordinates, so using this method will look something like pic.drawPolygon([(1,20),(20,20),(1,30),(20,30)]). This will draw a shape that connects all of the vertices in order, connecting the last vertex to the first vertex.

drawLine(x1,y1,x2,y2): Draws a line from point (x1,y1) to point (x2, y2).

drawText(x, y, TEXT, font_name, font_size): Writes string TEXT in font font_name, size font_size, centered at point x,y. font_name and font_size are both strings. Fonts available include "Arial", "Times", and "Helvetica".

pixel(x,y,color): Sets the pixel at position x,y to color color. color is a r,g,b value, so setting the pixel at (5,5) to red would look like pic.pixel(5,5, (255,0,0)).

Using the Pen

setPosition(x,y), getPostion(), setPenX(x), setPenY(y): Move the pen to x,y. getPosition will return the current pen position.

rotate(theta), setDirection(theta), getDirection(): Changes the direction the pen will move. rotate adds theta degrees to the angle of the pen, setDirection sets the angle to theta degrees, and getDirection() returns the current angle.

drawForward(distance): Draws a line of length distance from the current pen position, at the current pen angle.

setPenWidth(width), getPenWidth(): Sets the width of the line drawn by the pen. getPenWidth returns the current width.

Settings

setFillColor(r,g,b): Sets the fill color (the inside of the shape) to the color represented by the r,g,b value (r,g,b).

setOutlineColor(r,g,b): Sets the outline color to the r,g,b value (r,g,b).

display(): This will update the canvas with whatever you have drawn.

delay(millisecond): This will wait millisecond milliseconds before it does anything. This may be useful for animations.


C. Taylor