mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibWeb/CSS: Add support for the a98-rgb color space in color()
This makes us pass the following WPT tests: - css/css-color/a98rgb-001.html - css/css-color/a98rgb-002.html - css/css-color/a98rgb-003.html - css/css-color/a98rgb-004.html - css/css-color/predefined-007.html - css/css-color/predefined-008.html
This commit is contained in:
committed by
Andreas Kling
parent
c0ae3aa884
commit
a59d9a3986
@@ -413,6 +413,24 @@ Color Color::from_linear_srgb(float red, float green, float blue, float alpha)
|
||||
clamp(lroundf(alpha * 255.f), 0, 255));
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-color-4/#predefined-a98-rgb
|
||||
Color Color::from_a98rgb(float r, float g, float b, float alpha)
|
||||
{
|
||||
auto to_linear = [](float c) {
|
||||
return pow(c, 563. / 256);
|
||||
};
|
||||
|
||||
auto linear_r = to_linear(r);
|
||||
auto linear_g = to_linear(g);
|
||||
auto linear_b = to_linear(b);
|
||||
|
||||
float x = 0.57666904 * linear_r + 0.18555824 * linear_g + 0.18822865 * linear_b;
|
||||
float y = 0.29734498 * linear_r + 0.62736357 * linear_g + 0.07529146 * linear_b;
|
||||
float z = 0.02703136 * linear_r + 0.07068885 * linear_g + 0.99133754 * linear_b;
|
||||
|
||||
return from_xyz65(x, y, z, alpha);
|
||||
}
|
||||
|
||||
Color Color::from_xyz50(float x, float y, float z, float alpha)
|
||||
{
|
||||
// See commit description for these values
|
||||
|
||||
Reference in New Issue
Block a user