14 typedef unsigned char byte;
88 const T&
r()
const {
return (*
this)[0]; }
95 T&
r() {
return (*
this)[0]; }
102 const T&
g()
const {
return (*
this)[1]; }
109 T&
g() {
return (*
this)[1]; }
116 const T&
b()
const {
return (*
this)[2]; }
123 T&
b() {
return (*
this)[2]; }
130 operator T ()
const {
return T(0.3*
r()+0.59*
g()+0.11*
b()); }
137 template <
typename T>
162 (*this)[0]=
r;(*this)[1]=
g;(*this)[2]=
b;(*this)[3]=
a;
172 (*this)[0]=
r;(*this)[1]=
g;(*this)[2]=
b;(*this)[3]=T(255);
217 const T&
r()
const {
return (*
this)[0]; }
224 T&
r() {
return (*
this)[0]; }
231 const T&
g()
const {
return (*
this)[1]; }
238 T&
g() {
return (*
this)[1]; }
245 const T&
b()
const {
return (*
this)[2]; }
252 T&
b() {
return (*
this)[2]; }
259 const T&
a()
const {
return (*
this)[3]; }
266 T&
a() {
return (*
this)[3]; }
273 operator T ()
const {
return T(0.3*
r()+0.59*
g()+0.11*
b()); }
345 return out << (int)c[0] <<
' ' << (
int)c[1] <<
' ' << (int)c[2];
412 double y=.299*double(rgb[0])+.587*double(rgb[1])+.114*double(rgb[2]);
423 double r(yuv[2]/.877+yuv[0]);
424 double b(yuv[1]/.492+yuv[0]);
425 double g((yuv[0]-.299*r-.114*b)/.587);
426 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
const T & x() const
Read alias.
Definition: FVector.h:104
RED GREEN BLUE Alpha color.
Definition: Color.h:138
RGBA(T r, T g, T b)
Constructor with r,g,b values Constructs a RGBA of type T.
Definition: Color.h:171
T & g()
Write GREEN alias.
Definition: Color.h:238
const T & r() const
Read RED alias.
Definition: Color.h:217
const T & b() const
Read BLUE alias.
Definition: Color.h:245
T & a()
Write alpha alias.
Definition: Color.h:266
T & r()
Write RED alias.
Definition: Color.h:224
const T & g() const
Read GREEN alias.
Definition: Color.h:231
RGBA(const Base &x)
Copy constructor.
Definition: Color.h:189
RGBA(T x)
Constructor with constant value.
Definition: Color.h:154
RGBA(const T t[4])
Constructor from C array.
Definition: Color.h:182
T & b()
Write BLUE alias.
Definition: Color.h:252
RGBA(const FArray< T2, 4 > &x)
Constructor from other value type Constructs from RGBA with different type.
Definition: Color.h:197
RGBA()
Empty constructor.
Definition: Color.h:147
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:161
const T & a() const
Read alpha alias.
Definition: Color.h:259
RGBA(const FArray< T2, 3 > &x)
Constructor from RGB.
Definition: Color.h:205
RED GREEN BLUE color.
Definition: Color.h:26
const T & g() const
Read GREEN alias.
Definition: Color.h:102
T & b()
Write BLUE alias.
Definition: Color.h:123
T & r()
Write RED alias.
Definition: Color.h:95
RGB(T v)
Constructor with constant value.
Definition: Color.h:42
RGB(const Base &x)
Copy constructor.
Definition: Color.h:64
const T & b() const
Read BLUE alias.
Definition: Color.h:116
RGB(const T t[3])
Constructor from C array.
Definition: Color.h:57
T & g()
Write GREEN alias.
Definition: Color.h:109
RGB()
Empty constructor.
Definition: Color.h:35
const T & r() const
Read RED alias.
Definition: Color.h:88
RGB(const FArray< T2, 4 > &x)
Constructor from RGBA.
Definition: Color.h:81
RGB(const FVector< T2, 3 > &x)
Constructor from other value type Constructs from RGB with different type.
Definition: Color.h:72
RGB(T r, T g, T b)
Constructor with r,g,b values Constructs a RGB of type T.
Definition: Color.h:49
const AlphaColor ABLUE
Predefined color.
Definition: Color.h:372
const Color PURPLE
Predefined color.
Definition: Color.h:341
const Color CYAN
Predefined color.
Definition: Color.h:323
const AlphaColor AYELLOW
Predefined color.
Definition: Color.h:390
const Color BLACK
Predefined color.
Definition: Color.h:293
const AlphaColor ARED
Predefined color.
Definition: Color.h:378
const Color YELLOW
Predefined color.
Definition: Color.h:317
const AlphaColor ABLACK
Predefined color.
Definition: Color.h:366
const Color WHITE
Predefined color.
Definition: Color.h:287
const AlphaColor AMAGENTA
Predefined color.
Definition: Color.h:402
const AlphaColor ACYAN
Predefined color.
Definition: Color.h:396
const AlphaColor AGREEN
Predefined color.
Definition: Color.h:384
std::ostream & operator<<(std::ostream &out, const Color &c)
Display color as three integral values.
Definition: Color.h:344
RGB< T > YUV2RGB(const FVector< double, 3 > &yuv)
YUV to RGB.
Definition: Color.h:422
RGBA< byte > AlphaColor
RGBA<byte> alias.
Definition: Color.h:354
FVector< double, 3 > RGB2YUV(const RGB< T > &rgb)
RGB to YUV.
Definition: Color.h:411
const Color ORANGE
Predefined color.
Definition: Color.h:335
const AlphaColor AWHITE
Predefined color.
Definition: Color.h:360
const Color BLUE
Predefined color.
Definition: Color.h:299
RGB< byte > Color
RGB<byte> alias.
Definition: Color.h:281
const Color MAGENTA
Predefined color.
Definition: Color.h:329
const Color RED
Predefined color.
Definition: Color.h:305
const Color GREEN
Predefined color.
Definition: Color.h:311