Saturday, February 26, 2011

A rotated polygon

Following on from the rotated square we extended the script to draw the regular polygons from nonagon to triangle.
We chose custom colours for each of the polygons.
reset

for $y = 9 to 3 step -1
{
  if $y == 3 {
    pencolor 194, 0, 0 
  }
  else if $y == 4 {
    pencolor 0, 194, 0 
  }
  else if $y == 5 {
    pencolor 0, 0, 194 
  }
  else if $y == 6 {
    pencolor 0, 194, 194 
  }
  else if $y == 7 {
    pencolor 194, 194, 0 
  }
  else if $y == 8 {
    pencolor 194, 0, 194
  }
  else if $y == 9 {
    pencolor 255, 239, 59
  }
  repeat 24 {
    turnright 15
    repeat $y {
      forward 60
      turnleft 360/$y
    }
  }
}

No comments:

Post a Comment