Turtle Graphics#
The original Python Turtle is based on Tkinter, a Python binding of the Tk GUI toolkit, which is not usable in the browser. Therefore we re-implemented the turtle library using PixiJS, a library for 2d rendering. Since version 1.8.0, the rendering lives in its own package, @tigerpython/turtle-renderer, which is developed in a separate repository. In WTP, python runs in a web worker thread while the pixi Canvas is rendered in the main thread. The communication happens over the PostMessage API. However to simplify the process, we use Comlink, a library, that lets us call functions within the respective other thread.
turtle#
We do support most of the Python Turtle functionality with the exception of a few functions which are listed below. Additionally, we also added a few methods.
Additional Turtle Functions#
Function |
Description |
|---|---|
|
Creates a new color with 4 values (r, g, b, a). Unlike the Python turtle, an alpha channel is supported ( |
|
Returns the color below the turtle |
|
Returns the color below the turtle as a string: the name of a known color (e.g. |
|
Pauses the turtle for |
Unsupported Functions#
Turtle
undo
resizemode
shapesize
shearfactor
settiltangle
tiltangle
tilt
shapetransform
begin_poly
end_poly
get_poly
getturtle
getpen
getscreen
setundobuffer
undobufferentries
Screen
bgpic
resetscreen
setworldcoordinates
ontimer
colormode
getcanvas
getshapes
register_shape
exitonclick
gturtle#
The gturtle Library known from TigerJython was originally based on the Java Turtle. The Java Turtle does not run in the Browser, and therefore we implemented it on top of the turtle library.