@@ -94,6 +94,11 @@ struct Color { | |||||
*/ | */ | ||||
Color plus(float value) const noexcept; | 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. | Create a color specified by hue, saturation and lightness. | ||||
Values must in [0..1] range. | Values must in [0..1] range. | ||||
@@ -163,6 +163,15 @@ Color Color::plus(const float value) const noexcept | |||||
return color; | 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) | Color Color::fromHSL(float hue, float saturation, float lightness, float alpha) | ||||
{ | { | ||||
float m1, m2; | float m1, m2; | ||||