mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +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:
parent
c0ae3aa884
commit
a59d9a3986
Notes:
github-actions[bot]
2024-11-16 09:31:06 +00:00
Author: https://github.com/LucasChollet
Commit: a59d9a3986
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2374
13 changed files with 146 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue