Saturday, January 29, 2011

Four coloured spirals

The first logo (kturtle) script for this blog. It is a simple one which demonstrates learning a command. We used the HSL Color Picker to choose the RGB values.


This is the script to create the above image. If you change the numbers after forward and turnright, turnleft in the spiral command you can change the spiral shape.

reset

# start in the right spot
penup
turnright 90
forward 100
turnleft 90
forward 20
pendown

#
# This command creates a spiral
#
# $scale: how big should the spiral be
# $redcolor, $greencolor, $bluecolor: RGB colours for the spiral
#
learn spiral $scale, $redcolor, $greencolor, $bluecolor {
  pencolor $redcolor, $greencolor, $bluecolor
  for $i = 0 to 71 {
    forward $scale * 20
    turnright 30
    forward $scale * 5
    turnleft 175
    forward $scale * 100
  }
}

spiral 2, 255, 245, 56

penup
turnleft 100
forward 220
pendown
spiral 1, 179, 0, 173

penup
turnright 110
forward 200
pendown
spiral 0.5, 0, 235, 121

penup
turnright 110
forward 200
pendown
spiral 1, 255, 77, 88

No comments:

Post a Comment