Library reference for (c211 turtle)


(block turtle code ...)
=> unspecified

Store the current state of turtle then run code .... After that code has finished, restore turtle to its previous state. Multiple calls to block can be nested, each storing and restoring the turtle state in a correctly nested fashion.

Turtle location, facing, pen state, and pen color will all be stored.

(clone turtle)
=> a turtle

Copy a given turtle, creating a second turtle with the location, facing, pen status, and pen color as the given turtle. When drawing the original turtle, this clone will be drawn as well.

(color r g b)
=> a color

From (c211 color).

Create a new color with red, green, and blue values of r, g, and b respectively.

(color-equal? color color)
=> #t or #f

From (c211 color).

Test if two colors are equal.
5A

(color-ref color band)
=> an integer in the range [0, 255]

From (c211 color).

band should be one of either the symbols red, green, or blue or the corresponding integers 0, 1, or 2. Access the color object, returning the amount of that specified color as an integer in the range [0, 255] where 0 is none of that color and 255 is the maximum amount.

(color-set! color band value)
=> unspecified

From (c211 color).

band should be one of either the symbols red, green, or blue or the corresponding integers 0, 1, or 2. Alter the color object setting the value (should be in the range [0, 255]) in that band.

(color? obj)
=> #t or #f

From (c211 color).

Test if obj is a color.

(draw-turtle turtle)
=> unspecified

Display turtle and any turtles cloned from it on the screen.

(drop-pen! turtle)
=> unspecified

Drop the pen on turtle.

(hatch)
(hatch facing)
(hatch x y)
(hatch x y facing)
(hatch x y facing up/down color)
=> a turtle

Create a new turtle. By default, the turtle is at 0 x 0, facing north, and has a pen that is down and black.

If specified:
x and y can be any real number.
facing should be a real number representing a degree rotation where 0 is north and positive is clockwise.
up/down should be either the symbol up or down.
color should be a color from the (c211 image) library.

(lift-pen! turtle)
=> unspecified

Lift the pen on turtle. Future movement will not draw lines until the pen is dropped again.

(live-delay)
(live-delay delay)
=> see below

If delay is specified, set the delay after updating the display when animating turtle graphics. delay can be any real number of seconds. If not specified, return the delay's current value.

live-delay defaults to 0.1.

(live-display)
(live-display enable)
=> see below

If enable is specified and either #t or #f, enable or disable the live turtle view based on its value. Otherwise return its current value.

live-display defaults to #f.

(move! turtle n)
=> unspecified

Move the turtle along its current facing by n units. If the pen on turtle is currently the symbol down, draw a line.

(move-to! turtle x y)
=> unspecified

Move the turtle directly to the point x x y, preserving its current facing. If the pen on turtle is currently symbol down, draw a line.
aliases: teleport!

(pen-color turtle)
=> a color

Get the current pen color on turtle as a color from (c211 image).

(pen-up/down turtle)
=> the symbol up or down

Return the current up/down state of the pen on turtle.

(repeat n code ...)
=> unspecified

Repeat a block of code n times purely for side effects. Equivalent to (foreach (lambda (x) code ...) (iota n)) except the list does not need to be constructed.

(set-pen-color! turtle color)
=> unspecified

Set the current pen color on turtle to a color from (c211 image).

(turn-left! turtle angle)
=> unspecified

Rotates turtle left/counter-clockwise by angle degrees.
aliases: turn-counter-clockwise!

(turn-right! turtle angle)
=> unspecified

Rotates turtle right/clockwise by angle degrees.
aliases: turn-clockwise! turn!

(turn-to! turtle angle)
=> unspecified

Turn turtle directly to the given facing of angle degrees. North is 0 with positive going clockwise.

(turtle->image turtle)
=> an image

Convert turtle to an image from (c211 image).

(turtle-location turtle)
=> a list (x y)

Gets the current location of turtle as a list (x y).