diff --git a/dgl/Color.hpp b/dgl/Color.hpp index 5ea28fed..f1b7bb37 100644 --- a/dgl/Color.hpp +++ b/dgl/Color.hpp @@ -94,6 +94,11 @@ struct Color { */ Color plus(float value) const noexcept; + /** + Create a new color based on this one but colors inverted. + */ + Color invert() const 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 index 4c8714ff..df779687 100644 --- a/dgl/src/Color.cpp +++ b/dgl/src/Color.cpp @@ -163,6 +163,15 @@ Color Color::plus(const float value) const noexcept return color; } +Color Color::invert() const noexcept +{ + Color color(*this); + color.red = 1.f - color.red; + color.green = 1.f - color.green; + color.blue = 1.f - color.blue; + return color; +} + Color Color::fromHSL(float hue, float saturation, float lightness, float alpha) { float m1, m2;