48 :
r( aR ),
g( aG ),
b( aB )
51 :
r( src.
r ),
g( src.
g ),
b( src.
b )
53 ColorT(
const char *svgColorName );
58 template<
typename FromT>
63 void set( T ar, T ag, T ab )
65 r = ar;
g = ag;
b = ab;
70 r = rhs.
r;
g = rhs.
g;
b = rhs.
b;
96 assert( n >= 0 && n <= 2 );
102 assert( n >= 0 && n <= 2 );
127 return (
r == rhs.
r ) && (
g == rhs.
g ) && (
b == rhs.
b );
132 return ! ( *
this == rhs );
137 return r*rhs.
r +
g*rhs.
g +
b*rhs.
b;
147 return (
r - rhs.
r) * (
r - rhs.
r) + (
g - rhs.
g) * (
g - rhs.
g) + (
b - rhs.
b) * (
b - rhs.
b);
165 r =
static_cast<T
>(
r /
s );
166 g =
static_cast<T
>(
g /
s );
167 b =
static_cast<T
>(
b /
s );
173 return ColorT<T>(
r + ( d.
r -
r ) * fact,
g + ( d.
g -
g ) * fact,
b + ( d.
b -
b ) * fact );
183 return ColorT<T>(
static_cast<T
>( 0 ), static_cast<T>( 0 ),
static_cast<T
>( 0 ) );
199 uint8_t red = ( hexValue >> 16 ) & 255;
200 uint8_t
green = ( hexValue >> 8 ) & 255;
201 uint8_t
blue = hexValue & 255;
205 operator T*(){
return (T*)
this; }
206 operator const T*()
const {
return (
const T*)
this; }
219 :
r( 0 ),
g( 0 ),
b( 0 ),
a( 0 )
222 :
r( aR ),
g( aG ),
b( aB ),
a( aA )
225 :
r( src.
r ),
g( src.
g ),
b( src.
b ),
a( src.
a )
228 :
r( col.
r ),
g( col.
g ),
b( col.
b ),
a( aA )
234 template<
typename FromT>
240 template<
typename FromT>
245 void set( T ar, T ag, T ab , T aa )
247 r = ar;
g = ag;
b = ab;
a = aa;
252 r = rhs.
r;
g = rhs.
g;
b = rhs.
b;
a = rhs.
a;
264 template<
class FromT>
276 assert( n >= 0 && n <= 3 );
282 assert( n >= 0 && n <= 3 );
307 return (
r == rhs.
r ) && (
g == rhs.
g ) && (
b == rhs.
b ) && (
a == rhs.
a );
312 return ! ( *
this == rhs );
325 r =
static_cast<T
>(
r /
s );
326 g =
static_cast<T
>(
g /
s );
327 b =
static_cast<T
>(
b /
s );
338 return r *
r +
g *
g +
b *
b;
343 return ColorAT<T>(
r + ( d.
r -
r ) * fact,
g + ( d.
g -
g ) * fact,
b + ( d.
b -
b ) * fact,
a + ( d.
a -
a ) * fact );
348 return ColorAT<T>(
static_cast<T
>( 0 ), static_cast<T>( 0 ),
static_cast<T
>( 0 ), static_cast<T>( 0 ) );
369 uint8_t red = ( hexValue >> 16 ) & 255;
370 uint8_t
green = ( hexValue >> 8 ) & 255;
371 uint8_t
blue = hexValue & 255;
378 uint8_t
alpha = ( hexValue >> 24 ) & 255;
379 uint8_t red = ( hexValue >> 16 ) & 255;
380 uint8_t
green = ( hexValue >> 8 ) & 255;
381 uint8_t
blue = hexValue & 255;
385 operator T*(){
return (T*)
this; }
386 operator const T*()
const {
return (
const T*)
this; }
398 extern ColorT<uint8_t>
svgNameToRgb(
const char *svgName,
bool *found = NULL );
400 extern std::ostream& operator<<( std::ostream &lhs, const ColorT<float> &rhs );
401 extern std::ostream& operator<<( std::ostream &lhs, const ColorAT<float> &rhs );
402 extern std::ostream& operator<<( std::ostream &lhs, const ColorT<uint8_t> &rhs );
403 extern std::ostream& operator<<( std::ostream &lhs, const ColorAT<uint8_t> &rhs );
static T sqrt(T x)
Definition: CinderMath.h:63
GLdouble GLdouble GLdouble r
Definition: GLee.h:1474
static ColorAT< T > white()
Definition: Color.h:356
Vec3f rgbToHSV(const ColorT< float > &c)
Definition: Color.cpp:354
const ColorT< T > & operator*=(T rhs)
Definition: Color.h:122
GLenum GLint GLint y
Definition: GLee.h:987
CHANTRAIT< T >::Accum lengthSquared() const
Definition: Color.h:336
T b
Definition: Color.h:216
ColorAT< T > operator-(const ColorAT< T > &rhs) const
Definition: Color.h:289
GLclampf green
Definition: GLee.h:951
ColorT(T aR, T aG, T aB)
Definition: Color.h:47
static ColorAT< T > zero()
Definition: Color.h:346
const ColorT< T > & operator-=(T rhs)
Definition: Color.h:121
CHANTRAIT< T >::Accum dot(const ColorT< T > &rhs) const
Definition: Color.h:135
ColorAT< float > ColorAf
Definition: Color.h:409
ColorAT()
Definition: Color.h:218
int int * max
Definition: GLee.h:17208
void normalize()
Definition: Color.h:321
ColorT< T > operator-(T rhs) const
Definition: Color.h:117
ColorAT(T aR, T aG, T aB, T aA=CHANTRAIT< T >::convert(1.0f))
Definition: Color.h:221
ColorT< float > Colorf
Definition: Color.h:406
const ColorAT< T > & operator-=(const ColorAT< T > &rhs)
Definition: Color.h:293
void set(const ColorT< T > &rhs)
Definition: Color.h:68
GLuint src
Definition: GLee.h:10873
ColorAT< T > operator=(const ColorAT< FromT > &rhs)
Definition: Color.h:265
T & operator[](int n)
Definition: Color.h:94
static ColorT< T > hex(uint32_t hexValue)
Returns a color from a hexadecimal-encoded RGB triple. For example, red is 0xFF0000.
Definition: Color.h:197
ColorT< T > operator*(const ColorT< T > &rhs) const
Definition: Color.h:110
const ColorAT< T > & operator-=(T rhs)
Definition: Color.h:301
ColorT< uint8_t > Color8u
Definition: Color.h:407
T b
Definition: Color.h:44
ColorAT< T > operator-(T rhs) const
Definition: Color.h:297
ColorAT< T > premultiplied() const
Definition: Color.h:331
static ColorT< T > max()
Definition: Color.h:176
const T & operator[](int n) const
Definition: Color.h:280
ColorAT< T > operator*(T rhs) const
Definition: Color.h:298
ColorT()
Definition: Color.h:46
ColorT< T > operator*(Y s, const ColorT< T > &c)
Definition: Color.h:391
CHANTRAIT< T >::Accum lengthSquared() const
Definition: Color.h:155
float length() const
Definition: Color.h:315
const ColorAT< T > & operator/=(T rhs)
Definition: Color.h:303
const ColorT< T > & operator+=(const ColorT< T > &rhs)
Definition: Color.h:112
T * ptr() const
Definition: Color.h:106
T g
Definition: Color.h:44
ColorT< T > operator+(T rhs) const
Definition: Color.h:116
ColorAT< T > operator/(T rhs) const
Definition: Color.h:299
Vec3< float > Vec3f
Definition: Vector.h:1317
static ColorAT< T > hexA(uint32_t hexValue)
Returns a ColorA from a hexadecimal-encoded ARGB ordering. For example, 50% transparent red is 0x80FF...
Definition: Color.h:376
ColorAT< float > ColorA
Definition: Color.h:408
GLclampf GLclampf blue
Definition: GLee.h:951
void set(T ar, T ag, T ab)
Definition: Color.h:63
ColorAT(const ColorAT< FromT > &src)
Definition: Color.h:241
const ColorAT< T > & operator+=(T rhs)
Definition: Color.h:300
T * ptr() const
Definition: Color.h:286
ColorAT(const ColorAT< T > &src)
Definition: Color.h:224
GLboolean GLboolean g
Definition: GLee.h:2964
GLclampf GLclampf GLclampf alpha
Definition: GLee.h:951
Definition: ChanTraits.h:30
ColorT< T > operator/(const ColorT< T > &rhs) const
Definition: Color.h:111
const T & operator[](int n) const
Definition: Color.h:100
ColorT< T > operator=(const ColorT< FromT > &rhs)
Definition: Color.h:84
ColorAT< T > operator+(const ColorAT< T > &rhs) const
Definition: Color.h:288
GLenum GLint x
Definition: GLee.h:987
void set(const ColorAT< T > &rhs)
Definition: Color.h:250
void set(T ar, T ag, T ab, T aa)
Definition: Color.h:245
GLenum GLsizei n
Definition: GLee.h:5780
const ColorAT< T > & operator*=(T rhs)
Definition: Color.h:302
const GLdouble * v
Definition: GLee.h:1384
static ColorT< T > white()
Definition: Color.h:186
GLdouble GLdouble z
Definition: GLee.h:1911
GLboolean GLboolean GLboolean b
Definition: GLee.h:2964
static ColorT< T > black()
Definition: Color.h:181
const ColorAT< T > & operator+=(const ColorAT< T > &rhs)
Definition: Color.h:292
GLsizei const GLfloat * value
Definition: GLee.h:2487
ColorAT< T > lerp(T fact, const ColorAT< T > &d) const
Definition: Color.h:341
ColorAT< uint8_t > ColorA8u
Definition: Color.h:410
const GLubyte * c
Definition: GLee.h:8491
ColorAT< T > operator*(const ColorAT< T > &rhs) const
Definition: Color.h:290
void normalize()
Definition: Color.h:161
const ColorT< T > & operator/=(T rhs)
Definition: Color.h:123
ColorT< float > Color
Definition: Color.h:405
GLboolean GLboolean GLboolean GLboolean a
Definition: GLee.h:2964
T a
Definition: Color.h:216
const ColorT< T > & operator*=(const ColorT< T > &rhs)
Definition: Color.h:114
ColorT< T > lerp(float fact, const ColorT< T > &d) const
Definition: Color.h:171
bool operator!=(const ColorAT< T > &rhs) const
Definition: Color.h:310
ColorT< T > operator+(const ColorT< T > &rhs) const
Definition: Color.h:108
T r
Definition: Color.h:216
const ColorT< T > & operator+=(T rhs)
Definition: Color.h:120
ColorAT(const ColorT< FromT > &src)
Definition: Color.h:235
float length() const
Definition: Color.h:150
ColorT(const ColorT< FromT > &src)
Definition: Color.h:59
const ColorT< T > & operator-=(const ColorT< T > &rhs)
Definition: Color.h:113
ColorT< float > hsvToRGB(const Vec3f &hsv)
Definition: Color.cpp:324
T & operator[](int n)
Definition: Color.h:274
ColorModel
Definition: Color.h:35
ColorAT< T > operator+(T rhs) const
Definition: Color.h:296
ColorAT(const ColorT< T > &col, T aA=CHANTRAIT< T >::convert(1.0f))
Definition: Color.h:227
static ColorT< T > gray(T value)
Definition: Color.h:191
ColorT< T > operator/(T rhs) const
Definition: Color.h:119
bool operator==(const ColorAT< T > &rhs) const
Definition: Color.h:305
CHANTRAIT< T >::Accum distanceSquared(const ColorT< T > &rhs) const
Definition: Color.h:145
ColorT< T > operator=(const ColorT< T > &rhs)
Definition: Color.h:75
static ColorAT< T > black()
Definition: Color.h:351
bool operator!=(const ColorT< T > &rhs) const
Definition: Color.h:130
ColorT< T > operator-(const ColorT< T > &rhs) const
Definition: Color.h:109
const ColorT< T > & operator/=(const ColorT< T > &rhs)
Definition: Color.h:115
static ColorAT< T > gray(T value, T alpha=CHANTRAIT< T >::max())
Definition: Color.h:361
GLdouble s
Definition: GLee.h:1378
ColorAT< T > operator/(const ColorAT< T > &rhs) const
Definition: Color.h:291
float distance(const ColorT< T > &rhs) const
Definition: Color.h:140
static ColorAT< T > hex(uint32_t hexValue)
Returns a ColorA from a hexadecimal-encoded RGB triple. For example, red is 0xFF0000.
Definition: Color.h:367
const ColorAT< T > & operator/=(const ColorAT< T > &rhs)
Definition: Color.h:295
ColorT< T > operator*(T rhs) const
Definition: Color.h:118
GLclampf f
Definition: GLee.h:15307
T r
Definition: Color.h:44
const ColorAT< T > & operator*=(const ColorAT< T > &rhs)
Definition: Color.h:294
T g
Definition: Color.h:216
ColorT(const ColorT< T > &src)
Definition: Color.h:50
ColorT< uint8_t > svgNameToRgb(const char *svgName, bool *found=NULL)
Converts the named colors of the SVG spec http://en.wikipedia.org/wiki/Web_colors#X11_color_names to ...
Definition: Color.cpp:389
ColorAT< T > operator=(const ColorAT< T > &rhs)
Definition: Color.h:255
void convert(const SourceT *sourceArray, DestT *destArray, size_t length)
Converts between two arrays of different precision (ex. float to double). length samples are converte...
Definition: Converter.h:72
bool operator==(const ColorT< T > &rhs) const
Definition: Color.h:125