00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef COLOR_H_
00024 #define COLOR_H_
00025
00026 #include <iostream>
00027
00028 class Color{
00029 public:
00030 Color(float r, float g, float b, float a = 1.f);
00031
00032 inline float& red() {return m_red;}
00033 inline float& green() {return m_green;}
00034 inline float& blue() {return m_blue;}
00035 inline float& alpha() {return m_alpha;}
00036
00037 inline float red() const{return m_red;}
00038 inline float green() const{return m_green;}
00039 inline float blue() const{return m_blue;}
00040 inline float alpha() const{return m_alpha;}
00041 protected:
00042 float m_red, m_green, m_blue, m_alpha;
00043 };
00044
00045 class HSLColor{
00046 public:
00047 HSLColor(float h, float s, float l, float a = 1.f);
00048
00049 inline float& hue() {return m_hue;}
00050 inline float& saturation() {return m_saturation;}
00051 inline float& lightness() {return m_lightness;}
00052 inline float& alpha() {return m_alpha;}
00053
00054 inline float hue() const {return m_hue;}
00055 inline float saturation() const {return m_saturation;}
00056 inline float lightness() const {return m_lightness;}
00057 inline float alpha() const {return m_alpha;}
00058
00059 void fromColor(const Color& color);
00060 Color toColor() const;
00061
00062 protected:
00063 float m_hue, m_saturation, m_lightness, m_alpha;
00064 };
00065
00066 HSLColor RGB2HSL(const Color& color);
00067
00068 Color HSL2RGB(const HSLColor& color);
00069
00070 std::ostream& operator<< (std::ostream& out, const Color& color);
00071 std::ostream& operator<< (std::ostream& out, const HSLColor& color);
00072
00073 #endif