View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Fall2001 Midterm Review: More Drawing in Smalltalk

Link back to Fall 2001 Midterm Review

Since no one else wants to....

1. myPen := Pen new.
myPen up.
myPen goto: 100@100.
myPen north.
myPen turn: 30.
myPen down.
myPen go: 25.
2 timesRepeat: [myPen turn: 60. myPen go: 25.]

2. joe := Box new.
steve := Box new.
bob := Box new.
joe moveTo: 25@100.
steve moveTo: 75@100.
bob moveTo: 50@50.

3) Nothing. It turns a total of 360 and is back in its original location. -Allen Tyner
You can do 1 more easily. How can you make 3 more interesting? Mark Guzdial
If your background is a color other than white, you can see where it redrew the box at each interval in the loop. It makes a pretty design. Nate Weimer

1. Modifying Allen's code:
myPen := Pen new.
3 timesRepeat: [ myPen go: 25; turn: 120 ].
Alfred Park
If there is a delay in draw, then it can appear as if the box was spinning.
Shwetak Patel

One can start making great designs by taking Alfred Park's code to the extreme:

myPen := Pen new.
6 timesRepeat: [6 timesRepeat: [6 timesRepeat: [3 timesRepeat: [ myPen go: 300; turn: 120 ].
myPen go: 25.
myPen turn: 60].
myPen turn: -60].
myPen turn: 10].
Michael Kovash

Link to this Page