Scripts
Variables
declare vars with: var name = 6 [3 20]
speed
30
Script Reference
Turtle commands, helpers, and quick patterns
Use the editor on the left, then run the script or drag sliders to re-render.
Expressions use degrees for trig functions, and
# starts a line comment unless it forms a
hex color.Movement
fd n forward
bk n back
rt deg turn right
lt deg turn left
home center + heading
setpos x y relative to center
seth deg absolute heading
Pen + Color
pu pen up
pd pen down
size n stroke width
alpha n 0 to 1 opacity
color #hex or named color
color hsl h s l HSL color
rainbow animated hue
norainbow fixed color
Shapes + State
circle r draw circle
arc r deg partial circle
dot n filled point
tree len depth [angle] recursive tree
push save turtle state
pop restore turtle state
cs clear canvas
push and pop are useful for branching structures and
radial variations, especially with random angles.Flow + Variables
var name = 6 [3 20] slider variable
let x = expr local value
repeat n [ ... ] fixed loop
for i from to [ ... ] loop with index
Math Functions
sin cos tan degree-based trig
asin acos atan atan2 inverse trig
sqrt abs floor ceil round basics
pow min max mod exp log log2 utilities
random(a, b) float between bounds
randint(a, b) integer between bounds
clamp(x, lo, hi) constrain value
lerp(a, b, t) interpolate 0..1
pi tau e constants
random(n) returns a float from 0 to n. random(a, b) works
in either order.Quick Example
var branches = 42 [8 90] var step = 14 [4 40] var spread = 28 [6 75] color hsl 145 62 58 size 1.5 repeat branches [ push rt random(-spread, spread) fd step + random(step * 0.25, step * 1.4) pop rt 360 / branches ]
Shortcuts: Ctrl/Cmd+Enter run, Ctrl/Cmd+S save, Ctrl/Cmd+Z undo, Shift+Ctrl/Cmd+Z
redo, Esc closes this panel.