LibGfx: Add Color::with_opacity(float opacity)

This returns the color with its alpha scaled by the opacity.
This commit is contained in:
MacDue 2023-05-18 19:02:00 +01:00 committed by Andreas Kling
parent f0560fd087
commit 120e5b6b6f
Notes: sideshowbarker 2024-07-17 03:27:40 +09:00

View file

@ -331,6 +331,11 @@ public:
alpha());
}
constexpr Color with_opacity(float opacity) const
{
return with_alpha(alpha() * opacity);
}
constexpr Color darkened(float amount = 0.5f) const
{
return Color(red() * amount, green() * amount, blue() * amount, alpha());