Details
A turtle follows a sequence of commands: draw lines and arcs, rotate, draw in different colors, go to a specific place on the screen, etc.
ResourceFunction["TurtleArt"] was inspired by the
LOGO programming language and was designed to be easy enough for children and yet powerful enough for people of all ages.
The following fields are supported:
| TurtleArt["Background"] | the screen color |
| TurtleArt["Color"] | the color of the turtle's pen |
| TurtleArt["Heading"] | the heading of the turtle |
| TurtleArt["PenQ"] | True if the pen is down; False otherwise |
| TurtleArt["Pensize"] | the width of the turtle's pen |
| TurtleArt["Shade"] | the shade of the turtle's pen |
| TurtleArt["TurtleQ"] | whether the turtle is being shown |
| TurtleArt["X"] | the x (horizontal) coordinate of the turtle |
| TurtleArt["Y"] | the y (vertical) coordinate of the turtle |
For appropriate fields, ResourceFunction["TurtleArt"]["field"]=val can be used to set the value of a field.
The following commands are supported:
| TurtleArt[“Arc”][a,r] | move the turtle in an arc with an angle a and a distance of r units |
| TurtleArt[“Back”][n] | move the turtle backward n units |
| TurtleArt[“Clean”][] | clear the screen and reposition the turtle to the center |
| TurtleArt["Draw"][] | draw to the screen |
| TurtleArt[“FillScreen”][c,s] | fill the screen with a color c and a shade s |
| TurtleArt["Forward"][n] | move the turtle forward n units |
| TurtleArt["HideTurtle"][] | hide the turtle icon |
| TurtleArt["Left"][n] | turn the turtle left n units |
| TurtleArt["PenDown"][] | lower the turtle's pen so that it will draw |
| TurtleArt["PenUp"][] | raise the turtle's pen so that it will not draw |
| TurtleArt["Right"][n] | turn the turtle right n units |
| TurtleArt["SetColor"][c] | set the color of the turtle's pen to c |
| TurtleArt["SetHeading"][h] | set the heading of the turtle to h |
| TurtleArt["SetPensize"][w] | set the width of the turtle's pen to w |
| TurtleArt["SetShade"][s] | set the shade of the turtle's pen to s |
| TurtleArt["SetXY"][x,y] | set the position of the turtle to {x,y} |
| TurtleArt["ShowTurtle"][] | show the turtle icon |
ResourceFunction["TurtleArt"] works with a coordinate system. The turtle's default position is {0,0}, which is the middle of the screen:
The heading of the turtle is given in degrees, where 0 degrees means the turtle is directed upwards.
In ResourceFunction["TurtleArt"], the color and shade numbers are between 0 and 100. The default color is 0 and the default shade is 50: