Support filtering toCompositeImage() to a subset of layers - #37
Merged
Conversation
Adds an optional visibleSurfaces parameter, closing #35: the Obsidian plugin's .spd viewer wants a per-layer visibility toggle (philips/supernote-obsidian-plugin#138), which needs compositing only a chosen subset of surfaces instead of always every surface in the file. undefined (the default) keeps existing behavior. When given, surfaces not in the set are dropped from _compositeOrder()'s result before compositing, so the bottom-to-top layers-based ordering is unchanged -- only which surfaces participate changes. Surface names not present in the file are silently ignored, same as toImage() already does for an unknown surface name.
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
Fixes #35.
toCompositeImage()previously always flattened every surface in the file. The Obsidian plugin's.spdviewer wants a per-layer visibility toggle (philips/supernote-obsidian-plugin#138), which needs compositing only a chosen subset of surfaces on each re-render instead of always all of them.undefined(the default) keeps existing behavior — every surface, via_compositeOrder()._compositeOrder()'s result is filtered down to just the requested surface names before compositing, so the bottom-to-toplayers-based stacking order is unchanged — only which surfaces participate changes.toImage()'s existing behavior for an unknown surface name.null, same as the no-tiles case already did.Test plan
npm run build(tsc) succeedsnpm run lintpassesnpm test— full suite passes (39/39)tests/input/real-device.spd(per the issue's request):['surface_1', 'surface_2'](hiding thesurface_9999"Reference Layer" background) produces an image still sized/aligned to the full file, but transparent where only the background would have shown, while the full composite is opaque there.null.