mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibGfx: Reimplement from_hsla
- Hue now wraps properly when negative or larger than 360 - The hsl to rgb conversion now closely mirrors the code example from the spec. This fixes a number of WPT tests in /css/css-color/parsing/color-computed-hsl.html
This commit is contained in:
parent
bc846d933d
commit
201648485f
Notes:
github-actions[bot]
2024-11-22 11:11:26 +00:00
Author: https://github.com/glupi-borna 🔰
Commit: 201648485f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2495
Reviewed-by: https://github.com/LucasChollet ✅
Reviewed-by: https://github.com/gmta
2 changed files with 28 additions and 37 deletions
|
@ -28,3 +28,18 @@ TEST_CASE(hsv)
|
|||
EXPECT_EQ(Color(51, 179, 51, 128), Color::from_hsv(120, 0.714285714, .7).with_opacity(0.5));
|
||||
EXPECT_EQ(Color(87, 128, 77), Color::from_hsv(108, 0.4, .5));
|
||||
}
|
||||
|
||||
TEST_CASE(hsl)
|
||||
{
|
||||
EXPECT_EQ(Color(191, 191, 0), Color::from_hsl(-300, 1.0, 0.375));
|
||||
EXPECT_EQ(Color(159, 138, 96), Color::from_hsl(400, 0.25, 0.5));
|
||||
EXPECT_EQ(Color(159, 96, 128), Color::from_hsl(330, 0.25, 0.5));
|
||||
EXPECT_EQ(Color(128, 0, 128), Color::from_hsl(300, 1.0, 0.25));
|
||||
EXPECT_EQ(Color(0, 128, 128), Color::from_hsl(180, 1.0, 0.25));
|
||||
EXPECT_EQ(Color(128, 239, 16), Color::from_hsl(90, 0.875, 0.5));
|
||||
EXPECT_EQ(Color(128, 223, 32), Color::from_hsl(90, 0.75, 0.5));
|
||||
EXPECT_EQ(Color(128, 207, 48), Color::from_hsl(90, 0.625, 0.5));
|
||||
EXPECT_EQ(Color(128, 191, 64), Color::from_hsl(90, 0.5, 0.5));
|
||||
EXPECT_EQ(Color(128, 175, 80), Color::from_hsl(90, 0.375, 0.5));
|
||||
EXPECT_EQ(Color(128, 159, 96), Color::from_hsl(90, 0.25, 0.5));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue