Simple Turtle for Processing

I've been trying to implement some fractals with Processing recently, and I noticed that the Wikipedia page for the Koch Snowflake contained source code for generating the snowflake in the Logo language. This brought back memories of the Turtle robot we used to use in primary school - a large grey dome with wheels and a felt-tip pen placed in a hole in the top, which trundled around leaving lines on a large piece of paper spread out on the floor. This was (I think) my first contact with any sort of programming.

I decided to implement a basic Turtle for Processing. This is extremely simple - it can only drive forward and back, turn left or right through a specified angle and raise or lower its "pen". But, combined with some simple programming routines and a bit of recursion, it can create some really nice patterns.

The Processing source code for the Turtle class can be found here: turtle.pde

A couple of examples using this class:

Donut Spiral - based on one of the examples of Logo on its Wikipedia page.

Koch Snowflake - this is based on the Logo source code found on the Wikipedia page for the Koch Snowflake. Click to zoom in on the fractal (Warning: I haven't implemented any bounding for the zoom, so the fractal simply gets larger each time. The program will get slower to run the more times you click!)

Koch Snowflake

Comments

blog comments powered by Disqus