Wednesday, March 30, 2011

Overlaid spirals in colour

This is an extension of the simple spiral script to overlay multiple spirals of increasing size in red, green and blue. The first image is colourful, but very messy.

The messiness is caused by the turtle starting from the direction that the spiral ended in. For the second image we reset the direction, so it looks more organised.

reset
canvassize 500,500

for $y = 5 to 20 {
  go 250,250
  direction 0
  if $y ==5 {
    pencolor 0, 0, 0
  }
  else if $y < 11 {
    pencolor 105 + ((10 - $y)*30), 0, 0
  }
  else if $y < 16 {
    pencolor 0, 105 + ((15 - $y)*30), 0
  }
  else {
    pencolor 0, 0, 105 + ((20 - $y)*30)
  }
  for $x = 2 to 20 {
    repeat $x {
      forward $y
      turnright 105 / $x
    }
  }
}

No comments:

Post a Comment