On this page:
forward
turn-left
turn-right
repeat
pen-up
pen-down
go-to
go-to-origin
change-color
change-pen-size
change-pen-style
change-bg-color
set-bg-image
set-bg-grid
set-origin
stamper-on
stamper-off
mirror-x-on
mirror-y-on
mirror-x-off
mirror-y-off
clean-up
hide-turtle
show-turtle
6.3.90.900

2 Commands for Racket Turtle

procedure

(forward x)  procedure

  x : real?
Moves the turtle forward x pixels, if given x is positive, backwards it it’s negative.

procedure

(turn-left a)  procedure

  a : real?
Turns the turtle heading to the left a degrees, if given a is positive. Negative a will make the turtle to turn right (abs a) degrees.

procedure

(turn-right a)  procedure

  a : real?
Turn the turtle heading to the right a degrees, if given a is positive. Negative a will make the turtle to turn left (abs a) degrees.

procedure

(repeat k command-list)  procedure

  k : (and/c integer? positive?)
  command-list : (list-of procedure)
Makes the turtle to repeat k times the commands given in the command-list.

procedure

(pen-up)  procedure

Lifts up the pen so the turtle will not draw a line when it moves. The default position is down.

procedure

(pen-down)  procedure

Puts the pen down so that the turtle will draw a line as it moves.

procedure

(go-to x y)  procedure

  x : real?
  y : real?
Makes the turtle go to a given point (x, y). The origin of the turtle image is in the low left corner unless it has been moved (see: set-origin).

procedure

(go-to-origin)  procedure

Makes the turtle go to the origin of the animation window. The origin is in the low left corner unless it has been moved (see: set-origin).

procedure

(change-color color)  procedure

  color : image-color?
(change-color color-list)  procedure
  color-list : (list-of image-color?)
Changes the color of the pen (the default color is blue). The argument can be a single color or a color-list, which contains one or more colors. Colors in the color-list are used one by one and when the list is finished it starts from the beginning.

procedure

(change-pen-size width)  procedure

  width : (and/c integer? (<= 0 255))
Sets the width of the pen. The width is an interger between 0 - 255.

Note! WeScheme doesn’t support this.

procedure

(change-pen-style style)  procedure

  style : pen-style?
Changes the pen style. The style can be one of these: "solid", "dot", "long-dash", "short-dash" or "dot-dash".

Note! WeScheme doesn’t support this.

procedure

(change-bg-color color)  procedure

  color : image-color?
Changes the background color (the default color is white). This command should be used first since it fills the whole image with the given color.

procedure

(set-bg-image img)  procedure

  img : image?
Sets the given image img as a background image. This command should be used before drawing the actual image, since img is put on top of the existing turtle drawings.

procedure

(set-bg-grid width height color)  procedure

  width : (and/c integer? positive?)
  height : (and/c integer? positive?)
  color : image-color?
Draws a background grid with given cell width, height and color. This command should be used before drawing the actual turtle drawings.

procedure

(set-origin)  procedure

Stores the current position of the turtle as a new origin. The location of the origin is shown as a red dot during the turtle animation.

procedure

(stamper-on stamp)  procedure

  stamp : image?
(stamper-on stamp-list)  procedure
  stamp-list : (list-of image?)
Activates the stamper. Stamper draws one stamp in each new turtle location. If the argument is a list of images stamp-list stamps are used one after another according to the list. After all stamp images have been used once, the list starts again from the beginning.

The stamper doesn’t affect the pen so if the pen is down, a line will be drawn in additions to the stamps.

procedure

(stamper-off)  procedure

Removes the stamper.

procedure

(mirror-x-on)  procedure

Copies the turtle commands so that they are mirrored horizontally e.g. there will be a second mirrored image in addition to the original image. The position of the mirroring axis is set to be a vertical line, which y-coordinate is taken from the point in which mirror-x-on was used. If mirror-y-on is used in the same location, the mirroring will be done also vertically.

procedure

(mirror-y-on)  procedure

Copies the turtle commands so that they are mirrored vertically e.g. there will be a second mirrored image in addition to the original image. The position of the mirroring axis is set to be a horizontal line, which x-coordinate is taken from the point in which mirror-y-on was used. If mirror-x-on is used in the same location, the mirroring will be done also horizontally.

procedure

(mirror-x-off)  procedure

Removes horizontal mirroring.

procedure

(mirror-y-off)  procedure

Removes vertical mirroring.

procedure

(clean-up)  procedure

Cleans up the animation screen including the background image and grid but keeps the background color. Also the location and heading of the turtle are kept.

procedure

(hide-turtle)  procedure

Hides the turtle sprite for the duration of the animation (turtle is visible as a default). Turtle sprite is a black triangle showing the location and current heading of the turtle.

procedure

(show-turtle)  procedure

Shows turtle sprite again during the animation. Turtle sprite is a black triangle showing the location and current heading of the turtle.