First you need to define a list of turtle commands for drawing a square. We will name it square1. Actual drawing of the turtle image is done using draw function, the turtle command list is given as an argument to draw .
(draw square1)
Since the command list for drawing a square has a repeating pattern, it is better to define it separately and use it repeatedly. We will name it side and we will repeat it 4 times using repeat .
(draw repeat-square)
We can use a previously defined square and draw two of those in the same picture. We will define a list of commands move to move to a new location and changes the pen color before drawing the second square.
movesquare1))
(draw two-squares)
To be able to draw squares with changing side lengths, we need to define a function, which we will name changing-square. We need also a helper function changing-side to draw sides with changing lengths. The variable x is the side length. Finally we call the new function changing-square with argument 30 (x=30).
(draw (changing-square30))
You can draw a square also by ordering the turtle to go via some points in the coordinate plane using go-to commands. To get easier coordinates we change the place of the origin with set-origin command.
(draw coordinate-square)
We can draw two square so that the second one is created by mirroring the first one using a pivot point. The pivot point is the location where the mirroring was turned on (mirron-x-on, mirron-y-on), in this example it is the starting point.
square1))
(draw mirroring-square)
We can activate the stamper functionality using stamper-on command. Now the turtle will "stamp" the given image after each movement. Here we use a red circle as the stamp. You could also let the pen draw the line also (here is it taken up).
square1))
(draw stamper-square)
You can change the style of the line using change-pen-style command and the width of the line using change-pen-size command.
Note! This doesn’t work in WeScheme.
square1))
(draw speacial-pen-square)
First we draw a background grid using set-bg-grid . We move to the origin using (go-to 00) and activate the stamper with a blue circle as the stamp. To get the stamps in the right coordinates we need to command the turtle using go-to multiple times. In this example the stamper is inactivated after four points .
(draw line-with-grid)
We move to origin using go-to-origin command and draw a line using a list of stamps.
(draw line-with-stamps)
You can change the background color using change-bg-color color and you can put an additional image on top of it using set-bg-image . In the example we want to draw a picture with different dimensions so draw-custom is used (setting the drawing speed to zero will not affect the drawing speed).
square1))
(draw square-over-bg4002500)
In this example we set the pen color to be a list of colors. Turtle will use each color one after another. The animation speed has been set to be slower (the last argument of draw-custom ). The turtle is also hidden during the first part of the animation.
(draw-custom color-line5005000.5)