Skip to main content

walk_with_depths

Function walk_with_depths 

Source
pub fn walk_with_depths(
    s: &str,
    angle: f32,
    max_segments: usize,
    out: &mut Vec<SegmentInstance>,
    depths: &mut Vec<u32>,
) -> usize
Expand description

walk, plus the generation depth of every emitted segment written into depths (cleared first) — the branch-nesting level the turtle drew it at (ADR-0059’s lsystem colour axis). Depth 0 is the trunk; each unclosed [ is one more generation, so a segment’s depth is how many branch pushes are still open above it.

depths is index-aligned with out by construction, which is the whole reason it is produced here rather than by a second pass over the string: both are pushed in the same branch, under the same cap, so a segment dropped at the cap drops its depth with it. A separate scanner would have to re-derive which characters draw, and would silently desynchronise the moment the turtle’s vocabulary changed.