commit e6ec672107e35acea784f03839af5d0ff802d7bd
parent 073b662b9e967abb33b220de8040eb910482b337
Author: falkTX <falktx@falktx.com>
Date: Wed, 29 Mar 2023 15:43:01 +0200
Add Color::invert()
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/dgl/Color.hpp b/dgl/Color.hpp
@@ -95,6 +95,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
@@ -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;