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

spase_strips: Implement some FilterFunction variants with ColorMatrix#1624
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.

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