TinkerPad

In chapter 6 of Lauren Ipsum, N. Veterate Tinker teaches our hero how to use a mechanical turtle to draw figures. She learns a simplified version of the programming language Logo. Type commands into the window on the left, and click GO. Click SAVE to show off your masterpiece. Scroll down for help and hints. Enjoy!



speed 500 define serif dir move 0.7 turn dir 3 repeat 30 define T turn left 90 move 18 turn right 90 move 100 turn right 90 move 18 turn right 180 serif left move 30 turn left 90 move 110 serif right turn right 180 move 40 turn right 180 serif right move 110 turn left 90 move 30 serif left penup move 100 pendown T color green turn left 42 T penup move 100 define square size move size turn right 90 repeat 4 pendown color blue square 50 turn right 13 repeat 13 move 40 color red square 42 turn right 13 repeat 13 turn left 30 penup color black move 12 turn right 3 dot repeat 360

Get the source on GitHub.

Tinker's Turtle understands a very basic vocabulary, one command per line.

DOT

Draws a dot on the paper, wherever the turtle happens to be.

MOVE distance

The turtle walks forward some distance, in whatever direction his nose is pointing.

REPEAT number-of-times

This allows you to tell the turtle to do whatever it just did multiple times.

With just these three commands you can tell the turtle to draw a line of dots:



TURN RIGHT|LEFT degrees

The turtle turns in place left or right, by some number of degrees. If you TURN RIGHT 360, the turtle will end up exactly where it started. If you TURN LEFT 180 it will make one half-turn.



Now, all of that DOT MOVE 12 stuff can get really boring to repeat. So let's add a really clever idea.

DEFINE command [arg1, arg2, ...]

Creates a new command (function/procedure/subroutine/etc). Everything up to the next empty line becomes part of that command. For example, let's write a command to draw a LINE. Now you can use LINE just like you use DOT, and draw a square.



You can even make a new command for drawing squares, and get REALLY fancy!



PENUP

PENDOWN

Instead of making DOTs, you can tell Tinker's Turtle to draw thin lines instead. Just tell it to leave his pen down:



Or even use them together!



COLOR color

Change the color of the pen.



SPEED number

Make the turtle go faster or slower. By default he runs at 200 pixels per second.

Like it? Buy Lauren Ipsum in paperback, for Kindle, iBooks, or the Nook.