Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rec2020 color space #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Rec2020 color space #42

wants to merge 1 commit into from

Conversation

tomcur
Copy link
Member

@tomcur tomcur commented Nov 14, 2024

Resolves #20, now implementing all CSS Color Module Level 4 color spaces.

Resolves linebender#20, now implementing all CSS Color Module Level 4 color
spaces.
Comment on lines +460 to +472
(2_785_571_537. / 1_677_558_947.) as f32,
(-985_802_650. / 1_677_558_947.) as f32,
(-122_209_940. / 1_677_558_947.) as f32,
],
[
(-4_638_020_506. / 37_238_079_773.) as f32,
(42_187_016_744. / 37_238_079_773.) as f32,
(-310_916_465. / 37_238_079_773.) as f32,
],
[
(-97_469_024. / 5_369_968_309.) as f32,
(-3_780_738_464. / 37_589_778_163.) as f32,
(42_052_799_795. / 37_589_778_163.) as f32,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more lily-gilding here. Debatable usefulness, as the transfer function parameters are reals not representable as rationals.

Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of picky micro-optimizations, otherwise looks good. Again, spot-checked the color pairs in the test against color.js.


fn transfer(x: f32) -> f32 {
if x.abs() < Rec2020::B * 4.5 {
x / 4.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be x * (1.0 / 4.5) for performance.

if x.abs() < Rec2020::B {
x * 4.5
} else {
(Rec2020::A * x.abs().powf(0.45) - Rec2020::A + 1.).copysign(x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you group it so it's (Rec2020::A - 1.) that's one fewer addition.

@waywardmonkeys waywardmonkeys added this to the Initial Release milestone Nov 15, 2024
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.

CSS 4: Predefined color spaces
3 participants