On this page:
Simple example
7.7

1 Racket Turtle Principles

With Racket Turtle - library you can draw traditional turtle-graphics by ordering turtle (black triangle) to move forward, to turn left, to lift its pen up, to put it down etc. In addition to this you can draw stamps in the turtle positions, mirror turtle’s movements vertically and horizontally or order turtle to travel via some specific coordinates. You can make your images more interesting by changing the color of the pen, the width and type of the line, also the background color and image can be set to your preferences.

To give orders to turtle you need to create a list of turtle commands. This list is given as an argument to a drawing function, which reads the commands and draws the image. By selecting a different drawing function, you can change the animation window size and drawing speed, store the animation as a animated gif or draw the image step by step.

It is preferable to define the command list and give it a good desciptive name. The simplest command list contains one command and its arguments written inside parenthesis.

Simple example

This command list draws one blue line of length 100 pixels from the middle of the animation screen towards the top of the screen (the starting point of the turtle is in the middle of the screen in (250, 250) and it is facing up).

Defining a command list line1 for drawing the line (in definitions window):

(define line1 (list (forward 100)))

Calling the drawing function draw with line1 as the argument (in interactions window):

(draw line1)

All Racket Turtle commands and drawing functions are presented in the following chapters.