Saturday, February 19, 2011

Learning RGB - more colours

This is a rewrite of the previous Learning RGB script. It loops through a few more colours.

reset
penwidth 2
penup

turnleft 90
forward 113
turnleft 90
forward 113
turnleft 180
pendown

for $r = 0 to 1 {
  for $g = 0 to 1 {
    for $b = 0 to 1 {
      for $x = 0 to 255 step 2 {
        pencolor $r*$x,$g*$x,$b*$x
        forward 16
        turnright 90
        forward 1
        turnright 90
        pencolor $r*($x + 1),$g*($x + 1),$b*($x + 1)
        forward 16
        turnleft 90
        forward 1
        turnleft 90
      }  

      penup
      turnleft 90
      forward 256
      turnright 90
      forward 17
      pendown
    }
  }
}

No comments:

Post a Comment