lib/graphics.py)
Turtle-style drawing backed by Python’s
turtle module. Import with
use graphics;, create a pen with
graphics.icon, then call methods on
your variable — same names as turtle (forward,
right, penup, …).
Statements still end with ;.
Requires a graphical display and tkinter for your Python build. Headless CI / Pyodide will not run the window.
use graphics; artist.setVar(graphics.icon); #comment: or: artist <- graphics.icon; artist.speed(5); artist.forward(100); artist.right(90); artist.forward(100); artist.done();
graphics.icon — create a new pen (SPLArtist handle).graphics.done() — block until the turtle window is closed.type.isArtist(x) — 1 for a graphics pen.
Call on your variable: artist.method(...);
Supports standard turtle names and short aliases:
forward / fd, backward / bk, goto, setpos, homeright / rt, left / lt, setheading / sethpenup / pu, pendown / pd, pensize, color, fillcolorcircle, dot, begin_fill, end_fillclear, reset, hideturtle / ht, showturtle / st, speed, writeposition, xcor, ycor, heading, isdowndone, title, bgcolor, screensize
Any other method name is forwarded to the underlying
turtle.Turtle if it exists.
Example: examples/graphics_demo.spl