Browse Source

Add Color::invert()

Signed-off-by: falkTX <falktx@falktx.com>
pull/421/head
falkTX 2 years ago
parent
commit
e6ec672107
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 14 additions and 0 deletions
  1. +5
    -0
      dgl/Color.hpp
  2. +9
    -0
      dgl/src/Color.cpp

+ 5
- 0
dgl/Color.hpp View File

@@ -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.


+ 9
- 0
dgl/src/Color.cpp View File

@@ -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;


Loading…
Cancel
Save