Skip to content

spase_strips: Implement some FilterFunction variants with ColorMatrix - #1624

Draft
waywardmonkeys wants to merge 4 commits into
linebender:mainfrom
waywardmonkeys:filter/colormatrix-functions
Draft

waywardmonkeys wants to merge 4 commits into
linebender:mainfrom
waywardmonkeys:filter/colormatrix-functions

Conversation

@waywardmonkeys

Copy link
Copy Markdown
Collaborator

This hooks up the color-adjustment FilterFunction variants by lowering them to ColorMatrix primitives.

Filter::from_function now supports:

  • Brightness
  • Contrast
  • Grayscale
  • HueRotate
  • Invert
  • Opacity
  • Saturate
  • Sepia

Blur continues to lower to GaussianBlur.

The matrix formulas follow the CSS/SVG Filter Effects shorthand definitions. The implementation keeps the matrix constructors private, so this uses the existing FilterFunction -> FilterPrimitive -> PreparedFilter::ColorMatrix path without adding new public API.

Notes

  • grayscale, saturate, and the reusable full grayscale matrix use the current sRGB luminance coefficients: 0.2126, 0.7152, 0.0722.
  • hueRotate keeps the older rounded coefficients from the spec’s hue-rotate matrix instead of substituting the newer luminance constants.
  • grayscale, invert, opacity, and sepia clamp their bounded amount values before lowering.
  • saturate, brightness, and contrast allow values above 1.0, matching the filter-function behavior.

@waywardmonkeys

Copy link
Copy Markdown
Collaborator Author

This was done with the assistance of Codex (GPT 5.5, xhigh).

@waywardmonkeys

Copy link
Copy Markdown
Collaborator Author

This is a draft because it is layered on top of the changes to add ColorMatrix in #1623.

@waywardmonkeys

Copy link
Copy Markdown
Collaborator Author

Once we add ComponentTransfer, then some of these can migrate to using that ... like brightness, contrast, opacity, and invert.

@grebmeg

grebmeg commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

I think this PR is quite obsolete now, and I’m curious what the blocker was for merging it. Should we close it for now and reimplement it on top of the latest main when needed?

@grebmeg
grebmeg removed their request for review September 24, 2026 23:16

This branch has not been deployed

No deployments
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.

2 participants