back to math cats love MicroWorlds
MicroWorlds index
Snowflakes Overview
Go to the snowflakes project!
Get the MicroWorlds Web Player
so you can use the project

screenshot of snowflakes (inactive buttons)

To use this project, you need the free MicroWorlds Web Player, but you do not need to know anything about MicroWorlds.

When the random snowflakes are drawn, all of the textboxes are hidden. If you view the snowflakes one at a time, it is fun to try to predict what angles were randomly chosen by the computer in drawing each of the six branches of the snowflake. (There are three angles per snowflake, moving from the outside towards the inside of the flake. The randomly-chosen angles tell the computer how far to turn from the center of each branch.) After you make your predictions, click on "show.variables" to see how close you came.

screenshot of the page for watching snowflakes fall (inactive buttons)

The slider controls the speed of the snow falling. Each snowflake has been given a different speed in relation to the slider. (See the "snowing" procedure below.)

five snowflakes created with the "lacy snowflakes" page

If you own MicroWorlds and would like the create the project yourself from scratch, here are the procedures:

* * * * * * * * * *

procedures for SNOWFLAKES

Please refer to the screenshots to see the buttons, slider, textboxes, and turtle needed. Remember that on the snowflake-generating page, you need to put the turtle's pen down (pd) so that it will draw. You may want to increase the thickness of the lines (for instance, using the command: setpensize 2).

* * * * * * * * * *

to startup

(The next four procedures are used to create one snowflake. The "random.snow" procedure uses hidden textboxes to record the random angles and lengths chosen by the computer for each of the six spokes of the snowflake. The "br" procedure creates two variables -- a for angle and l for length -- and enables the turtle to draw two lines off of a spoke, using the designated angle and length. The "fixed.random.snow" procedure draws one spoke and places three pairs of branches on it using the designated angles and lengths. The "random.snowflake" procedure creates six identical spokes to complete a snowflake.) These four procedures are followed by two procedures for hiding and showing the textboxes, one procedure (new.flake) which puts all of this together and makes sure that the textboxes are hidden, and one procedure for endlessly generating random snowflakes.

to random.snow
angle1, ct insert 10 + random 120
length1, ct insert 10 + random 60
angle2, ct insert 10 + random 120
length2, ct insert 10 + random 60
angle3, ct insert 10 + random 120
length3, ct insert 10 + random 60

to br :a :l
rt :a fd :l bk :l lt :a
lt :a fd :l bk :l rt :a

to fixed.random.snow
t1, setc 40 pd fd 70 bk 10
br angle1 length1
bk 20
br angle2 length2
bk 20
br angle3 length3
bk 20

to random.snowflake
repeat 6 [fixed.random.snow rt 60]

to hide.variables
angle1, hidetext
angle2, hidetext
angle3, hidetext
length1, hidetext
length2, hidetext
length3, hidetext

to show.variables
angle1, showtext
angle2, showtext
angle3, showtext
length1, showtext
length2, showtext
length3, showtext

to new.flake
pu clean home seth 0 pd ht hide.variables
setc 93 fill setc 30 setpensize 2

to lots.of.snowflakes
forever [new.flake wait 30]

(The next procedure ensures that the "lots.of.snowflakes" button is turned off while drawing one snowflake at a time.)

to new.snowflake
set "button2 "on? "false

The next three procedures cancel any process which is currently running on a page before taking you to another page of the project.

set "button2 "on? "false

to make.snowflakes
set "button1 "on? "false

to lacy.snowflakes
set "button2 "on? "false

The next two procedures are used to create random lacy snowflakes. There are 13 turtles in all. Two turtles are used to draw each branch of the flake. T13 is a hidden turtle which always sits at the center of the screen; if the first turtle gets more than 130 pixels away from this center point, then the snowflake-drawing procedure will stop before the 100 repetitions have completed, so that the snowflake will not become overly large. This page requires one slider called "pensize?" for controlling the thickness of the lines.

to make.random.lacy.snowflake
everyone [pu home pd ]
everyone [setpensize pensize?]
repeat 100 [t1, if (distance "t13) > 130 [everyone [ht] stopall] make "whichway? -90 + random 180 ask [t1 t3 t5 t7 t9 t11 ] [st seth heading + :whichway?] ask [t2 t4 t6 t8 t10 t12 ] [st seth heading - :whichway?] make "howfar? 3 + random 6 ask [t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12] [fd :howfar?] ]

to lacy.snowflake.setup
ask [t1 t2] [seth 0]
ask [t3 t4] [seth 60]
ask [t5 t6] [seth 120]
ask [t7 t8] [seth 180]
ask [t9 t10] [seth 240]
ask [t11 t12] [seth 300]

The "snowing" procedure sets many snowflakes in motion on the "snowy_day" page of the project.

to snowing
t10, forever [fd speed / 10]
t11, forever [fd speed / 10]
t12, forever [fd speed / 10]
t13, forever [fd speed / 10]
t1, forever [fd 1.3 * speed / 10]
t2, forever [fd 1.9 * speed / 10]
t3, forever [fd 1.7 * speed / 10]
t4, forever [fd 2.2 * speed / 10]
t5, forever [fd 2.0 * speed / 10]
t6, forever [fd 1.5 * speed / 10]
t7, forever [fd 2.3 * speed / 10]
t8, forever [fd 1.7 * speed / 10]
t9, forever [fd 1.6 * speed / 10]
t14, forever [fd 3 * speed / 10]
t15, forever [fd 4 * speed / 10]

© copyright 2000 -   Wendy Petti of Math Cats.   All Rights Reserved.