21 typedef unsigned char byte;
44 explicit RGB(T v) : Base(v) {}
59 explicit RGB(
const T t[3]): Base(t) {}
66 RGB(
const Base&
x) : Base(x) {}
90 const T&
r()
const {
return (*
this)[0]; }
97 T&
r() {
return (*
this)[0]; }
104 const T&
g()
const {
return (*
this)[1]; }
111 T&
g() {
return (*
this)[1]; }
118 const T&
b()
const {
return (*
this)[2]; }
125 T&
b() {
return (*
this)[2]; }
132 operator T ()
const {
return T(0.3*
r()+0.59*
g()+0.11*
b()); }
139 template <
typename T>
156 explicit RGBA(T
x) : Base(x) { (*this)[3]=T(1); }
164 (*this)[0]=
r;(*this)[1]=
g;(*this)[2]=
b;(*this)[3]=
a;
174 (*this)[0]=
r;(*this)[1]=
g;(*this)[2]=
b;(*this)[3]=T(255);
219 const T&
r()
const {
return (*
this)[0]; }
226 T&
r() {
return (*
this)[0]; }
233 const T&
g()
const {
return (*
this)[1]; }
240 T&
g() {
return (*
this)[1]; }
247 const T&
b()
const {
return (*
this)[2]; }
254 T&
b() {
return (*
this)[2]; }
261 const T&
a()
const {
return (*
this)[3]; }
268 T&
a() {
return (*
this)[3]; }
275 operator T ()
const {
return T(0.3*
r()+0.59*
g()+0.11*
b()); }
289 const Color
WHITE(255,255,255);
295 const Color
BLACK(0,0,0);
301 const Color
BLUE(0,0,255);
307 const Color
RED(255,0,0);
313 const Color
GREEN(0,255,0);
319 const Color
YELLOW(255,255,0);
325 const Color
CYAN(0,255,255);
331 const Color
MAGENTA(255,0,255);
337 const Color
ORANGE(255,128,0);
343 const Color
PURPLE(128,0,255);
346 inline std::ostream&
operator<<(std::ostream& out,
const Color& c) {
347 return out << (int)c[0] <<
' ' << (
int)c[1] <<
' ' << (int)c[2];
414 double y=.299*double(rgb[0])+.587*double(rgb[1])+.114*double(rgb[2]);
425 double r(yuv[2]/.877+yuv[0]);
426 double b(yuv[1]/.492+yuv[0]);
427 double g((yuv[0]-.299*r-.114*b)/.587);
428 return RGB<T>(T(r),T(g),T(b));
RGB(const T t[3])
Constructor from C array.
Definition: Color.h:59
Vector of fixed size.
Definition: FVector.h:17
RGBA(T r, T g, T b)
Constructor with r,g,b values Constructs a RGBA of type T.
Definition: Color.h:173
const Color BLUE(0, 0, 255)
Predefined color.
RGBA< octet > AlphaColor
RGBA alias.
Definition: Color.h:356
RGBA(const FArray< T2, 3 > &x)
Constructor from RGB.
Definition: Color.h:207
const T & b() const
Read BLUE alias.
Definition: Color.h:118
const T & b() const
Read BLUE alias.
Definition: Color.h:247
RGB< octet > Color
RGB alias.
Definition: Color.h:283
RGB(const FArray< T2, 4 > &x)
Constructor from RGBA.
Definition: Color.h:83
const Color MAGENTA(255, 0, 255)
Predefined color.
const AlphaColor AYELLOW
Predefined color.
Definition: Color.h:392
const T & g() const
Read GREEN alias.
Definition: Color.h:104
const T & r() const
Read RED alias.
Definition: Color.h:219
RGB(T r, T g, T b)
Constructor with r,g,b values Constructs a RGB of type T.
Definition: Color.h:51
RGBA(T r, T g, T b, T a)
Constructor with r,g,b,a values Constructs a RGBA of type T.
Definition: Color.h:163
const T & r() const
Read RED alias.
Definition: Color.h:90
const AlphaColor AWHITE
Predefined color.
Definition: Color.h:362
RGB< T > YUV2RGB(const FVector< double, 3 > &yuv)
YUV to RGB.
Definition: Color.h:424
RGBA(const T t[4])
Constructor from C array.
Definition: Color.h:184
T & b()
Write BLUE alias.
Definition: Color.h:254
RED GREEN BLUE Alpha color.
Definition: Color.h:140
RGB(const FVector< T2, 3 > &x)
Constructor from other value type Constructs from RGB with different type.
Definition: Color.h:74
T & r()
Write RED alias.
Definition: Color.h:97
T & g()
Write GREEN alias.
Definition: Color.h:111
const AlphaColor ABLUE
Predefined color.
Definition: Color.h:374
RGBA(T x)
Constructor with constant value.
Definition: Color.h:156
RGBA(const FArray< T2, 4 > &x)
Constructor from other value type Constructs from RGBA with different type.
Definition: Color.h:199
Array of fixed size.
Definition: FArray.h:17
const Color GREEN(0, 255, 0)
Predefined color.
const AlphaColor ABLACK
Predefined color.
Definition: Color.h:368
const Color YELLOW(255, 255, 0)
Predefined color.
const AlphaColor ARED
Predefined color.
Definition: Color.h:380
T & a()
Write alpha alias.
Definition: Color.h:268
T & b()
Write BLUE alias.
Definition: Color.h:125
unsigned char octet
0 to 255 integer type.
Definition: Color.h:18
RGBA()
Empty constructor.
Definition: Color.h:149
const AlphaColor ACYAN
Predefined color.
Definition: Color.h:398
T & r()
Write RED alias.
Definition: Color.h:226
RGB()
Empty constructor.
Definition: Color.h:37
const Color CYAN(0, 255, 255)
Predefined color.
RGBA(const Base &x)
Copy constructor.
Definition: Color.h:191
const T & g() const
Read GREEN alias.
Definition: Color.h:233
const Color RED(255, 0, 0)
Predefined color.
const Color WHITE(255, 255, 255)
Predefined color.
const AlphaColor AGREEN
Predefined color.
Definition: Color.h:386
const AlphaColor AMAGENTA
Predefined color.
Definition: Color.h:404
unsigned char byte
Definition: Color.h:21
RGB(const Base &x)
Copy constructor.
Definition: Color.h:66
std::ostream & operator<<(std::ostream &out, const Color &c)
Display color as three integral values.
Definition: Color.h:346
const T & x() const
Read alias.
Definition: FVector.h:104
const Color PURPLE(128, 0, 255)
Predefined color.
Imagine++ namespace.
Definition: Array.h:7
T & g()
Write GREEN alias.
Definition: Color.h:240
RED GREEN BLUE color.
Definition: Color.h:28
const T & a() const
Read alpha alias.
Definition: Color.h:261
const Color BLACK(0, 0, 0)
Predefined color.
const Color ORANGE(255, 128, 0)
Predefined color.
FVector< double, 3 > RGB2YUV(const RGB< T > &rgb)
RGB to YUV.
Definition: Color.h:413
RGB(T v)
Constructor with constant value.
Definition: Color.h:44