21 typedef unsigned char byte;
44 explicit RGB(T v) : Base(v) {}
59 explicit RGB(
const T t[3]): Base(t) {}
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()); }
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));
Array of fixed size.
Definition FArray.h:17
Vector of fixed size.
Definition FVector.h:17
FVector()
Definition FVector.h:25
const T & x() const
Read alias.
Definition FVector.h:104
RED GREEN BLUE Alpha color.
Definition Color.h:140
RGBA(T r, T g, T b)
Constructor with r,g,b values Constructs a RGBA of type T.
Definition Color.h:173
T & g()
Write GREEN alias.
Definition Color.h:240
const octet & r() const
Definition Color.h:219
const octet & b() const
Definition Color.h:247
T & a()
Write alpha alias.
Definition Color.h:268
T & r()
Write RED alias.
Definition Color.h:226
const octet & g() const
Definition Color.h:233
RGBA(const Base &x)
Copy constructor.
Definition Color.h:191
RGBA(T x)
Constructor with constant value.
Definition Color.h:156
RGBA(const T t[4])
Constructor from C array.
Definition Color.h:184
T & b()
Write BLUE alias.
Definition Color.h:254
RGBA(const FArray< T2, 4 > &x)
Constructor from other value type Constructs from RGBA with different type.
Definition Color.h:199
RGBA()
Empty constructor.
Definition Color.h:149
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 octet & a() const
Definition Color.h:261
RGBA(const FArray< T2, 3 > &x)
Constructor from RGB.
Definition Color.h:207
RED GREEN BLUE color.
Definition Color.h:28
const octet & g() const
Definition Color.h:104
T & b()
Write BLUE alias.
Definition Color.h:125
T & r()
Write RED alias.
Definition Color.h:97
RGB(T v)
Constructor with constant value.
Definition Color.h:44
RGB(const Base &x)
Copy constructor.
Definition Color.h:66
const octet & b() const
Definition Color.h:118
RGB(const T t[3])
Constructor from C array.
Definition Color.h:59
T & g()
Write GREEN alias.
Definition Color.h:111
RGB()
Empty constructor.
Definition Color.h:37
const octet & r() const
Definition Color.h:90
RGB(const FArray< T2, 4 > &x)
Constructor from RGBA.
Definition Color.h:83
RGB(const FVector< T2, 3 > &x)
Constructor from other value type Constructs from RGB with different type.
Definition Color.h:74
RGB(T r, T g, T b)
Constructor with r,g,b values Constructs a RGB of type T.
Definition Color.h:51
const Color ORANGE(255, 128, 0)
Predefined color.
const Color WHITE(255, 255, 255)
Predefined color.
const Color YELLOW(255, 255, 0)
Predefined color.
const AlphaColor ABLUE
Predefined color.
Definition Color.h:374
const AlphaColor AYELLOW
Predefined color.
Definition Color.h:392
const AlphaColor ARED
Predefined color.
Definition Color.h:380
RGB< octet > Color
RGB<octet> alias.
Definition Color.h:283
const AlphaColor ABLACK
Predefined color.
Definition Color.h:368
const Color BLACK(0, 0, 0)
Predefined color.
const Color MAGENTA(255, 0, 255)
Predefined color.
const Color RED(255, 0, 0)
Predefined color.
unsigned char octet
0 to 255 integer type.
Definition Color.h:18
const Color PURPLE(128, 0, 255)
Predefined color.
const Color CYAN(0, 255, 255)
Predefined color.
const AlphaColor AMAGENTA
Predefined color.
Definition Color.h:404
const AlphaColor ACYAN
Predefined color.
Definition Color.h:398
const AlphaColor AGREEN
Predefined color.
Definition Color.h:386
std::ostream & operator<<(std::ostream &out, const Color &c)
Display color as three integral values.
Definition Color.h:346
RGBA< octet > AlphaColor
RGBA<byte> alias.
Definition Color.h:356
RGB< T > YUV2RGB(const FVector< double, 3 > &yuv)
YUV to RGB.
Definition Color.h:424
FVector< double, 3 > RGB2YUV(const RGB< T > &rgb)
RGB to YUV.
Definition Color.h:413
const Color GREEN(0, 255, 0)
Predefined color.
const AlphaColor AWHITE
Predefined color.
Definition Color.h:362
unsigned char byte
Definition Color.h:21
const Color BLUE(0, 0, 255)
Predefined color.