LibGfx: Round values in Color::with_opacity()

`svg-gradient-userSpaceOnUse` is now rendered to something closer to
what firefox does, so it is at least some progress.
This commit is contained in:
Lucas CHOLLET 2024-11-17 14:19:49 -05:00 committed by Sam Atkins
parent b4ba65c6e5
commit 248e4bb517
Notes: github-actions[bot] 2024-11-21 12:00:54 +00:00
4 changed files with 3 additions and 2 deletions

View file

@ -400,7 +400,8 @@ public:
constexpr Color with_opacity(float opacity) const
{
return with_alpha(alpha() * opacity);
VERIFY(opacity >= 0 && opacity <= 1);
return with_alpha(static_cast<u8>(round(alpha() * opacity)));
}
constexpr Color darkened(float amount = 0.5f) const

View file

@ -25,5 +25,6 @@ TEST_CASE(all_green)
TEST_CASE(hsv)
{
EXPECT_EQ(Color(51, 179, 51), Color::from_hsv(120, 0.714285714, .7));
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));
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -165,5 +165,4 @@ Text/input/test-http-test-server.html
; Multiple bugs are affecting these tests. To avoid having to rebase them every
; single time, let's deactivate them for a bit.
Ref/input/color-hwb.html
Screenshot/input/css-color-functions.html