Dig Trig
Turtle Graphics
Menu

Turtle Graphics - Programming For Kids

Bookmark and Share
When I was a wee lad in 4th and 5th grade (1984/1985), we had a couple Apple II+ computers. One of the first programming experiences was with Apple Logo, a turtle graphics program that had a small language, but was still very much a 'programming' environment. Thus began my code monkey fate. My son (9 yrs old) asked me if he could learn to program... so I created this in hopes that he finds as much enjoyment as I did.

I took this a step further for myself and added the ability to define your own functions. There is a link below to export your functions. Just copy the string back in next time to rebuild your function library. I also added variables and basic operations, random number generators, IF logic conditions and LIFO stacks. It's great for self-similar fractals and L-system generation!

UPDATE: I am now using the 'canvas' tag in HTML5 for the drawing routines. The canvas tag is not supported in all browsers. I suggest using Firefox or Safari.
CL : Clear H : Home PU : Pen Up PD : Pen Down PC color : Pen Color (HTML color names, RGB hex as RGB or RRGGBB, RGBA hex as RRGGBBAA) FD value : Move Forward # pixels BK value : Move Backward # pixels RT value : Right Turn # degrees LT value : Left Turn # degrees SAVE : Saves current Position, Angle and Pen Color (pushes onto LIFO state stack) RESTORE : Restores saved Position, Angle and Pen Color (pops from LIFO state stack) NULL : Do Nothing (useful in logic conditions: IF Less Than = IFGTE x y [NULL][...]) RP value [...] : Repeats [...] # times (can use REPEAT instead) TO name [...] : Creates a function of commands (call the name, or click on the button) SET var value : var = value ADD var value : var = var + value SUB var value : var = var - value MULT var value : var = var * value DIV var value : var = var / value PRCNT var value : var = var * value / 100 PUSH value : Pushes value onto LIFO variable stack POP : Pops value from LIFO variable stack (eg SET X POP) RAND : Random number 0-100 RANDANGLE : Random number 0-359 IFNZ value [...][...] : If value != 0 runs first, otherwise second IFEQ value1 value2 [...][...] : If value1 = value2 runs first, otherwise second IFGT value1 value2 [...][...] : If value1 > value2 runs first, otherwise second IFGTE value1 value2 [...][...] : If value1 >= value2 runs first, otherwise second

Functions:

IE is not supported.
Get a real browser.