neoGFX
C++ GPU-oriented GUI library and app/game creation framework.
hsl_colour.hpp
Go to the documentation of this file.
1 // hsl_colour.hpp
2 /*
3  neogfx C++ GUI Library
4  Copyright (c) 2015 Leigh Johnston. All Rights Reserved.
5 
6  This program is free software: you can redistribute it and / or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <neogfx/neogfx.hpp>
23 
24 namespace neogfx
25 {
26  class colour;
27 
28  class hsl_colour
29  {
30  public:
31  hsl_colour();
32  hsl_colour(double aHue, double aSaturation, double aLightness, double aAlpha = 1.0);
33  hsl_colour(const colour& aColour);
34  public:
35  double hue() const;
36  double saturation() const;
37  double lightness() const;
38  double alpha() const;
39  void set_hue(double aHue);
40  void set_saturation(double aSaturation);
41  void set_lightness(double aLightness);
42  void set_alpha(double aAlpha);
43  bool hue_undefined() const;
44  public:
45  hsl_colour with_lightness(double aNewLightness) const;
46  hsl_colour lighter(double aDelta) const;
47  hsl_colour lighter(double aCoeffecient, double aDelta) const;
48  colour to_rgb() const;
49  static hsl_colour from_rgb(const colour& aColour);
50  public:
51  static double undefined_hue();
52  public:
53  bool operator==(const hsl_colour& aOther) const;
54  bool operator!=(const hsl_colour& aOther) const;
55  bool operator<(const hsl_colour& aOther) const;
56  private:
57  double iHue;
58  double iSaturation;
59  double iLightness;
60  double iAlpha;
61  };
62 }
hsl_colour with_lightness(double aNewLightness) const
bool operator<(const hsl_colour &aOther) const
double alpha() const
void set_alpha(double aAlpha)
hsl_colour lighter(double aDelta) const
static double undefined_hue()
bool operator!=(const hsl_colour &aOther) const
double hue() const
double saturation() const
bool hue_undefined() const
colour to_rgb() const
bool operator==(const hsl_colour &aOther) const
void set_saturation(double aSaturation)
void set_lightness(double aLightness)
static hsl_colour from_rgb(const colour &aColour)
void set_hue(double aHue)
double lightness() const