Goal: Change conditions at intervals.
Vocabulary: color, pensize
make "count 1
spiral 10 110
to spiral :length :pitch
if :length > howbig [stop]
make "count :count + 1
if :count > interval
[setc color + 1
setpensize pensize + 1
make "count 1]
fd :length rt angle
carefully [note :pitch 3] [ ]
spiral :length + howtight :pitch - 1
In this project, the color and line thickness change only at intervals which we set with the interval
- We will use a new variable called count to keep track of the intervals. We need to give count a starting value of 1. So this project uses a new procedure called changing_spiral to set the starting values of count, color, and pensize. Then it calls the spiral procedure (which has two inputs in this project).
- When the value of count becomes greater than the number on the interval slider, three things happen:
setc color + 1 means: increase the turtle's color by 1;
setpensize pensize + 1 means: increase the line thickness by 1;
make "count 1 resets the value of the variable called count to 1.
So while length and note change every time spiral is called, the color and line thickness change only at the interval set on the interval slider.
Try different settings on the interval slider.
Can you modify the project so that the angle changes size at intervals? "At intervals" means: if the interval slider is set to 4, then the angle should only change once in every four repetitions (See Squares 6.)
On Your Own - Project Ideas
Can you modify the project so that color and line thickness change at different intervals, rather than at the same time? (Hints: this might involve a second counting variable and a second interval slider. Be sure to give them different names.)