Expand description
Turtle interpretation: walk an L-system string into line segments, with a
branch stack for [/]. A build-time step (runs inside Scene::configure,
off the hot path) that produces the base geometry a generator scene caches
and then only transforms per frame.
Commands (the common turtle vocabulary):
F,G— step forward, drawing a segmentf— step forward without drawing+— turn left by the configured angle-— turn right by the configured angle[— push position + heading]— pop position + heading- anything else — no-op (grammar variables such as
Xthat only expand)
The space turtle (TurtleMode::Space) reads the same commands, with +
and - yawing about its up vector, and five more, each turning by the
configured angle:
&,^— pitch down, up (about the left vector)\,/— roll left, right (about the heading)|— turn around (yaw by 180 degrees)
[ and ] push and pop the whole frame. The flat turtle leaves those five
symbols inert.
Structs§
- Drawn
- One draw step the
Pentook: a segment in draw-step units, the generation it was drawn at, and whether it continues the segment drawn just before it. - Pen
- The turtle an endless figure walks with, one symbol at a time.
- Turtle3d
- The space turtle’s state: a position and an orientation frame of three unit
vectors, heading
H, leftLand upU, withU = H x L.
Enums§
- Turtle
Mode - Which turtle walks the grammar:
[generator] turtle(ADR-0258).
Functions§
- normalize_
fit - Center
segsand uniformly scale them to fit within[-target, target]on the larger axis, so any figure (whatever its raw extent per depth) frames itself in the view. A degenerate (zero-extent) set is left untouched. - on_grid
prounded to the nearest point of theGRID.- sphere_
fit - Centre
segson their bounding box’s centre and scale them uniformly so every endpoint lies within a sphere of radiusradiusabout the origin, and return the sphere’s radius after the fit —radius, or0for an empty or degenerate set, which is left untouched. - walk
- Walk
sintoout(cleared first) as base geometry — positions only; the scene fills colour/width per frame.angleis in radians. Segments beyondmax_segmentsare dropped and counted (the ADR-0007 cap is never silent): the returnedusizeis how many draw steps were dropped. - walk_
3d_ with_ depths walk_with_depthsfor the space turtle:swalked into 3D segments inout, with each segment’s generation depth indepths, index-aligned the same way and under the same cap. Both are cleared first; the returnedusizeis how many draw steps the cap dropped.- walk_
with_ depths walk, plus the generation depth of every emitted segment written intodepths(cleared first) — the branch-nesting level the turtle drew it at (ADR-0059’slsystemcolour axis). Depth0is the trunk; each unclosed[is one more generation, so a segment’s depth is how many branch pushes are still open above it.