DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 6d57f75c6a5cc01bf34ba9e72346320395e6b7ee
parent 63b104153575b0eeb62e5e7d1eb942c11cc93821
Author: falkTX <falktx@falktx.com>
Date:   Sat, 19 Jun 2021 19:26:00 +0100

Add convenience Color::withAlpha method

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdgl/Color.hpp | 5+++++
Mdgl/src/Color.cpp | 7+++++++
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dgl/Color.hpp b/dgl/Color.hpp @@ -66,6 +66,11 @@ struct Color { Color(const Color& color1, const Color& color2, float u) noexcept; /** + Create a new color based on this one but with a different alpha value. + */ + Color withAlpha(float alpha) noexcept; + + /** Create a color specified by hue, saturation and lightness. Values must in [0..1] range. */ diff --git a/dgl/src/Color.cpp b/dgl/src/Color.cpp @@ -114,6 +114,13 @@ Color::Color(const Color& color1, const Color& color2, const float u) noexcept interpolate(color2, u); } +Color Color::withAlpha(const float alpha) noexcept +{ + Color color(*this); + color.alpha = alpha; + return color; +} + Color Color::fromHSL(float hue, float saturation, float lightness, float alpha) { float m1, m2;