1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibGfx+LibWeb: Use floats not doubles to create HSL colors

There's really no reason to use doubles here, except at the time I
wanted to use doubles everywhere in CSS. I now realize that is
excessive, so everything can be floats instead.
This commit is contained in:
Sam Atkins 2022-03-21 17:13:52 +00:00 committed by Andreas Kling
parent 75ec960495
commit 404a7cb63a
2 changed files with 34 additions and 34 deletions

View file

@ -2530,9 +2530,9 @@ Optional<Color> Parser::parse_color(StyleComponentValueRule const& component_val
&& s_val.is(Token::Type::Percentage)
&& l_val.is(Token::Type::Percentage)) {
auto h = h_val.number_value();
auto s = s_val.percentage() / 100.0;
auto l = l_val.percentage() / 100.0;
auto h = static_cast<float>(h_val.number_value());
auto s = static_cast<float>(s_val.percentage() / 100.0f);
auto l = static_cast<float>(l_val.percentage() / 100.0f);
return Color::from_hsl(h, s, l);
}
} else if (function.name().equals_ignoring_case("hsla")) {
@ -2549,10 +2549,10 @@ Optional<Color> Parser::parse_color(StyleComponentValueRule const& component_val
&& l_val.is(Token::Type::Percentage)
&& a_val.is(Token::Type::Number)) {
auto h = h_val.number_value();
auto s = s_val.percentage() / 100.0;
auto l = l_val.percentage() / 100.0;
auto a = a_val.number_value();
auto h = static_cast<float>(h_val.number_value());
auto s = static_cast<float>(s_val.percentage() / 100.0f);
auto l = static_cast<float>(l_val.percentage() / 100.0f);
auto a = static_cast<float>(a_val.number_value());
return Color::from_hsla(h, s, l, a);
}
}