Sunday, January 30, 2011

Another spiral variant

Another variant of a spiral with a small inner circle and longer outer arms.
We wanted to add some colour so we split the loop into three parts and added a different colour for each loop.

reset

penup
forward 50
turnright 180
pendown

# red layer
pencolor 255, 0, 0
for $x = 1 to 60 {
  forward 109
  turnright 100
  forward 39
  turnleft 29
  forward 78
  turnleft 189
}

# green layer
pencolor 0, 255, 0
for $x = 1 to 60 {
  forward 109
  turnright 100
  forward 39
  turnleft 29
  forward 78
  turnleft 189
}

# blue layer
pencolor 0, 0, 255
for $x = 1 to 60 {
  forward 109
  turnright 100
  forward 39
  turnleft 29
  forward 78
  turnleft 189
}

Saturday, January 29, 2011

A spiral variant

A spiral variant. The kids enjoy changing the numbers and experimenting.
reset

penup
forward 50
turnright 180
pendown

for $x = 1 to 200 {
  forward 109
  turnright 100
  forward 39
  turnleft 29
  forward 78
  turnleft 189
}

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