| 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:
- The
Graphicselement on which to draw (optional--could be a global).- The
x,ylocation at which to begin drawing. Although most graphics methods (such asdrawRect) usexandyas 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 usesizeinstead).
Additional points:
x, y)
and the size of the drawing, and don't get
these confused. Size and location are independent, and must be treated
as such. x or y by anything. Always use the
current
x, y location plus or minus some function
of the size. (If you do a little arithmetic at different
locations, you will see why this is important.) depth - 1 in each recursive
call, rather than setting
depth = depth - 1 before
all the calls. Either way usually works, but the former is a little
safer.size. 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.
![]() |