2 Value Turtles
(require graphics/value-turtles) | package: htdp-lib |
The value turtles are a variation on traditional turtles. Rather than having just a single window where each operation changes the state of that window, in the graphics/value-turtles library, the entire turtles window is treated as a value. This means that each of the primitive operations accepts, in addition to the usual arguments, a turtles-window value; instead of returning nothing, each returns a turtles-window value.
procedure
(turtles width height [ init-x init-y init-angle]) → turtles? width : real? height : real? init-x : real? = (/ width 2) init-y : real? = (/ height 2) init-angle : real? = 0
procedure
(move-offset h v turtles) → turtles?
h : real? v : real? turtles : turtles?
procedure
(draw-offset h v turtles) → turtles?
h : real? v : real? turtles : turtles?
procedure
(erase-offset h v turtles) → turtles?
h : real? v : real? turtles : turtles?
procedure
(turn/radians theta turtles) → turtles?
theta : real? turtles : turtles?
procedure
(set-pen-width turtles width) → turtles?
turtles : turtles? width : (real-in 0 255)
Added in version 1.5 of package htdp-lib.
procedure
(set-pen-color turtles color) → turtles?
turtles : turtles? color : (or/c string? (is-a?/c color%))
Added in version 1.6 of package htdp-lib.
Instead, the merge accepts two turtles windows and combines the state of the two turtles windows into a single window. The new window contains all of the turtles of the previous two windows, but only the line drawings of the first turtles argument.
procedure
(turtles-width turtles) → (and/c real? positive?)
turtles : turtles?
procedure
(turtles-height turtles) → (and/c real? positive?)
turtles : turtles?
procedure
(turtles-pen-width turtles) → (real-in 0 255)
turtles : turtles?
Added in version 1.5 of package htdp-lib.
procedure
(turtles-pen-color turtles) → (is-a?/c color%)
turtles : turtles?
Added in version 1.6 of package htdp-lib.
procedure
(turtle-state turtles) →
(listof (vector/c real? real? real? #:immutable? #t #:flat? #t)) turtles : turtles?
Added in version 1.5 of package htdp-lib.
procedure
(restore-turtle-state turtles state) → turtles?
turtles : turtles?
state :
(listof (vector/c real? real? real? #:immutable? #t #:flat? #t))
Added in version 1.5 of package htdp-lib.
procedure
(turtles-pict turtles) → pict?
turtles : turtles?
Added in version 1.5 of package htdp-lib.
2.1 Examples
(require graphics/value-turtles-examples) | |
package: htdp-lib |
The graphics/turtle-examples library’s source is meant to be read, but it also exports the following examples.
procedure
(radial-turtles n turtles) → turtles?
n : exact-nonnegative-integer? turtles : turtles?
procedure
(spaced-turtles n turtles) → turtles?
n : exact-nonnegative-integer? turtles : turtles?
procedure
(regular-poly sides radius turtles) → turtles?
sides : exact-nonnegative-integer? radius : real? turtles : turtles?
procedure
(regular-polys n s turtles) → turtles?
n : exact-nonnegative-integer? s : any/c turtles : turtles?