Repository navigation
Description
This is a design call, not an implementation plan. The goal is to invite research and agreement on a richer data model before any code lands.
What we have today
One concept does the job of three:
// src/shapeeditor/strips-model.ts
interface StripEntry {
name: string;
points: [number, number][]; // physical placement
offset: number; // index in the global flat array
count: number; // how many LEDs
pin: string; // controller output
video_offset: number; // sampling offset into the source video
// ...
}A "strip" today simultaneously means:
- What FastLED writes to. A run of LED indices fed from one pin.
- A physical chain. A contiguous sequence of LEDs in space.
- A semantic region. Whatever the artist mentally calls "panel 3, quad 0".
That fusion breaks down at the densities we now want to support (4096-LED layouts) and prevents real-world wiring patterns that the hardware already supports.
Three concepts we want to separate
1. Data strip — what FastLED writes
A pure signal, no position. The thing the controller's pin emits.
interface DataStrip {
id: string; // e.g. "pin1"
length: number; // number of LED slots on the wire
// No points. No (x, y). Position is somebody else's job.
}2. Group (a.k.a. segment) — a named index range with physical points
The thing the UI lets you select, color, and visualize. A group says "this range of indices on this data strip physically lives here."
interface Group {
name: string; // e.g. "q0_p0"
dataStripId: string; // which DataStrip's index space we're in
start: number; // inclusive
end: number; // inclusive
points: [number, number][]; // physical (x, y) for each LED in [start..end]
diameter?: number;
}3. Fork — the same signal physically appears in N places
Real installations Y-split the data line so the same FastLED output drives multiple physical chains. Today our model cannot say "indices 11..33 of pin1 appear in both group B and group C." A fork is the mechanism:
// Two groups sharing the same DataStrip index range = a fork.
{
dataStripId: "pin1",
start: 11, end: 33,
points: [...] // physical chain B
},
{
dataStripId: "pin1",
start: 11, end: 33,
points: [...] // physical chain C — same indices, different (x, y)
}Both groups receive the same color frame for index 17; both render it at their own (x, y).
Worked example
Imagine pin1 has length 100. Wire diagram:
pin1 --[0..10]-- A --fork--+--[11..33]-- B
+--[11..33]-- C
--[34..99]-- D
Data strip:
{ id: "pin1", length: 100 }
Groups:
{ name: "A", dataStripId: "pin1", start: 0, end: 10, points: [11 (x,y)s] }{ name: "B", dataStripId: "pin1", start: 11, end: 33, points: [23 (x,y)s] }{ name: "C", dataStripId: "pin1", start: 11, end: 33, points: [23 (x,y)s] }← fork twin of B{ name: "D", dataStripId: "pin1", start: 34, end: 99, points: [66 (x,y)s] }
The fork is implicit — it is whenever two groups on the same data strip claim overlapping index ranges.
Open design questions
A. Forking
- Implicit (two groups with overlapping ranges = a fork) or explicit (a
forkOffield naming the parent group)? Implicit is less ceremony; explicit is easier to validate and easier to render "fork-aware" UI for. - Fork shape constraints: must forked groups have the same
end - start + 1? (Probably yes — a fork copies a signal range, so the lengths must match.) - Partial forks: can group C cover
[15..33]while group B covers[11..33]? I.e., a fork that taps mid-range. This complicates validation but matches real hardware. - Color-coding forks in the UI: should forked twins share a color hue with a brightness/saturation modifier so they are identifiable as the same signal but visually distinct?
- Realtime video sampling implications: the screenmap drives moviemaker, which samples a video frame at each LED's (x, y) and writes the sample into the data strip. With forks, both physical LEDs at the fork get the same color — which one's (x, y) does the sampler use? Simplest answer: the sampler reads at the first group's (x, y); forks just replicate the resulting color. Worth confirming.
B. Partitioning
- Must groups partition the data strip's index space (every index appears in exactly one non-fork group)? Or are ungrouped indices fine ("dead" indices that exist in the data strip but have no physical home)?
- With forks, partitioning becomes "every index appears in >= 1 group." Is that the right rule, or do we want "every index appears in exactly 1 parent and >= 0 forks"?
- Should the editor warn (not block) when index ranges are missing? Block at save?
C. Persistence + interop
The screenmap.json is consumed by:
- The on-device firmware (FastLED + ScreenMap)
- The moviemaker tool, which samples realtime video onto the surface
- The shape editor itself (round-trip)
- Future tools (shapeviewer, etc.)
Open:
- Should the JSON keep the current per-strip shape for backward compat and add a
groups: [...]anddataStrips: [...]block alongside? Or rewrite the schema and provide a migrator? - Firmware does not care about groups (only data strips + the flat color buffer). Can we tag the JSON so a firmware build picks up just
dataStrips/lengths and a video-sampling build picks upgroups? - Local-only UI state (collapsed groups, selected group, etc.) — localStorage only, or in JSON?
D. UI panels
Today the strips panel is one flat list. With three concepts:
- One unified hierarchical panel: data strip -> groups -> (fork siblings) -> points? Risks panel real estate.
- Tabbed panels: a Strips tab (data strips, lengths, pin assignments) and a Groups tab (the visual segments)?
- Selection model with three scopes: hovering an index, hovering a group, hovering a data strip. The arrow-hover X-ray UX wants to know "which group is selected." Do we need to also support "all groups on this data strip are selected"?
E. Naming / editor workflow
- Auto-name groups ("q0_p0" style) vs. user-named?
- When the user splits a strip (today's "split pin" workflow), does it produce two groups inside one data strip, or two data strips?
- Reverse-group, reorder-group, repin (move group to a different data strip), merge-groups, fork-group — which operations are first-class?
F. Migration
- The current screenmap.json files in the wild have one strip = one chain. The migrator should treat each existing strip as a
{ DataStrip, single Group, no fork }triplet. - The unit tests in
tests/unit/strips-model.test.tsandscreenmap-store.test.tsare the existing contracts. The new model needs equivalent coverage.
Goals
- Real-world LED wiring patterns (forks, daisy-chained panels with shared data) become first-class.
- The UI/UX enhancement work (arrow-hover X-ray on selected group, dense-layout legibility) gets a meaningful "selected group" to operate on.
- Existing screenmap.json files keep loading.
- Moviemaker (realtime video -> LED) keeps working with the new model and gains the ability to sample once and replicate to forked twins.
Non-goals (this design pass)
- Picking a final JSON schema.
- Implementation.
- Rewriting strips-model.ts.
What I would like out of this issue
- Agreement (or pushback) on the three-concept split.
- Decisions on the A-F questions above — at least a leading direction for each.
- A short list of real-world examples (from your installs / from the FastLED community) that exercise forks, so we have concrete shapes to validate against.
- A follow-up issue with a concrete schema + migration plan once 1-3 settle.
Cross-reference: this work was sparked by the dense-layout hover/arrow UX thread and the request to separate strips from logical groups.
Activity
zackees commentedon Jun 14, 2026
Hard constraint: keep the base
screenmap.jsonschema fixedThe
screenmap.jsonshape this project produces is consumed by FastLED-firmware devices (and by WLED-family firmware that includes FastLED'sScreenMapparser). The base schema cannot change — any group/fork/data-strip work has to be additive (new top-level keys that legacy parsers ignore), not a rewrite.The locked-in base schema
Canonical source: FastLED's
ScreenMap::ParseJsoninsrc/fl/math/screenmap.cpp.hppand its header atsrc/fl/math/screenmap.h.Top-level shape:
{ "map": { "<segment_name>": { "x": [<float>, ...], "y": [<float>, ...], "diameter": <float, optional> }, "<another_segment>": { "x": [...], "y": [...], "diameter": ... } } }Parser contract (paraphrased from the FastLED source):
mapmap.<name>map.<name>.xmap.<name>.yx.length.map.<name>.diameterAny extra top-level keys are silently ignored by FastLED. That is the seam this design must use.
Where the new model fits without breaking compat
To stay compatible, all new concepts ride alongside
maprather than inside it:{ "map": { /* unchanged, FastLED-parseable */ }, "dataStrips": [ { "id": "pin1", "length": 100 } ], "groups": [ { "name": "A", "dataStripId": "pin1", "start": 0, "end": 10, "mapName": "A" }, { "name": "B", "dataStripId": "pin1", "start": 11, "end": 33, "mapName": "B" }, { "name": "C", "dataStripId": "pin1", "start": 11, "end": 33, "mapName": "C" }, { "name": "D", "dataStripId": "pin1", "start": 34, "end": 99, "mapName": "D" } ] }Implications:
map.A,map.B,map.C,map.D— the legacy view, ignored extra keys. Forks just appear as two map entries with their own (x, y).dataStrips+groups, recovers fork semantics, and can produce the X-ray UX.groups[].mapNameis the bridge: it names whichmapentry holds the (x, y) points for that group. Thepointsfield that earlier drafts of this issue put insideGrouplives in themapblock instead — single source of truth, no duplication.Note on WLED specifically
Stock WLED's own
ledmap.jsonis a different format — a flat 1D pixel-reorder array, optionally withwidth/heightfor 2D matrices (WLED docs). It is not the same schema as FastLED'sScreenMap. Compatibility-with-WLED means compatibility with FastLED-flavored builds (e.g. WLED MoonModules, custom FastLED firmware) that link theScreenMapparser — not withwled/WLED's stockledmap.json. If targeting stock WLED is also a goal, we would need a separate exporter that converts themapblock into the WLED pixel-reorder shape; flag if so.What this changes in the design questions
map.<name>entries (every physical LED appears once in the rendered overlay), but the index space (groups[].start..end) can be sparse without breaking the firmware view.dataStrips+groupstop-level keys alongsidemap. No schema rewrite, no migrator needed for forward direction. Old files load as-is and the editor synthesizes a defaultdataStrips+ one-group-per-map-entry on import.screenmap.json-> readmap, treat each entry as{ DataStrip(id=key, length=x.length), Group(start=0, end=x.length-1, mapName=key) }.Source for the WLED ledmap.json format note: WLED docs - Mapping, WLED MoonModules - Mapping.
zackees commentedon Jun 14, 2026
Proposed API: data strips + groups + forks + optional 3D
Following on from the schema-compat constraint above. This is a concrete API proposal — discussion welcome before any of it lands. Everything sits on top of the existing FastLED
ScreenMapshape; nothing removes or moves existing keys.Design principle: one source of truth for physical points
Physical (x, y[, z]) points live in exactly one place: the existing
map.<name>block. Groups don't duplicate points; they reference amapentry by name. Two reasons:mapandgroupsgetting out of sync.Layer 1 —
DataStrip(signal, no position)A DataStrip is exactly what FastLED's controller writes to. No (x, y). No physical reality. Just "this output emits
lengthcolored slots."Layer 2 —
ScreenmapGroup(UI region + index range, plus fork)Cardinality rules:
[start..end]range must be disjoint from every other primary's range on the samedataStripId.startandendmust equal its parent's exactly (initial constraint — partial-tap forks can come later if real installs need them, see Design: forks + groups + data-strips — separating signal from physical placement #88 question A).mapNamepoints to amap.<name>entry whosex.length === end - start + 1.Layer 3 — optional 3D via
zExisting
ScreenmapStrip(matches FastLED parser):The FastLED
ScreenMap::ParseJsonsource (screenmap.cpp.hpp) only readsx,y,diameterfrom each segment and silently ignores other keys. Addingzis therefore non-breaking — old firmware sees only the 2D projection.3D-aware tools (future shapeviewer 3D mode, possibly moviemaker with depth-aware sampling later) pick
zup when present; everything else treats it as if it isn't there.Putting it together — the schema on disk
{ "map": { "A": { "x": [...11 floats], "y": [...11 floats], "diameter": 0.5 }, "B": { "x": [...23 floats], "y": [...23 floats], "z": [...23 floats], "diameter": 0.5 }, "C": { "x": [...23 floats], "y": [...23 floats], "z": [...23 floats], "diameter": 0.5 }, "D": { "x": [...66 floats], "y": [...66 floats], "diameter": 0.5 } }, "dataStrips": [ { "id": "pin1", "length": 100 } ], "groups": [ { "id": "g_A", "name": "A", "dataStripId": "pin1", "start": 0, "end": 10, "mapName": "A" }, { "id": "g_B", "name": "B", "dataStripId": "pin1", "start": 11, "end": 33, "mapName": "B" }, { "id": "g_C", "name": "C", "dataStripId": "pin1", "start": 11, "end": 33, "mapName": "C", "parentGroupId": "g_B" }, { "id": "g_D", "name": "D", "dataStripId": "pin1", "start": 34, "end": 99, "mapName": "D" } ] }Walk-through:
sum(primary group lengths on pin1) === dataStrips[pin1].lengthANDevery fork twin's length === its parent's length.[11..33]on pin1. B has its own physical chain (23 points inmap.B), C has its own physical chain (23 points inmap.C). Both render the same color frame because they read the same indices off pin1.z), the rest are 2D. Firmware ignoresz. The editor projects to the canvas plane when rendering in 2D mode, lights it up in a future 3D view.Sampling semantics — moviemaker side
This is what makes forks actually work for realtime video → LED:
DataStrip, allocate one color buffer oflengthslots.i ∈ [start..end], sample the video atmap[mapName].x[i - start], y[i - start]. Write the color intodataStrip[dataStripId][i].map[mapName]positions using the color fromdataStrip[dataStripId][i].Net result: sampler does the work once per signal index, both physical chains light up, and the firmware bit-stream is identical to what the device actually receives.
If both B and C should sample from their own positions (e.g. you want C to mirror a different region of the video), that's not a fork — that's two independent groups on two independent data strips. The current "fork" semantics are strict: same signal, same color, two physical placements.
UI selection model
selectedGroupIdbecomes the unit of UI selection (wasselectedStripIdx).DataStrip(header, showspin1 · 100 LEDs · 3 groups + 1 fork) → primary groups (indented) → fork twins (further indented under their parent, with a 🔀 marker).Migration from existing
screenmap.jsonA file with just
map(nodataStrips, nogroups) loads like this:In other words: each old strip becomes one DataStrip + one Group, no forks. The editor presents the legacy file identically to before.
Validation invariants (would live in
strips-model.ts)groups.length >= dataStrips.length(each data strip has ≥1 group).dataStripId: primary groups'[start..end]ranges partition[0..length-1]exactly, OR cover a subset (ungrouped indices are allowed but warned in the editor).start/endexactly match parent.mapNameresolves to amapentry whosex.length === end - start + 1.x.length === y.length, and ifzis present,z.length === x.length.These would each get a unit test, joined by the parser regression test in #89.
What this changes in #88's open questions
parentGroupId. Reasons: easier validation, easier "highlight the whole fork as one" UX, sampler can skip twins by checkingparentGroupId != null.dataStrips,groups). No schema rewrite.collapsedandcoloroverrides live ingroups[]so they round-trip. Pure ephemeral state (currently-selected group, ruler position) stays in localStorage.synthesizeDefaults()above. One DataStrip + one Group per legacy map entry.Still open after this proposal:
Happy to convert this into a follow-up issue with a concrete TS PR plan once the shape is agreed.
zackees commentedon Jun 14, 2026
v2 schema — clean rewrite
Dropping the "additive on top of FastLED" constraint. Editor and on-disk format become v2; firmware consumption goes through an explicit exporter that emits the legacy FastLED
ScreenMapshape — separating "what the editor edits" from "what the device reads" is a cleaner split anyway.Two principles drive the rewrite:
parentGroupId. No invariants between sibling groups.x[]/y[]/z[]arrays. Spans of floats stay intact for efficient processing (typed arrays, SIMD-friendly walks, video-sampler readback in row-major).Schema
{ "version": 2, "title": "Optional human-readable name", "strips": [ { "id": "pin1", "length": 100, "groups": [ { "id": "A", "name": "Top panel quad 0", "start": 0, "count": 11, "placements": [ { "x": [ /* 11 floats */ ], "y": [ /* 11 floats */ ], "z": [ /* 11 floats — optional */ ], "diameter": 0.5 } ], "color": "#3b82f6", "collapsed": false } ] } ], "ui": { "selectedGroupId": "A", "viewport": { "panX": 0, "panY": 0, "zoom": 1.0 } } }Field rules:
version2titlestripsstrips[].idstrips[].lengthstrips[].groupsgroups[].idgroups[].namegroups[].startgroups[].countgroups[].placementslength >= 1for a normal group;length >= 2is a fork.placements[].xlength === groups[].count.placements[].ylength === groups[].count.placements[].zlength === count. Enables 3D installs.placements[].diametergroups[].colorgroups[].collapseduiForks, with no ceremony
A fork is just "this signal range physically appears in N spots":
{ "id": "B", "name": "Mirror panel", "start": 11, "count": 23, "placements": [ { "x": [ /* 23 floats — chain A */ ], "y": [...], "diameter": 0.5 }, { "x": [ /* 23 floats — chain B */ ], "y": [...], "diameter": 0.5 } ] }No
parentGroupId. No "twin." No special-case validation that two groups must mirror each other's ranges. The group says "I am 23 LEDs starting at index 11, and you can find me physically in these two places."Sampling (moviemaker / video → LED)
Per group, the sampler:
(x[i], y[i])(andz[i]if depth-aware), produces a length-countcolor stream.[start..start+count).Rendering walks every placement of every group and draws at
(x[i], y[i])with the color from the data strip buffer. No double-sampling work for forks.Validation invariants
Each becomes a unit test in
strips-model.test.ts:strips[].idunique.groups[].idunique within strip.groups[].start + count <= strips[].length.[start, start+count)ranges are disjoint. (Subset coverage is allowed — ungrouped indices are dark but warned in the editor.)x.length === y.length === count. Ifzpresent,z.length === count.TypeScript
Firmware exporter — keeps the device happy
Editor stays in v2 forever. When the user hits Export for device, we emit the legacy FastLED
ScreenMapshape — onemap.<key>entry per placement, names auto-generated to be stable (e.g.<groupName>for single-placement groups,<groupName>_p0,<groupName>_p1for forked ones):Two consequences:
zis silently dropped on export (firmware doesn't use it). The 2D projection is what the device sees, which is what was already true.map.<key>entry — the device renders both physically, exactly as today's multi-mapflow does. Whoever is reading the v1screenmap.jsondoesn't notice forks at all (they just see N entries).A round-tripper in the other direction (import a v1 file → v2) synthesizes one group per
mapentry, no forks, noz. One-shot, run once at load.Worked example (the
pin1 length=100, fork at[11..33]case){ "version": 2, "title": "Fork demo", "strips": [ { "id": "pin1", "length": 100, "groups": [ { "id": "A", "name": "A", "start": 0, "count": 11, "placements": [ { "x": [0,1,2,3,4,5,6,7,8,9,10], "y": [0,0,0,0,0,0,0,0,0,0,0], "diameter": 0.5 } ] }, { "id": "B", "name": "B", "start": 11, "count": 23, "placements": [ { "x": [11,12,13,/*...*/,33], "y": [0,0,0,/*...*/,0], "diameter": 0.5 }, { "x": [200,201,/*...*/,222], "y": [10,10,/*...*/,10], "diameter": 0.5 } ] }, { "id": "D", "name": "D", "start": 34, "count": 66, "placements": [ { "x": [/* 66 floats */], "y": [/* 66 floats */], "diameter": 0.5 } ] } ] } ] }Reads as: pin1 has 100 LED slots. Group A owns the first 11 (one physical chain). Group B owns the next 23 and renders them in two places (the fork). Group D owns the last 66.
What this leaves open
group_p0/group_p1is a reasonable default; expose an override?If this shape lands, the next concrete piece of work is a new
tests/unit/screenmap-v2-schema.test.ts(the v2 equivalent of #89) plus a v1→v2 importer with its own round-trip test.zackees commentedon Jun 14, 2026
v2-flat — two tables, depth 2
Same goals, lower nesting. Two top-level arrays —
stripsandsegments— and that's it. No nestedgroups[], no nestedplacements[], noparentGroupId. A segment carries everything: signal binding, physical points, optional UI grouping label.Schema
{ "version": 2, "title": "Optional name", "strips": [ { "id": "pin1", "length": 100 } ], "segments": [ { "id": "A", "strip": "pin1", "start": 0, "count": 11, "x": [ /* 11 floats */ ], "y": [ /* 11 floats */ ], "z": [ /* 11 floats — optional */ ], "diameter": 0.5, "group": "topRow" } ] }How the concepts collapse
strips[]— justid+length.segments[]— one row per chain. Each segment has its ownx[]/y[]/z[]?.(strip, start, count)triple. No parent/child, no twin field, no shared key beyond what the firmware already knows.segments[].group— a string label. Segments with the samegroupvalue are treated as one unit by the UI. Defaults to the segment'sidwhen absent (= each segment is its own group).That's it. No third entity, no joined keys, no "first ID wins" rule.
Worked example — pin1 length 100, fork at indices [11..33]
{ "version": 2, "title": "Fork demo", "strips": [ { "id": "pin1", "length": 100 } ], "segments": [ { "id": "A", "strip": "pin1", "start": 0, "count": 11, "x": [0,1,2,3,4,5,6,7,8,9,10], "y": [0,0,0,0,0,0,0,0,0,0,0], "diameter": 0.5, "group": "row0" }, { "id": "B0", "strip": "pin1", "start": 11, "count": 23, "x": [11,12, /*...*/ ,33], "y": [0, 0, /*...*/ , 0], "diameter": 0.5, "group": "mirror" }, { "id": "B1", "strip": "pin1", "start": 11, "count": 23, "x": [200,201, /*...*/ ,222], "y": [10, 10, /*...*/ ,10], "diameter": 0.5, "group": "mirror" }, { "id": "D", "strip": "pin1", "start": 34, "count": 66, "x": [ /* 66 floats */ ], "y": [ /* 66 floats */ ], "diameter": 0.5, "group": "row1" } ] }Reads as: pin1 has 100 LED slots.
Aowns slots 0-10, one chain.B0andB1both claim slots 11-33 → fork, same color stream, two physical chains.Downs 34-99. UI groups:row0,mirror(contains both fork halves),row1.TypeScript
Optional UI state — only if we want round-trip
Pure-ephemeral state (hover, drag offsets, currently-dragged handle) stays in localStorage. Anything you want preserved across opens lives in
ui.Sampling, in two lines
For each
(strip, start, count)tuple present insegments[], sample once at the first matching segment's(x[i], y[i])and write the resulting color stream into the strip's color buffer at[start..start+count). Then render every segment by reading colors out of the strip buffer at its index range and drawing at its own(x[i], y[i]). Forks render twice from one sample.Validation invariants
strips[].idunique.segments[].idunique.segments[i].stripresolves to astrips[]entry;start + count <= strip.length;x.length === y.length === count; ifzpresent,z.length === count.map.<key>per occurrence.Firmware exporter
Editor stays on v2; firmware reads through an exporter that flattens to FastLED's
ScreenMapshape:zis silently dropped on export — the firmware never knew about it.Compared to the previous v2 (nested)
stripsstrips,segmentsx[]strips[i].groups[j].placements[k].x)segments[i].x)placementsarray inside a group(strip, start, count)The price: validating a fork requires walking
segments[]looking for matching(strip, start, count)tuples (O(n) once, cached in a Map). The previous design made forks structurally explicit in exchange for that nesting.zackees commentedon Jun 14, 2026
Three alternatives to v2-flat
Recruited three schema designers with different lenses (columnar/Arrow, JSON Schema standards, relational 3NF) and asked each for one alternative to v2-flat. Same fork-at-
[11..33]worked example across all three so trade-offs read side by side. None of these is a final pick — they exist to surface what each design philosophy buys and costs.Alternative 1 — Columnar / typed-array (Apache Arrow-style)
Hoist all coordinates into three top-level parallel float buffers (
x,y,z) that materialize directly intoFloat32Arraywith one allocation per axis. Segments collapse to(offset, count)views — pure integer metadata — so forks are free (two segments pointing at the same span) and the per-frame sampler walks contiguous memory with zero pointer-chasing. Deliberately reject a single stride-3coordsbuffer: keeping axes separate preserves SoA layout, lets the sampler skipzentirely in 2D mode without gather instructions, and is friendlier to SIMD / GPU attribute uploads (oneBufferAttributeper axis).{ "version": 3, "layout": "columnar", "title": "Optional name", "strips": [ { "id": "pin1", "length": 100 } ], "buffers": { "x": [ /* 100 floats: 0..10 for A, 11..33 for B (shared by fork), 34..99 for D */ ], "y": [ /* 100 floats, same order */ ], "z": null }, "segments": [ { "id": "A", "strip": "pin1", "start": 0, "count": 11, "offset": 0, "diameter": 0.5, "group": "topRow" }, { "id": "B0", "strip": "pin1", "start": 11, "count": 23, "offset": 11, "diameter": 0.5, "group": "fork" }, { "id": "B1", "strip": "pin1", "start": 11, "count": 23, "offset": 11, "diameter": 0.5, "group": "fork" }, { "id": "D", "strip": "pin1", "start": 34, "count": 66, "offset": 34, "diameter": 0.5 } ] }Pros
new Float32Array(json.buffers.x)per axis at load — no per-segment boxing, no GC churn, cache-hot iteration on the hot path.BufferAttributeper axis and onto SIMD lanes;z=nullis a free 33% bandwidth win in 2D.Int32Arrayfor workerpostMessagewith transferables.Cons
offset + count <= buffers.x.length, axes equal length) the editor must validate on load and maintain on every edit; v2-flat self-validates per segment.B0and see its points.Sampler frame: For each segment, read
(offset, count, strip.ledBaseIndex + start), thenfor (let i = 0; i < count; i++)sample the video at(x[offset+i], y[offset+i] [, z[offset+i]])and write intoledColors[base + i]— one tight contiguous loop, no object dereferences inside the inner body.Alternative 2 — JSON Schema canonical (interop-first)
A self-describing document with a stable
$id, explicittype/vdiscriminator, and a discriminated union over segment kinds so a stock JSON Schema validator rejects malformed files before any tool touches them. Groups live in a normalized table referenced by id, and forks become a first-class"kind": "fork"variant that points at a physical segment instead of duplicating geometry implicitly.{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://ledmapper.com/schemas/screenmap-2.0.json", "type": "Screenmap", "v": "2.0", "title": "Optional name", "strips": { "pin1": { "length": 100 } }, "groups": { "topRow": { "name": "Top Row", "color": "#3b82f6", "collapsed": false } }, "segments": { "A": { "kind": "physical", "strip": "pin1", "start": 0, "count": 11, "geometry": { "x": [ /* 11 floats */ ], "y": [ /* 11 floats */ ] }, "diameter": 0.5, "group": "topRow" }, "B0": { "kind": "physical", "strip": "pin1", "start": 11, "count": 23, "geometry": { "x": [ /* 23 floats */ ], "y": [ /* 23 floats */ ], "z": [ /* 23 floats */ ] }, "diameter": 0.5 }, "B1": { "kind": "fork", "forkOf": "B0", "geometry": { "x": [ /* 23 floats */ ], "y": [ /* 23 floats */ ] }, "diameter": 0.4, "group": "topRow" }, "D": { "kind": "physical", "strip": "pin1", "start": 34, "count": 66, "geometry": { "x": [ /* 66 floats */ ], "y": [ /* 66 floats */ ] }, "diameter": 0.5 } } }Pros
strip/group/forkOfrefs, missingcount, and wrong-kind fields without custom code — interop with third-party tools is basically free.kind: "fork"+forkOf) instead of inferred from coincidence on(strip, start, count), so downstream tools never have to guess intent.groupsas a normalized table gives color/display/collapsed a real home; no more smearing UI metadata across every segment.$id+vmean future migrations (2.1, 3.0) are dispatchable on a single field, and files are self-identifying when found in the wild.Cons
strips/segments/groupslose array ordering — UI z-order or render order needs a separate explicitorderfield if it matters.physicalvsfork) everywhere a tool touches segments, even for tools that don't care about forks.countis still a semantic rule the validator can't express cleanly without$dataor custom keywords, so one runtime check survives.A downstream consumer validates by fetching the schema at
$id, running it through any standard JSON Schema validator (ajv, jsonschema, etc.), and only then walking the document.Alternative 3 — Normalized tables (3NF, forks as first-class)
A screenmap is a small relational database, not a document. Strips, signal routes, groups, and segments are distinct entities with distinct lifecycles — stop cramming them into one row and stop reconstructing forks by tuple-matching. Model them as four flat tables with explicit foreign keys; a fork is then literally "two segments pointing at the same
signal_route_id," not a heuristic.{ "version": 3, "title": "Optional name", "strips": [ { "id": "pin1", "length": 100 } ], "signal_routes": [ { "id": "r_A", "strip": "pin1", "start": 0, "count": 11 }, { "id": "r_B", "strip": "pin1", "start": 11, "count": 23 }, { "id": "r_D", "strip": "pin1", "start": 34, "count": 66 } ], "groups": [ { "id": "g_top", "name": "topRow", "color": "#3b82f6", "collapsed": false }, { "id": "g_fork", "name": "forkPair", "color": "#f59e0b", "collapsed": false } ], "segments": [ { "id": "A", "signal_route": "r_A", "group": "g_top", "diameter": 0.5, "x": [ /* 11 floats */ ], "y": [ /* 11 floats */ ], "z": null }, { "id": "B0", "signal_route": "r_B", "group": "g_fork", "diameter": 0.5, "x": [ /* 23 floats */ ], "y": [ /* 23 floats */ ], "z": null }, { "id": "B1", "signal_route": "r_B", "group": "g_fork", "diameter": 0.5, "x": [ /* 23 floats */ ], "y": [ /* 23 floats */ ], "z": null }, { "id": "D", "signal_route": "r_D", "group": null, "diameter": 0.5, "x": [ /* 66 floats */ ], "y": [ /* 66 floats */ ], "z": null } ] }Pros
B0andB1drifting out of sync onstart/count.Cons
segment -> signal_route -> strip) instead of reading one row.Rendering the fork: find both segment rows where
signal_route === "r_B", join tosignal_routesfor the LED index range[11, 34), join tostripsforpin1, and draw each segment's(x, y)array against the shared route.Quick side-by-side
strips+buffers+segments)strips,groups,segments)strips,signal_routes,groups,segments)x[]segments[i].x)buffers.x)segments[id].geometry.x)segments[i].x)(strip, start, count)offset"kind": "fork"+forkOfsignal_route_idgroupsmapgroupstableFloat32ArraywalkMy read: Alt 1 wins if per-frame sampling is the dominant cost we care about, Alt 2 wins if interop with third-party tools is the primary goal, Alt 3 wins if we expect forks and group metadata to become rich enough to justify the join indirection. v2-flat still wins if we want the smallest-possible model with the lowest learning curve.
zackees commentedon Jun 14, 2026
Generative / adversarial design loop
The principles being optimized (set by issue author):
Loop: generator proposes a variant taking the last critique into account; adversary scores each principle 1-10 (10 best) and gives a verdict. Ideal = average ≥ 8.5 AND every principle ≥ 7. Otherwise the next iteration begins. Ledger continues below.
Baseline being iterated on: v2-flat (two top-level arrays
strips+segments, each segment carries its ownx[]/y[]/z?[]).zackees commentedon Jun 14, 2026
Round 1
Generator — Iteration 1: single-array
segments, strip lengths inlineWhat changed from v2-flat. Collapsed the two top-level arrays into one:
segments. Strip declarations are folded in as a tinystripsmap (name → length); everything else lives as a flat list of segments where each segment owns its own contiguousx,y, optionalzcolumnar float arrays. Fork = two segments with identical(strip, at, n)but differentx/y. No nesting beyond the segment object itself.Schema (worked example).
{ "strips": { "pin1": 100 }, "segments": [ { "id": "A", "strip": "pin1", "at": 0, "n": 11, "x": [ /* 11 floats */ ], "y": [ /* 11 floats */ ] }, { "id": "B0", "strip": "pin1", "at": 11, "n": 23, "x": [ /* 23 floats — left copy */ ], "y": [ /* 23 floats — left copy */ ] }, { "id": "B1", "strip": "pin1", "at": 11, "n": 23, "x": [ /* 23 floats — right copy */ ], "y": [ /* 23 floats — right copy */ ] }, { "id": "D", "strip": "pin1", "at": 34, "n": 66, "x": [ /* 66 floats */ ], "y": [ /* 66 floats */ ] } ] }Simplest-case file (one strip, one chain, no fork).
{ "x": [0,1,2,3,4,5,6,7,8,9], "y": [0,0,0,0,0,0,0,0,0,0] }Loader rule: if root has bare
x/y, treat as single anonymous segment on a single anonymous strip starting at 0.Adversary critique — iteration 1
x/yvs. fullstrips+segments) plus a fork-by-convention rule means a reader must learn two formats and one implicit invariant.x/y/z?arrays that drop straight intoFloat32Array; only ding is a full chain is split across N segment arrays the consumer must concatenate.root.segments[0].x[5]— depth 3; the terse form is depth 1 but doesn't count as the real schema.(strip, at, n)convention rather than an explicit schema field.Average: 7.6 / 10. Lowest: principle 1 (Simple) at 6.
Specific weaknesses to fix.
{x, y}and full{strips, segments}are two schemas — pick one and make the simple case fall out by omitted fields.forkorbranch_offield), not duplicate-tuple convention.x/yto root when single-segment as the canonical (not alternate) form.idfrom the simplest case if not load-bearing.nis redundant withx.length— drop one.Verdict: Continue.
zackees commentedon Jun 14, 2026
Round 2
Generator — Iteration 2: Root coords, optional segments as overlay
What changed from iteration 1. One schema:
x/yalways live at root (addresses adversary's depth + parallel-form complaint);segments[]is an optional overlay that names index ranges (ndropped —x.lengthis truth); forks are explicit via aforklabel shared by sibling segments whose physical arrays differ.Schema (worked example).
{ "strips": { "pin1": 100 }, "x": [ /* 100 floats: A(11) | B0(23) | D(66) ... */ ], "y": [ /* 100 floats, same layout */ ], "segments": [ { "name": "A", "strip": "pin1", "at": 0 }, { "name": "B0", "strip": "pin1", "at": 11, "fork": "B" }, { "name": "B1", "strip": "pin1", "at": 11, "fork": "B", "x": [ /* 23 floats */ ], "y": [ /* 23 floats */ ] }, { "name": "D", "strip": "pin1", "at": 34 } ] }Rules: root
x/yhold canonical positions for every signal index[0, strip_length). A segment's range is[at, at + (next_at_on_strip or strip_length))— non. Segments may overridex/ylocally;fork: "B"declares siblings that share the same signal range at different physical locations.Simplest-case file.
{ "x": [0,1,2,3,4,5,6,7,8,9], "y": [0,0,0,0,0,0,0,0,0,0] }Depth to first float in canonical form.
root.x[5]— depth 2.Adversary critique — iteration 2
strips,segments,at,fork, and the implicit range-derivation rule add ~4 concepts.x[]/y[]are contiguous parallel float arrays that map directly toFloat32Arraywithx[i]access.root.x[5]— depth 2.x/yoverrides reintroduce a parallel coordinate form, and 3D still requires addingz[]at both root and per-segment.Average: 8.6 / 10. Lowest: principle 1 (Simple) at 7. (Technically over the ≥8.5/≥7 bar, but the adversary judged that substantive improvements remain.)
Specific weaknesses to fix.
[at, next_at)) — either make ranges explicit withn/end, or use a different shape so the reader doesn't have to scan siblings.x/yoverrides mean coordinates live in two places. Move fork-divergent coordinates into a single root-append region indexed by segmentat.strips+segments[].stripredundancy:strips: { pin1: 100 }duplicates information the segment list implies, and forces multi-strip files to declare both.Verdict: Continue.
zackees commentedon Jun 14, 2026
Round 3
Generator — Iteration 3: Single root coordinate buffer; segments are pure (signal, physical) range pairs
What changed from iteration 2.
counton every segment. No more sibling-scan to derive length.x/yis the only place floats live. Forks just append extra physical placements at the end; fork twins point viaoffset.stripstable gone. Strip length =max(at + count)per pin. In the segment-less common case, the strip is an implicit anonymous strip of lengthx.length.Schema (worked example). Strip
pin1length 100. Segment A = signal 0-10. Segments B0 and B1 fork: both bind signal 11-33, B0 placed at root indices 11-33, B1 placed at appended indices 100-122. Segment D = signal 34-99.{ "x": [ /* 123 floats: signal[0..99] then forkB1[100..122] */ ], "y": [ /* 123 floats */ ], "segments": [ { "name": "A", "pin": "pin1", "at": 0, "count": 11, "offset": 0 }, { "name": "B0", "pin": "pin1", "at": 11, "count": 23, "offset": 11 }, { "name": "B1", "pin": "pin1", "at": 11, "count": 23, "offset": 100 }, { "name": "D", "pin": "pin1", "at": 34, "count": 66, "offset": 34 } ] }Sugar:
offsetmay be omitted when it equalsat. Non-fork segments becomepin/at/count.Simplest-case file.
{ "x": [0, 1, 2, 3], "y": [0, 0, 0, 0] }Depth to first float in canonical form.
root.x[0]— depth 2.Adversary critique — iteration 3
root.x[i], maps 1:1 to a singleFloat32Arraypair.root.x[0]— depth 2.x/y; uncommon adds segments + appended-fork convention. Additive but introduces offset/at duality.Average: 8.8 / 10. All principles ≥ 7. (Formal threshold met, but adversary still has substantive critiques.)
Specific weaknesses to fix.
offset, or dropatentirely and letoffsetdouble as both).at=0,count=10thenat=20,count=5) silently defines a 25-length strip with undefined LEDs 10..19. Make explicit or forbid gaps.x/ymixes signal-order and physical-only points in the same buffer with no marker. Consumers iteratingx[i]for "signal index" walk off the end into fork data unless they consultsegmentsfirst.Verdict: Continue.
zackees commentedon Jun 14, 2026
Round 4
Generator — Iteration 4: Segment-order is physical-order; one buffer, one concept
What changed from iteration 3.
offsetfield. A segment's slice of rootx/ydetermined by position in array via running sum of prior counts.countfor segments on that pin.x/yis segment-indexed (concatenation of per-segment placements in declaration order).Schema (worked example).
{ "x": [ /* 123 floats: A(11) | B0(23) | B1(23) | D(66) */ ], "y": [ /* 123 floats */ ], "segments": [ { "pin": "pin1", "at": 0, "count": 11 }, { "pin": "pin1", "at": 11, "count": 23 }, { "pin": "pin1", "at": 11, "count": 23 }, { "pin": "pin1", "at": 34, "count": 66 } ] }Slices: seg[0] = x[0..11), seg[1] = x[11..34), seg[2] = x[34..57), seg[3] = x[57..123). Forks = two segments with same
(pin, at, count).Simplest-case file.
{ "x": [0, 1, 2, 3], "y": [0, 0, 0, 0], "segments": [{ "pin": "pin1", "at": 0, "count": 4 }] }Depth.
root.x[0]— depth 2.Adversary critique — iteration 4
segmentsarray is overhead for the single-strip case.Average: 8.0 / 10. Lowest: principles 1, 3, 5 tied at 7. (Regression from iter 3.)
Specific weaknesses to fix.
atfield is fully redundant with running-sum of priorcounts. Drop it.segmentsoptional: if omitted, default to single implicit segment covering all ofx[]. Restores iter-3 minimum.Verdict: Continue.
zackees commentedon Jun 14, 2026
Round 5 — Ideal reached
Generator — Iteration 5: Implicit single-chain with optional
chain+forkWhat changed from iteration 4.
at. Signal index is running sum of prior non-forkcounts on the samepin; physical index is running sum of every priorcount.chain. Ifchainis omitted, the file is a single implicit segment spanning all ofx[]. Simplest case back to 4 lines.chaincommunicates "array order = wiring order = physical order = signal order (unlessfork)."Schema (worked example).
{ "x": [/* 123 floats */], "y": [/* 123 floats */], "chain": [ { "pin": "pin1", "count": 11 }, // A: signal [0..11), physical [0..11) { "pin": "pin1", "count": 23 }, // B0: signal [11..34), physical [11..34) { "pin": "pin1", "count": 23, "fork": true }, // B1: signal [11..34), physical [34..57) (mirrors B0) { "pin": "pin1", "count": 66 } // D: signal [34..100), physical [57..123) ] }Pin1 signal length = 11 + 23 + 66 = 100. Physical buffer length = 11 + 23 + 23 + 66 = 123.
fork: truerequires the immediately-preceding segment on the samepinto have matchingcount.Simplest-case file (one strip, one chain, no fork).
{ "x": [0, 1, 2, 3], "y": [0, 0, 0, 0] }4 lines. Parser infers one segment of length
x.lengthon a default pin.Depth to first float in canonical form.
root.x[0]— depth 2.Adversary critique — iteration 5
chain) for the common case;forkis additive opt-in, though "implicit signal index = running sum of non-fork counts" is still an implicit rule.x[]/y[]store, maps directly toFloat32Array.chainblock required.root.x[0]— depth 2.chainentries and an optionalforkboolean without restructuring.Average: 9.2 / 10. Lowest: principle 1 at 8. All principles ≥ 7. Average ≥ 8.5.
Residual nits (not blocking ideal):
pinon every chain entry invites typos; not a blocker.Verdict: Ideal.
Final schema (the winner)
{ "x": [/* parallel float array */], "y": [/* parallel float array, same length as x */], "z": [/* optional, parallel, same length as x; 3D */], "chain": [ { "pin": "pin1", "count": 11 }, { "pin": "pin1", "count": 23 }, { "pin": "pin1", "count": 23, "fork": true }, { "pin": "pin1", "count": 66 } ] }Rules in one paragraph.
x/y(optionallyz) are parallel float arrays — the only place coordinates live. Ifchainis omitted, the file is a single implicit segment of lengthx.lengthon a default pin. Otherwise, each chain entry is one segment in physical wiring order: its physical slice isx[runningSum(priorCounts)..runningSum + count). Its signal range is[runningSum(priorNonForkCountsOnThisPin)..+count).fork: truere-uses the immediately-preceding segment-on-same-pin's signal range while occupying its own physical slice; counts must match.z, group labels, and per-segment metadata are additive.Why this won the loop.
{x, y}. No ceremony.Float32Array(json.x)works.chain), with one positional rule (array order = wiring order), and one explicit opt-out (fork).Ledger closed.
zackees commentedon Jun 14, 2026
Superseded by #92, which captures the final v2 schema and the parser/dispatch plan to implement. Closing.
feat(screenmap): add v2 parser + dispatcher with auto-detection (#93)