Skip to content

Add color transform primitives, take 2. - #227

Open
PoignardAzur wants to merge 6 commits into
linebender:mainfrom
PoignardAzur:color_primitives
Open

PoignardAzur wants to merge 6 commits into
linebender:mainfrom
PoignardAzur:color_primitives

Conversation

@PoignardAzur

Copy link
Copy Markdown

Add color-transformation primitives, specifically ColorMatrix and ComponentTransfer.
Add functions for creating these types (valid for sRGB only) matching the shorthands in Filter Effects Module Level 1 § 13.

Builds on top of @waywardmonkeys's #221.
Implements the solution proposed in #221 (comment).

waywardmonkeys and others added 6 commits May 7, 2026 13:11
Introduce the `color_operations` crate as a small `no_std` layer for per-pixel color transforms in caller-selected working color spaces.

Add `ComponentTransfer` and `TransferFunction` for per-channel identity, table, discrete, linear, and gamma operations. Add `ColorMatrix` for affine channel-mixing operations, including common constructors for opacity, brightness, contrast, invert, saturate, grayscale, hue rotation, sepia, and luminance-to-alpha.

Add `ColorOperation` for storing mixed matrix and component-transfer pipelines. Add typed apply support for `AlphaColor`, `PremulColor`, and `DynamicColor`, plus raw straight and premultiplied component helpers. `DynamicColor` operations preserve the runtime color-space tag and missing-component flags while discarding named-color state.

Operations intentionally do not clip, clamp, gamut-map, pack, quantize, or perform color-space conversion; those remain caller/rendering-boundary responsibilities.
@PoignardAzur
PoignardAzur requested a review from tomcur August 26, 2026 12:44
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