plot::Turtle
-- graphical
primitive for turtle graphicsplot::Turtle
()
creates a turtle,
which is a drawing device which understands few simple commands.
plot::Turtle()
plot::Turtle
represent a simple
drawing device called a turtle. A turtle may be used to create
2-dimensional line drawings.plot
. One may also insert a turtle into
a graphical scene of the plot
library like any other
graphical object.::
. One method of a turtle for example has
the name line
. With the call t::line(1)
one
causes the turtle t
to draw a line of length 1 in its
current direction.
The following methods are available for a turtle t
:
t::color(c)
changes the actual colour of the turtle
t
to c
. The colour must be given as a list of
3 real-valued numbers in the range between 0 and 1, similar to the
other colour values of the plot library.
The method returns the turtle.
t::left(deg)
changes the direction of the turtle
t
. It rotates left for deg
degrees.
The method returns the turtle.
t::right(deg)
changes the direction of the turtle
t
. It rotates right for deg
degrees.
The method returns the turtle.
t::line(len)
causes the turtle t
to move
forward in its current direction, drawing a line in its current colour.
The length of the line is len
.
The method returns the turtle.
t::move(len)
causes the turtle t
to move
forward in its current direction without drawing a line. The length of
the move is given by len
.
The method returns the turtle.
t::push()
causes the turtle t
to save its
current state, i.e., its position, direction and colour. The state is
pushed onto a stack.
The method returns the turtle.
t::pop()
restores the state of the turtle to the one
which is currently stored on the stack. The top element of the stack is
popped off the stack.
The method returns the turtle.
plot::Turtle
has type
"graphprim"
, i.e., if o
is such an object,
then the result of type(o)
is the string
"graphprim"
.Evaluating an object of type plot::Turtle
returns
itself.
getPlotdata(dom t)
t
in a plot2d
and plot3d
conforming syntax,
respectively, i.e., it has the form [Mode = List, [polygon(...)],
...]
.plot::Scene
to build the plot data of
the graphical scene.slot(dom t, string
slotname)
slotname
of
t
. slotname
must be the name of a method of
the turtle, see above.slotname
is an invalid method name, then an error
message is issued.slot
, i.e., one may use it in the form
t::slotname_id
(here, slotname_id
must be the
identifier corresponding to the string slotname
), or in
functional notation slot(t, slotname)
.print(dom t)
plot::Turtle
to the screen.print
for details.We create a turtle, let it draw a triangle and then show its path:
>> T := plot::Turtle(): T::right(90): T::line(1): T::left(120): T::line(1): T::left(120): T::line(1): plot(T, Axes = None)
We draw a star-like object:
>> T := plot::Turtle(): for i from 1 to 36 do T::right(170); T::line(1) end_for: plot(T, Axes = None)
Turtle
plot
library.