Repository navigation
chromashift: model RGB colour spaces as first class values - #1553
Merged
keithamus merged 1 commit intoOct 7, 2026
Merged
Conversation
keithamus
enabled auto-merge (squash)
October 6, 2026 17:36
Currently we have seven near-identical RGB and XYZ modules, each with their own inline matrix arithmetic and the sRGB curve was duplicated in four modules. This also allowed drift. This change completely reworks these into: - A `Chromaticity` type which models white points. - A generic `Matrix3` type which allows for the various 3x3 transforms. - A `Transfer` type which encodes/decodes between linear light and a space's encoding. - An `RgbSpace` type which wraps all of these, defining a white point, transfer function, and two Matrices which determine how the type moves between encoded and CIE XYZ forms. This comes with some behavioural changes: - a98-rgb convers primaries, so rebeccapurple is now (0.358 0.212 0.584). - Gammut mapping is now per-destination not just sRGB. - Float-to-float conversions (e.g. oklab->lab) now no longer go through sRGB, which clamped them. In doing so, this gets us closer to conceptual parts of the spec, such as the reduction of colours to XYZ, but also exposes these parts for various ways to re-apply colours (such as ICC profiles). In addition, it also allows us to feature gate new `rec2020`/`rec2020-bt1886` flags which flip between BT.2020 OETF (current engines) and BT.1886 2.4 Gamma defined in w3c/csswg-drafts#12574.
keithamus
force-pushed
the
chromashift-model-rgb-colour-spaces-as-first-class-values
branch
from
October 7, 2026 09:32
be7767c to
b35436a
Compare
✅ CI passed
|
keithamus
deleted the
chromashift-model-rgb-colour-spaces-as-first-class-values
branch
October 7, 2026 12:03
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 7, 2026
## [0.0.35] - 2026-10-07 ### Other Changes - Chore(deps): update dependencies to v1.49.0 (#1546) ([#1546](#1546)) ### Chromashift - chromashift: model RGB colour spaces as first class values (#1553) ([#1553](#1553)) ### Css_ast - Regenerate css_ast/src/values from csswg drafts (#1545) ([#1545](#1545)) ### Csskit_vscode - chore(deps): update dependency @types/vscode to v1.140.0 (#1548) ([#1548](#1548)) [forcebuild]
Merged
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 7, 2026
## [0.0.35] - 2026-10-07 ### Other Changes - Chore(deps): update dependencies to v1.49.0 (#1546) ([#1546](#1546)) ### Chromashift - chromashift: model RGB colour spaces as first class values (#1553) ([#1553](#1553)) ### Css_ast - Regenerate css_ast/src/values from csswg drafts (#1545) ([#1545](#1545)) ### Csskit_vscode - chore(deps): update dependency @types/vscode to v1.140.0 (#1548) ([#1548](#1548))
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 7, 2026
## [0.0.35] - 2026-10-07 ### Other Changes - Chore(deps): update dependencies to v1.49.0 (#1546) ([#1546](#1546)) ### Chromashift - chromashift: model RGB colour spaces as first class values (#1553) ([#1553](#1553)) ### Css_ast - Regenerate css_ast/src/values from csswg drafts (#1545) ([#1545](#1545)) ### Csskit_vscode - chore(deps): update dependency @types/vscode to v1.140.0 (#1548) ([#1548](#1548)) [forcebuild]
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 7, 2026
## [0.0.35] - 2026-10-07 ### Other Changes - Chore(deps): update dependencies to v1.49.0 (#1546) ([#1546](#1546)) ### Chromashift - chromashift: model RGB colour spaces as first class values (#1553) ([#1553](#1553)) ### Css_ast - Regenerate css_ast/src/values from csswg drafts (#1545) ([#1545](#1545)) ### Csskit_vscode - chore(deps): update dependency @types/vscode to v1.140.0 (#1548) ([#1548](#1548))
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 7, 2026
## [0.0.35] - 2026-10-07 ### Other Changes - Chore(deps): update dependencies to v1.49.0 (#1546) ([#1546](#1546)) ### Chromashift - chromashift: model RGB colour spaces as first class values (#1553) ([#1553](#1553)) - chromashift: Align serialisation to CSS Spec (#1555) ([#1555](#1555)) ### Css_ast - Regenerate css_ast/src/values from csswg drafts (#1545) ([#1545](#1545)) ### Csskit_vscode - chore(deps): update dependency @types/vscode to v1.140.0 (#1548) ([#1548](#1548)) [forcebuild]
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 7, 2026
## [0.0.35] - 2026-10-07 ### Other Changes - Chore(deps): update dependencies to v1.49.0 (#1546) ([#1546](#1546)) ### Chromashift - chromashift: model RGB colour spaces as first class values (#1553) ([#1553](#1553)) - chromashift: Align serialisation to CSS Spec (#1555) ([#1555](#1555)) ### Css_ast - Regenerate css_ast/src/values from csswg drafts (#1545) ([#1545](#1545)) ### Csskit_vscode - chore(deps): update dependency @types/vscode to v1.140.0 (#1548) ([#1548](#1548))
keithamus
added a commit
that referenced
this pull request
Oct 11, 2026
## [0.0.35] - 2026-10-07 ### Other Changes - Chore(deps): update dependencies to v1.49.0 (#1546) ([#1546](#1546)) ### Chromashift - chromashift: model RGB colour spaces as first class values (#1553) ([#1553](#1553)) - chromashift: Align serialisation to CSS Spec (#1555) ([#1555](#1555)) ### Css_ast - Regenerate css_ast/src/values from csswg drafts (#1545) ([#1545](#1545)) ### Csskit_vscode - chore(deps): update dependency @types/vscode to v1.140.0 (#1548) ([#1548](#1548))
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.
Currently we have seven near-identical RGB and XYZ modules, each with their own
inline matrix arithmetic and the sRGB curve was duplicated in four modules. This
also allowed drift.
This change completely reworks these into:
Chromaticitytype which models white points.Matrix3type which allows for the various 3x3 transforms.Transfertype which encodes/decodes between linear light and aspace's encoding.
RgbSpacetype which wraps all of these, defining a white point, transferfunction, and two Matrices which determine how the type moves between
encoded and CIE XYZ forms.
This comes with some behavioural changes:
0.584).
sRGB, which clamped them.
In doing so, this gets us closer to conceptual parts of the spec, such as the
reduction of colours to XYZ, but also exposes these parts for various ways to
re-apply colours (such as ICC profiles). In addition, it also allows us to
feature gate new
rec2020/rec2020-bt1886flags which flip between BT.2020OETF (current engines) and BT.1886 2.4 Gamma defined in
w3c/csswg-drafts#12574.