Skip to content

Filters read the toolbox, a map file and the active path - #70

Merged
IAmJSD merged 1 commit into
mainfrom
t3code/filter-context
Aug 29, 2026
Merged

IAmJSD merged 1 commit into
mainfrom
t3code/filter-context

Conversation

@IAmJSD

@IAmJSD IAmJSD commented Aug 29, 2026

Copy link
Copy Markdown
Member

The last three functional gaps, closed. Every "a filter here cannot see that" left in the README was a decision about the plugin API, not about the filters — so the API changed.

FilterContext is what a filter gets beyond its own pixels and numbers: the two toolbox colours, what the document composites to underneath, an image somebody picked, and the active path flattened into the filter's own coordinates. apply_with replaces apply_over, wants_map and wants_path join wants_backdrop, and a filter that asks for nothing still implements one method.

The toolbox colours

The whole Sketch group draws in them — ink is the foreground, paper the background — as do Clouds, Difference Clouds, Fibers, Tiles' gaps, Neon Glow's glow, Colored Pencil's paper and Diffuse Glow's glow.

With the swatches at their defaults that is black on white, exactly as before, which is why the group has looked right until now. Set them to sepia and Stamp comes out as a sepia print — which it could not do before at any setting.

A displacement map

Displace takes the file Photoshop asks for: red for horizontal, green for vertical, mid grey meaning stay, stretched to fit or tiled. The dialog grew a Choose button that decodes through the same codecs that open documents, so a map can be a PSD, a PNG, or anything else this build reads. With no map it still falls back to its own noise field, and says so.

The active path

Flame burns along it, each flame leaving the curve at right angles to it, and the licks are sampled in the flame's own frame rather than the picture's so they run up it whichever way it points. With no path they rise from the bottom of the selection as before.

A depth map

Lens Blur can take one from the layer's transparency or from what is underneath it, holding part of the picture at its original sharpness — Photoshop's Depth Map, minus the channel picker.

Two things fell out

  • The filter dialog gave a choice's name the same 56 pixels it gives a number, so "Repeat Edge Pixels" wrapped onto three lines. Choices now take the room from their own track, which they barely need.
  • Flame's last root sat exactly on the last point of the path, where there is no segment ahead of it — so its direction was (0, 0), its normal was nothing, across was zero everywhere, and it set the entire frame alight. Caught by rendering it; the fix takes the segment behind, and a zero-length segment now means straight up.

Checked

New tests: that the two-tone filters actually use the colours they are given (handed red and blue, nothing may come out green), and that Displace moves pixels where its map says and leaves them where it says stay. Full workspace suite green, clippy and rustfmt clean. Every changed filter eyeballed — sepia Stamp, cream-paper Colored Pencil, blue-and-cream Clouds, a warm Diffuse Glow, Displace through a real map, Flame along an arc. And the app driven headlessly to confirm the Displace dialog's Choose row and that the long choice names now fit.

The README's "here is what a filter cannot see" paragraph is gone. What remains is ergonomic, not functional: Photoshop puts blur pins, light gizmos and flame paths on the canvas; here they are position sliders and the path you already drew.

🤖 Generated with Claude Code

The last three functional gaps, closed. Every "a filter here cannot see
that" in the README was a decision about the plugin API rather than
about the filters, so the API changed.

`FilterContext` is what a filter is handed beyond its own pixels and
numbers: the foreground and background colours, what the document
composites to underneath, an image somebody picked, and the active path
flattened into the filter's own coordinates. `apply_with` replaces
`apply_over`, `wants_map` and `wants_path` join `wants_backdrop`, and a
filter that asks for nothing still implements one method.

**The toolbox colours.** The whole Sketch group draws in them -- ink is
the foreground, paper the background -- as do Clouds, Difference Clouds,
Fibers, Tiles' gaps, Neon Glow's glow, Colored Pencil's paper and
Diffuse Glow's glow. With the swatches at their defaults that is black
on white, exactly as before, which is why the group has looked right
until now; set them to sepia and Stamp comes out as a sepia print,
which it could not before at any setting.

**A displacement map.** Displace takes the file Photoshop asks for, red
for horizontal and green for vertical with mid grey meaning stay, and
stretched or tiled. The dialog grew a Choose button that decodes through
the same codecs that open documents, so a map can be a PSD, a PNG or
anything else this build reads. With no map it still falls back to its
own noise field.

**The active path.** Flame burns along it, each flame leaving the curve
at right angles to it, and the licks are sampled in the flame's own
frame so they run up it whichever way it points. With no path they rise
from the bottom of the selection as before.

**A depth map.** Lens Blur can take one from the layer's transparency or
from what is underneath, holding part of the picture at its original
sharpness -- Photoshop's Depth Map, minus the channel picker.

Two things fell out. The filter dialog gave a choice's name the same
56 pixels it gives a number, so "Repeat Edge Pixels" wrapped onto three
lines; choices now take room from their own track, which they barely
need. And Flame's last root sat exactly on the last point of the path,
where there is no segment ahead of it -- so its direction was (0, 0),
its normal was nothing, and it set the entire frame alight.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@IAmJSD
IAmJSD merged commit 134f89a into main Aug 29, 2026
3 checks passed
@IAmJSD
IAmJSD deleted the t3code/filter-context branch August 29, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant