Turtle#
Turtle (also RawTurtle, Pen, RawPen) is the main drawing actor.
All turtle-module functions delegate to the global default Turtle instance.
Movement#
Method / Alias |
Description |
|---|---|
|
Move forward by |
|
Move backward by |
|
Turn right by |
|
Turn left by |
|
Move to absolute position |
|
Set the x coordinate; y stays unchanged. |
|
Set the y coordinate; x stays unchanged. |
|
Set the heading to |
|
Move to origin |
|
Draw a circle of given radius. |
|
Draw a dot at the current position. |
|
Move to |
Pen control#
Method / Alias |
Description |
|---|---|
|
Lift the pen; movement does not draw. |
|
Lower the pen; movement draws. |
|
Return |
|
Set line width. |
|
Set pen color. |
|
Set fill color. |
|
Set pen and fill color at once. |
|
Get or set multiple pen attributes at once. |
Fill#
Method |
Description |
|---|---|
|
Mark the start of a region to fill. |
|
Close and fill the region. |
|
Return |
State queries#
Method |
Description |
|---|---|
|
Return current |
|
Return x coordinate. |
|
Return y coordinate. |
|
Return current heading in degrees. |
|
Return angle towards point |
|
Return distance to point |
|
Return |
Appearance#
Method |
Description |
|---|---|
|
Set the turtle shape. |
|
Scale the turtle shape. |
|
Hide the turtle icon. |
|
Show the turtle icon. |
|
Rotate the turtle shape by |
|
Set the tilt angle of the turtle shape. |
|
Set drawing speed (0-10, or named string). |
Stamps and undo#
Method |
Description |
|---|---|
|
Stamp the turtle shape on the canvas; return stamp id. |
|
Remove a specific stamp. |
|
Remove first |
|
Undo the last action. |
|
Set the undo buffer size. |
|
Return the number of actions in the undo buffer. |
Mouse and click events#
Method |
Description |
|---|---|
|
Bind a function to a mouse-click on the turtle. |
|
Bind a function to dragging the turtle. |
|
Bind a function to releasing the mouse button on the turtle. |
Polygon#
Method |
Description |
|---|---|
|
Start recording polygon vertices. |
|
Stop recording. |
|
Return the recorded polygon. |
Module-level functions#
All Turtle methods are also available as module-level functions that
delegate to the global default turtle:
import miniworlds_turtle as turtle
turtle.forward(100)
turtle.pencolor("red")
turtle.circle(50)