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
    }
  }
}

Friday, March 25, 2011

A messy colour spiral

A rather messy spiral. We originally wrote this in black, but then added the random colour to show a little more of what was happening.

This script is a great one to experiment with changing the forward and turnright values.
reset

for $x = 2 to 50 {
  pencolor (random 0,255), (random 0,255), (random 0,255)
 repeat $x {
  forward 20
  turnright 555 / $x
}

Wednesday, March 16, 2011

A simple spiral

This script draws a simple spiral. It came from a simple change to the polygon spiral script.

reset
penup
turnleft 180
forward 150
turnright 90
pendown

for $x = 2 to 80 {
 repeat $x {
  forward 10
  turnright 105 / $x
}

Sunday, March 6, 2011

Polygon with colour

The plain black polygon was visually boring, so we started by changing the colour to gold:


Friday, March 4, 2011

Polygon

This is a simple script drawing polygons. Note how as the number of lines in the polygon increases the shape looks more and more like a circle.
reset

penup
turnleft 180
forward 150
turnright 90
pendown

for $x = 2 to 50 {
 repeat $x {
  forward 20
  turnright 360 / $x
}