Thursday, February 3, 2011

Spiral traffic light

Today we created a spiral traffic light. We started with a plain spiral, changed the colour to red, then added a green spiral and finally a yellow one in the middle.
reset

# red spiral
for $x = 1 to 72 {
  pencolor 4 * $x, 0, 0
  forward 123
  turnright 67
  forward 7
  turnleft 156
  forward 7
  turnleft 156
}

penup
turnleft 90
forward 20
turnleft 90
forward 50
pendown

# green spiral
for $x = 1 to 72 {
  pencolor 0 , 4 * $x, 0
  forward 123
  turnright 67
  forward 7
  turnleft 156
  forward 7
  turnleft 156
}

penup
forward 50
turnleft 190
pendown

# yellow spiral
for $x = 1 to 72 {
  pencolor  4 * $x, 4 * $x, 0
  forward 123
  turnright 67
  forward 7
  turnleft 156
  forward 7
  turnleft 156
}

No comments:

Post a Comment