23 #include <tulip/Vector.h>
28 class TLP_SCOPE Color :
public tlp::Vector<unsigned char, 4> {
31 inline Color(
const tlp::Vector<unsigned char, 4> &);
33 inline Color(
const unsigned char red = 0,
const unsigned char green = 0,
34 const unsigned char blue = 0,
const unsigned char alpha = 255);
36 inline void set(
const unsigned char red = 0,
const unsigned char green = 0,
37 const unsigned char blue = 0,
const unsigned char alpha = 255);
39 inline float getRGL()
const;
41 inline float getGGL()
const;
43 inline float getBGL()
const;
45 inline float getAGL()
const;
47 inline float *getGL()
const;
49 inline unsigned char getR()
const;
51 inline unsigned char getG()
const;
53 inline unsigned char getB()
const;
55 inline unsigned char getA()
const;
57 inline void setR(
const unsigned char red);
59 inline void setG(
const unsigned char green);
61 inline void setB(
const unsigned char blue);
63 inline void setA(
const unsigned char alpha);
79 static const Color Amaranth;
80 static const Color Amber;
81 static const Color Apricot;
82 static const Color Aquamarine;
83 static const Color Azure;
84 static const Color BabyBlue;
85 static const Color Beige;
86 static const Color Black;
87 static const Color Blue;
88 static const Color BlueGreen;
89 static const Color BlueViolet;
90 static const Color Blush;
91 static const Color Bronze;
92 static const Color Brown;
93 static const Color Burgundy;
94 static const Color Byzantium;
95 static const Color Carmine;
96 static const Color Cerise;
97 static const Color Cerulean;
98 static const Color Champagne;
99 static const Color ChartreuseGreen;
100 static const Color Chocolate;
101 static const Color Coffee;
102 static const Color Copper;
103 static const Color Coral;
104 static const Color Crimson;
105 static const Color Cyan;
106 static const Color DesertSand;
107 static const Color ElectricBlue;
108 static const Color Erin;
109 static const Color Gold;
110 static const Color Gray;
111 static const Color Green;
112 static const Color Harlequin;
113 static const Color Indigo;
114 static const Color Ivory;
115 static const Color Jade;
116 static const Color JungleGreen;
117 static const Color Lavender;
118 static const Color Lemon;
119 static const Color Lilac;
120 static const Color Lime;
121 static const Color Magenta;
122 static const Color MagentaRose;
123 static const Color Maroon;
124 static const Color Mauve;
125 static const Color NavyBlue;
126 static const Color Olive;
127 static const Color Orange;
128 static const Color OrangeRed;
129 static const Color Orchid;
130 static const Color Peach;
131 static const Color Pear;
132 static const Color Periwinkle;
133 static const Color PersianBlue;
134 static const Color Pink;
135 static const Color Plum;
136 static const Color PrussianBlue;
137 static const Color Puce;
138 static const Color Purple;
139 static const Color Raspberry;
140 static const Color Red;
141 static const Color RedViolet;
142 static const Color Rose;
143 static const Color Salmon;
144 static const Color Sapphire;
145 static const Color Scarlet;
146 static const Color Silver;
147 static const Color SlateGray;
148 static const Color SpringBud;
149 static const Color SpringGreen;
150 static const Color Tan;
151 static const Color Taupe;
152 static const Color Teal;
153 static const Color Turquoise;
154 static const Color Violet;
155 static const Color Viridian;
156 static const Color White;
157 static const Color Yellow;
160 TLP_SCOPE std::ostream &
operator<<(std::ostream &os,
const tlp::Color &);
161 TLP_SCOPE std::istream &
operator>>(std::istream &is, tlp::Color &);
164 tlp::Color::Color(
const tlp::Vector<unsigned char, 4> &v) :
tlp::Vector<unsigned char, 4>(v) {}
166 tlp::Color::Color(
const unsigned char red,
const unsigned char green,
const unsigned char blue,
167 const unsigned char alpha) {
168 set(red, green, blue, alpha);
171 void tlp::Color::set(
unsigned char red,
unsigned char green,
unsigned char blue,
172 unsigned char alpha) {
179 unsigned char tlp::Color::getR()
const {
182 unsigned char tlp::Color::getG()
const {
185 unsigned char tlp::Color::getB()
const {
188 unsigned char tlp::Color::getA()
const {
192 float tlp::Color::getRGL()
const {
193 return float((*
this)[0] / 255.0);
195 float tlp::Color::getGGL()
const {
196 return float((*
this)[1] / 255.0);
198 float tlp::Color::getBGL()
const {
199 return float((*
this)[2] / 255.0);
201 float tlp::Color::getAGL()
const {
202 return float((*
this)[3] / 255.0);
204 float *tlp::Color::getGL()
const {
205 float *result =
new float[4];
206 result[0] = getRGL();
207 result[1] = getGGL();
208 result[2] = getBGL();
209 result[3] = getAGL();
213 void tlp::Color::setR(
unsigned char red) {
216 void tlp::Color::setG(
unsigned char green) {
219 void tlp::Color::setB(
unsigned char blue) {
222 void tlp::Color::setA(
unsigned char alpha) {
228 struct hash<
tlp::Color> {
229 inline std::size_t operator()(
const tlp::Color &c)
const {
230 return hash_vector(c);
std::istream & operator>>(std::istream &is, Array< T, N > &array)
operator >> stream operator to easily read an array
std::ostream & operator<<(std::ostream &os, const Array< T, N > &array)
operator << stream operator to easily print an array, or save it to a file.