Turtle graphic
With turtle graphics , also hedgehog graphic , an image description language is called, imagine in which one, that a pin-carrying robot (the turtle, engl. "Turtle") moves to the drawing plane and lift with simple commands, such as pen, lower, forward walk and turn, can be controlled. This idea was implemented several times, for example as a control language for pen plotters ( HPGL ), as part of the programming language for home computers ( BASIC , Pascal on Amiga , Atari ) and as the basic idea of the educational programming language LOGO .
Graphic systems similar to Turtle graphics continue to be used in schools, because this encourages a motivating, playful introduction and helps train the geometrical conception better than with access using absolute coordinates . Compared to the classic Turtle graphics from LOGO, these systems have in some cases been significantly expanded so that real GUI applications (at school level) can be created with them. This applies, for example, to the Python modules xturtle and frog.
In the professional field, the turtle approach was dropped again in favor of coordinate-based graphic description and is now essentially only used to display fractals using Lindenmayer systems .
Simple commands
The turtle has no memory and executes commands immediately.
-
F(x)
- Move forward by the length x and draw -
f(x)
- Move forward by length x without drawing -
+(a)
- Turn to the left, counter-clockwise, by the angle a -
-(a)
- Rotation to the right, clockwise, by the angle a
Extended commands
A stack is introduced to store the respective current status. A state consists of the current position and direction of the turtle.
For this there are the characters [and] with the following meaning:
-
[
- Put the current status on the stack -
]
- Remove the top state on the stack and make it the current state
Within a pair of brackets, a partial figure, e.g. B. a branch ending in emptiness can be drawn.
See also
Web links
- Java library APLU from Aegidius Plüss with courses (at the University of Education in Bern)
- Turtle graphics for smartphones and tablets, Bern University of Education
- Turtle component for Delphi
- Turtle-based development environment "Frog for Children"
- A turtle graphic language and pattern gallery
- mjoy, an interpreter in Delphi for machine drawing (subset of Joy)