diff --git a/Libraries/LibGfx/Color.h b/Libraries/LibGfx/Color.h index 2b1e84837f8..9f54880b7dc 100644 --- a/Libraries/LibGfx/Color.h +++ b/Libraries/LibGfx/Color.h @@ -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(round(alpha() * opacity))); } constexpr Color darkened(float amount = 0.5f) const diff --git a/Tests/LibGfx/TestColor.cpp b/Tests/LibGfx/TestColor.cpp index 39fcdc7fa24..448cdbbff24 100644 --- a/Tests/LibGfx/TestColor.cpp +++ b/Tests/LibGfx/TestColor.cpp @@ -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)); } diff --git a/Tests/LibWeb/Screenshot/images/svg-gradient-userSpaceOnUse-ref.png b/Tests/LibWeb/Screenshot/images/svg-gradient-userSpaceOnUse-ref.png index c849fa4fe56..7484fed28d4 100644 Binary files a/Tests/LibWeb/Screenshot/images/svg-gradient-userSpaceOnUse-ref.png and b/Tests/LibWeb/Screenshot/images/svg-gradient-userSpaceOnUse-ref.png differ diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini index f5fd6b25ef2..bdf39884351 100644 --- a/Tests/LibWeb/TestConfig.ini +++ b/Tests/LibWeb/TestConfig.ini @@ -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