|CIT 594 Assignment 3: Suggestions for Recursive Drawings
CIT 594, Spring 2007
In the assignment I said:
The general technique is to write a method that takes these parameters:
Graphicselement on which to draw (optional--could be a global).
ylocation at which to begin drawing. Although most graphics methods (such as
yas the top left corner of the thing being drawn, you will find it more convenient to use these as the center of the figure you are drawing.
- Some measure of the
sizeof the drawing, such as the length of a side.
- A counter to control the
depthof the recursion (optional--can use
y) and the
sizeof the drawing, and don't get these confused. Size and location are independent, and must be treated as such.
yby anything. Always use the current
ylocation plus or minus some function of the
size. (If you do a little arithmetic at different locations, you will see why this is important.)
in each recursive call, rather than setting
depth - 1
before all the calls. Either way usually works, but the former is a little safer.
depth = depth - 1
These are not intended as additional requirements. If you get an interesting pattern (probably accidentally!) by violating some of these, feel free to keep it.