Drawing Procedures
Notes:
- include setscreen ("graphics") as the first executable line of code
- the origin of the coordinate grid (0, 0) is at the bottom left of the run window
- the axes run from the origin to maxx and maxy
- procedures without fill in their names produce a figure outlined in the specified colour
- procedures with fill in their names produce a figure filled with the specified colour
Basics
drawdot (x, y, colour)
- (x, y) are the coordinates of the dot
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawline (x1, y1, x2, y2, colour)
- the line runs from (x1, y1) to (x2, y2)
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
Boxes & rectangular figures
drawbox (bottom-x, bottom-y, top-x, top-y, colour)
drawfillbox (bottom-x, bottom-y, top-x, top-y, colour)
- (bottom-x, bottom-y) is the bottom left corner
- (top-x, top-y) is the top right corner
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawmapleleaf (bottom-x, bottom-y, top-x, top-y, colour)
drawfillmapleleaf (bottom-x, bottom-y, top-x, top-y, colour)
- (bottom-x, bottom-y) is the bottom left corner
- (top-x, top-y) is the top right corner
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawstar (bottom-x, bottom-y, top-x, top-y, colour)
drawfillstar (bottom-x, bottom-y, top-x, top-y, colour)
- (bottom-x, bottom-y) is the bottom left corner
- (top-x, top-y) is the top right corner
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
Ovals & arcs
drawoval (x, y, x-radius, y-radius, colour)
drawfilloval (x, y, x-radius, y-radius, colour)
- (x, y) are the coordinates of the centre
- x-radius and y-radius are the lengths in pixels from the centre to the edge
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawarc (x, y, x-radius, y-radius, starting-angle, ending-angle, colour)
drawfillarc (x, y, x-radius, y-radius, starting-angle, ending-angle, colour)
- (x, y) are the coordinates of the centre
- x-radius and y-radius are the lengths in pixels from the centre to the edge
- starting-angle and ending-angle are expressed in degrees in relation to the x-axis
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
Advanced
drawfill (x, y, fill-colour, border-colour)
- (x, y) are the coordinates of the centre
- fill-colour is the colour which will spread from the centre until the border-colour is reached
- border-colour is the colour which marks the end of the area to be filled with the fill-colour
drawpolygon (x-array, y-array, number-of-points, colour)
- x-array is an array of x-coordinates
- y-array is an array of y-coordinates
- number-of-points is the number of coordinate pairs to be constructed from the two coordinate arrays
- the points are
- ( x-array (1), y-array (1) )
- ( x-array (2), y-array (2) )
- ( x-array (3), y-array (3) )
- …
- ( x-array (number-of-points), y-array (number-of-points) )
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawfillbox (bottom-x, bottom-y, top-x, top-y, colour)
- (bottom-x, bottom-y) is the bottom left corner
- (top-x, top-y) is the top right corner
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawmapleleaf (bottom-x, bottom-y, top-x, top-y, colour)
drawfillmapleleaf (bottom-x, bottom-y, top-x, top-y, colour)
- (bottom-x, bottom-y) is the bottom left corner
- (top-x, top-y) is the top right corner
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawstar (bottom-x, bottom-y, top-x, top-y, colour)
drawfillstar (bottom-x, bottom-y, top-x, top-y, colour)
- (bottom-x, bottom-y) is the bottom left corner
- (top-x, top-y) is the top right corner
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
Ovals & arcs
drawoval (x, y, x-radius, y-radius, colour)
drawfilloval (x, y, x-radius, y-radius, colour)
- (x, y) are the coordinates of the centre
- x-radius and y-radius are the lengths in pixels from the centre to the edge
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawarc (x, y, x-radius, y-radius, starting-angle, ending-angle, colour)
drawfillarc (x, y, x-radius, y-radius, starting-angle, ending-angle, colour)
- (x, y) are the coordinates of the centre
- x-radius and y-radius are the lengths in pixels from the centre to the edge
- starting-angle and ending-angle are expressed in degrees in relation to the x-axis
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
Advanced
drawfill (x, y, fill-colour, border-colour)
- (x, y) are the coordinates of the centre
- fill-colour is the colour which will spread from the centre until the border-colour is reached
- border-colour is the colour which marks the end of the area to be filled with the fill-colour
drawpolygon (x-array, y-array, number-of-points, colour)
- x-array is an array of x-coordinates
- y-array is an array of y-coordinates
- number-of-points is the number of coordinate pairs to be constructed from the two coordinate arrays
- the points are
- ( x-array (1), y-array (1) )
- ( x-array (2), y-array (2) )
- ( x-array (3), y-array (3) )
- …
- ( x-array (number-of-points), y-array (number-of-points) )
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawfillstar (bottom-x, bottom-y, top-x, top-y, colour)
- (bottom-x, bottom-y) is the bottom left corner
- (top-x, top-y) is the top right corner
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
Ovals & arcs
drawoval (x, y, x-radius, y-radius, colour)
drawfilloval (x, y, x-radius, y-radius, colour)
- (x, y) are the coordinates of the centre
- x-radius and y-radius are the lengths in pixels from the centre to the edge
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawarc (x, y, x-radius, y-radius, starting-angle, ending-angle, colour)
drawfillarc (x, y, x-radius, y-radius, starting-angle, ending-angle, colour)
- (x, y) are the coordinates of the centre
- x-radius and y-radius are the lengths in pixels from the centre to the edge
- starting-angle and ending-angle are expressed in degrees in relation to the x-axis
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
Advanced
drawfill (x, y, fill-colour, border-colour)
- (x, y) are the coordinates of the centre
- fill-colour is the colour which will spread from the centre until the border-colour is reached
- border-colour is the colour which marks the end of the area to be filled with the fill-colour
drawpolygon (x-array, y-array, number-of-points, colour)
- x-array is an array of x-coordinates
- y-array is an array of y-coordinates
- number-of-points is the number of coordinate pairs to be constructed from the two coordinate arrays
- the points are
- ( x-array (1), y-array (1) )
- ( x-array (2), y-array (2) )
- ( x-array (3), y-array (3) )
- …
- ( x-array (number-of-points), y-array (number-of-points) )
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
drawfillarc (x, y, x-radius, y-radius, starting-angle, ending-angle, colour)
- (x, y) are the coordinates of the centre
- x-radius and y-radius are the lengths in pixels from the centre to the edge
- starting-angle and ending-angle are expressed in degrees in relation to the x-axis
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
Advanced
drawfill (x, y, fill-colour, border-colour)
- (x, y) are the coordinates of the centre
- fill-colour is the colour which will spread from the centre until the border-colour is reached
- border-colour is the colour which marks the end of the area to be filled with the fill-colour
drawpolygon (x-array, y-array, number-of-points, colour)
- x-array is an array of x-coordinates
- y-array is an array of y-coordinates
- number-of-points is the number of coordinate pairs to be constructed from the two coordinate arrays
- the points are
- ( x-array (1), y-array (1) )
- ( x-array (2), y-array (2) )
- ( x-array (3), y-array (3) )
- …
- ( x-array (number-of-points), y-array (number-of-points) )
- colour is any valid predefined colour name (blue, yellow, etc.) or integer colour code
touque.ca > Education Commons > Turing
[This page last updated 2020-12-23 at 12h13 Toronto local time.]

© 2007–2025 Hersch, Bear & Company Limited. All rights reserved. “Grammar Authority,” “grammarauthority.com,” “touque.ca,” and “Canada’s Thinking Cap” are trademarks of Hersch, Bear & Company Limited. All other trademarks and copyrights are the property of their respective owners.
Privacy Policy | Licence to Copy | How to cite | Contact us

