feat(plot2d): multi-image layers with per-layer cmap, clim, and alpha#29
Merged
Conversation
plot2d.add_layer(data, cmap=, alpha=, clim=, visible=) returns a Layer handle (set/set_data/remove); layers draw bottom-up above the base image with the base's exact fit-rect + zoom/pan transform, under axes, markers, and widgets, and composite in Canvas2D even over a WebGPU base. Per-layer LUT bitmaps are cached by (pixels, cmap, clim) so unchanged layers cost nothing on repaint; exportPNG captures layers for free. Heavy pixels ride dynamic geom keys (layer_<id>_b64): _GEOM_KEYS is now a property that unions the fixed base set with live layer keys, the Electron binary route ships each layer as its own PLOTBIN frame, and _spliceBinaryBytes scans by geom prefix instead of a hardcoded key list. resolve_pixel_tokens materialises layer base64 so save_html snapshots stay self-contained. Layers and tile mode exclude each other (enforced both directions). Layer data must match the base (H, W). 30 unit + 5 Playwright tests (incl. alpha-blend pixel assertions and the WebGPU-base + Canvas2D-layer readback case).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/export-png #29 +/- ##
===================================================
+ Coverage 88.97% 89.74% +0.76%
===================================================
Files 38 39 +1
Lines 3511 3696 +185
===================================================
+ Hits 3124 3317 +193
+ Misses 387 379 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #28 (retarget to main after it merges).
plot2d.add_layer(data, cmap=, alpha=, clim=, visible=)→Layerhandle withset/set_data/remove;plot2d.layersis z-ordered.exportPNGcaptures layers for free.layer_<id>_b64) —_GEOM_KEYSis now a property unioning the fixed set with live layer keys; the Electron binary route ships each layer as its own PLOTBIN frame;resolve_pixel_tokensmaterialises layer base64 sosave_htmlsnapshots stay self-contained.Motivation: SpyDE image overlays (live MDI layering + composed report figures), where each layer needs its own colormap/clim/alpha and frames swap per navigator move via
layer.set_data.Tests
30 unit + 5 Playwright (alpha-blend pixel assertions, visibility toggle, set_data swap, WebGPU-base + Canvas2D-layer readback, exportPNG-includes-layers). Regression across
test_plot2d/+test_layouts/+test_embed/: 502 passed, 6 pre-existing baseline skips.