Turtle Graphics

Instructions

Turtle Graphics uses a set of text commands to control the motion of a "turtle". The turtle draws out a path depending on where it is instructed to go.

Commands

The commands are:

U Up Lift the pen off the page (ie. stop drawing)
D Down drop the pen back on to the page (ie. start drawing)
F <n> Forward Move forward <n> steps
L <n> Left Turn to the left by <n> degrees
R <n> Right Turn to the right by <n> degrees
C <colour> Colour Change the pen colour
( … ) <n> Repeat Repeat the commands in the brackets <n> times

Notes

  • Colours can be specified by a word (eg. 'red', 'blue', 'lime', 'silver') or by a HTML colour code (eg. '#FF8000').
  • Repeats can be nested (that is, a repeat can contain a repeat).

Examples

Copy and paste these examples into the commands box, and press "Update":

A Square:

F10 L90 F10 L90 F10 L90 F10

Another Square:
This time using Repeat.

(F10 L90) 4

A Star:
The stuff before the 'D' is to reposition the star into the middle of the screen.

U F3 L90 F5 L180 D (F10 R144) 5

A Familiar Corporate Logo:

C red R30 (F5 L60 F5 L120 F5 L60 F5 R 120) 3
Page tags: activity ict interactive
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License