Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Color.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Cinder Project, All rights reserved.
3  This code is intended for use with the Cinder C++ library: http://libcinder.org
4 
5  Portions Copyright (c) 2010, The Barbarian Group
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
9  the following conditions are met:
10 
11  * Redistributions of source code must retain the above copyright notice, this list of conditions and
12  the following disclaimer.
13  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
14  the following disclaimer in the documentation and/or other materials provided with the distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
17  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
19  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
20  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23  POSSIBILITY OF SUCH DAMAGE.
24 */
25 
26 #pragma once
27 
28 #include "cinder/Cinder.h"
29 #include "cinder/ChanTraits.h"
30 #include "cinder/Vector.h"
31 #include "cinder/CinderMath.h"
32 
33 namespace cinder {
34 
35 typedef enum {
36  CM_RGB, // Red[0 - 1.0] Green[0 - 1.0] Blue[0 - 1.0]
37  CM_HSV // Hue[0 - 1.0] Saturation[0 - 1.0] Value[0 - 1.0]
38 } ColorModel;
39 
40 template<typename T>
41 class ColorT
42 {
43  public:
44  T r,g,b;
45 
46  ColorT() : r( 0 ), g( 0 ), b( 0 ) {}
47  ColorT( T aR, T aG, T aB )
48  : r( aR ), g( aG ), b( aB )
49  {}
50  ColorT( const ColorT<T> &src )
51  : r( src.r ), g( src.g ), b( src.b )
52  {}
53  ColorT( const char *svgColorName );
54 
55  ColorT( ColorModel cm, const Vec3f &v );
56  ColorT( ColorModel cm, float x, float y, float z );
57 
58  template<typename FromT>
60  : r( CHANTRAIT<T>::convert( src.r ) ), g( CHANTRAIT<T>::convert( src.g ) ), b( CHANTRAIT<T>::convert( src.b ) )
61  {}
62 
63  void set( T ar, T ag, T ab )
64  {
65  r = ar; g = ag; b = ab;
66  }
67 
68  void set( const ColorT<T> &rhs )
69  {
70  r = rhs.r; g = rhs.g; b = rhs.b;
71  }
72 
73  void set( ColorModel cm, const Vec3f &v );
74 
75  ColorT<T> operator=( const ColorT<T> &rhs )
76  {
77  r = rhs.r;
78  g = rhs.g;
79  b = rhs.b;
80  return * this;
81  }
82 
83  template<class FromT>
85  {
86  r = CHANTRAIT<T>::convert( rhs.r );
87  g = CHANTRAIT<T>::convert( rhs.g );
88  b = CHANTRAIT<T>::convert( rhs.b );
89  return * this;
90  }
91 
92  Vec3f get( ColorModel cm ) const;
93 
94  T& operator[]( int n )
95  {
96  assert( n >= 0 && n <= 2 );
97  return (&r)[n];
98  }
99 
100  const T& operator[]( int n ) const
101  {
102  assert( n >= 0 && n <= 2 );
103  return (&r)[n];
104  }
105 
106  T* ptr() const { return &(const_cast<ColorT*>( this )->r); }
107 
108  ColorT<T> operator+( const ColorT<T> &rhs ) const { return ColorT<T>( r + rhs.r, g + rhs.g, b + rhs.b ); }
109  ColorT<T> operator-( const ColorT<T> &rhs ) const { return ColorT<T>( r - rhs.r, g - rhs.g, b - rhs.b ); }
110  ColorT<T> operator*( const ColorT<T> &rhs ) const { return ColorT<T>( r * rhs.r, g * rhs.g, b * rhs.b ); }
111  ColorT<T> operator/( const ColorT<T> &rhs ) const { return ColorT<T>( r / rhs.r, g / rhs.g, b / rhs.b ); }
112  const ColorT<T>& operator+=( const ColorT<T> &rhs ) { r += rhs.r; g += rhs.g; b += rhs.b; return *this; }
113  const ColorT<T>& operator-=( const ColorT<T> &rhs ) { r -= rhs.r; g -= rhs.g; b -= rhs.b; return *this; }
114  const ColorT<T>& operator*=( const ColorT<T> &rhs ) { r *= rhs.r; g *= rhs.g; b *= rhs.b; return *this; }
115  const ColorT<T>& operator/=( const ColorT<T> &rhs ) { r /= rhs.r; g /= rhs.g; b /= rhs.b; return *this; }
116  ColorT<T> operator+( T rhs ) const { return ColorT<T>( r + rhs, g + rhs, b + rhs ); }
117  ColorT<T> operator-( T rhs ) const { return ColorT<T>( r - rhs, g - rhs, b - rhs ); }
118  ColorT<T> operator*( T rhs ) const { return ColorT<T>( r * rhs, g * rhs, b * rhs ); }
119  ColorT<T> operator/( T rhs ) const { return ColorT<T>( r / rhs, g / rhs, b / rhs ); }
120  const ColorT<T>& operator+=( T rhs ) { r += rhs; g += rhs; b += rhs; return *this; }
121  const ColorT<T>& operator-=( T rhs ) { r -= rhs; g -= rhs; b -= rhs; return *this; }
122  const ColorT<T>& operator*=( T rhs ) { r *= rhs; g *= rhs; b *= rhs; return *this; }
123  const ColorT<T>& operator/=( T rhs ) { r /= rhs; g /= rhs; b /= rhs; return *this; }
124 
125  bool operator==( const ColorT<T>& rhs ) const
126  {
127  return ( r == rhs.r ) && ( g == rhs.g ) && ( b == rhs.b );
128  }
129 
130  bool operator!=( const ColorT<T>& rhs ) const
131  {
132  return ! ( *this == rhs );
133  }
134 
135  typename CHANTRAIT<T>::Accum dot( const ColorT<T> &rhs ) const
136  {
137  return r*rhs.r + g*rhs.g + b*rhs.b;
138  }
139 
140  float distance( const ColorT<T> &rhs ) const
141  {
142  return math<float>::sqrt( static_cast<float>( (r - rhs.r)*(r - rhs.r) + (g - rhs.g)*(g - rhs.g) + (b - rhs.b)*(b - rhs.b)) );
143  }
144 
145  typename CHANTRAIT<T>::Accum distanceSquared( const ColorT<T> &rhs ) const
146  {
147  return (r - rhs.r) * (r - rhs.r) + (g - rhs.g) * (g - rhs.g) + (b - rhs.b) * (b - rhs.b);
148  }
149 
150  float length() const
151  {
152  return math<float>::sqrt( static_cast<float>( r*r + g*g + b*b ) );
153  }
154 
156  {
157  return r*r + g*g + b*b;
158  }
159 
160  // tests for zero-length
161  void normalize()
162  {
163  float s = length();
164  if( s > 0.0f ) {
165  r = static_cast<T>( r / s );
166  g = static_cast<T>( g / s );
167  b = static_cast<T>( b / s );
168  }
169  }
170 
171  ColorT<T> lerp( float fact, const ColorT<T> &d ) const
172  {
173  return ColorT<T>( r + ( d.r - r ) * fact, g + ( d.g - g ) * fact, b + ( d.b - b ) * fact );
174  }
175 
176  static ColorT<T> max()
177  {
179  }
180 
181  static ColorT<T> black()
182  {
183  return ColorT<T>( static_cast<T>( 0 ), static_cast<T>( 0 ), static_cast<T>( 0 ) );
184  }
185 
186  static ColorT<T> white()
187  {
189  }
190 
191  static ColorT<T> gray( T value )
192  {
193  return ColorT<T>( value, value, value );
194  }
195 
197  static ColorT<T> hex( uint32_t hexValue )
198  {
199  uint8_t red = ( hexValue >> 16 ) & 255;
200  uint8_t green = ( hexValue >> 8 ) & 255;
201  uint8_t blue = hexValue & 255;
203  }
204 
205  operator T*(){ return (T*) this; }
206  operator const T*() const { return (const T*) this; }
207 };
208 
209 
211 // ColorAT
212 
213 template<typename T>
214 class ColorAT {
215  public:
216  T r,g,b,a;
217 
219  : r( 0 ), g( 0 ), b( 0 ), a( 0 )
220  {}
221  ColorAT( T aR, T aG, T aB, T aA = CHANTRAIT<T>::convert( 1.0f ) )
222  : r( aR ), g( aG ), b( aB ), a( aA )
223  {}
224  ColorAT( const ColorAT<T> &src )
225  : r( src.r ), g( src.g ), b( src.b ), a( src.a )
226  {}
227  ColorAT( const ColorT<T> &col, T aA = CHANTRAIT<T>::convert( 1.0f ) )
228  : r( col.r ), g( col.g ), b( col.b ), a( aA )
229  {}
230  ColorAT( const char *svgColorName, T aA = CHANTRAIT<T>::convert( 1.0f ) );
231 
232  ColorAT( ColorModel cm, float c1, float c2, float c3, float aA = CHANTRAIT<T>::convert( 1.0f ) );
233 
234  template<typename FromT>
236  : r( CHANTRAIT<T>::convert( src.r ) ), g( CHANTRAIT<T>::convert( src.g ) ), b( CHANTRAIT<T>::convert( src.b ) ), a( CHANTRAIT<T>::convert( 1.0f ) )
237  {}
238 
239 
240  template<typename FromT>
242  : r( CHANTRAIT<T>::convert( src.r ) ), g( CHANTRAIT<T>::convert( src.g ) ), b( CHANTRAIT<T>::convert( src.b ) ), a( CHANTRAIT<T>::convert( src.a ) )
243  {}
244 
245  void set( T ar, T ag, T ab , T aa )
246  {
247  r = ar; g = ag; b = ab; a = aa;
248  }
249 
250  void set( const ColorAT<T> &rhs )
251  {
252  r = rhs.r; g = rhs.g; b = rhs.b; a = rhs.a;
253  }
254 
256  {
257  r = rhs.r;
258  g = rhs.g;
259  b = rhs.b;
260  a = rhs.a;
261  return * this;
262  }
263 
264  template<class FromT>
266  {
267  r = CHANTRAIT<T>::convert( rhs.r );
268  g = CHANTRAIT<T>::convert( rhs.g );
269  b = CHANTRAIT<T>::convert( rhs.b );
270  a = CHANTRAIT<T>::convert( rhs.a );
271  return * this;
272  }
273 
274  T& operator[]( int n )
275  {
276  assert( n >= 0 && n <= 3 );
277  return (&r)[n];
278  }
279 
280  const T& operator[]( int n ) const
281  {
282  assert( n >= 0 && n <= 3 );
283  return (&r)[n];
284  }
285 
286  T* ptr() const { return &(const_cast<ColorAT*>( this )->r); }
287 
288  ColorAT<T> operator+( const ColorAT<T> &rhs ) const { return ColorAT<T>( r + rhs.r, g + rhs.g, b + rhs.b, a + rhs.a ); }
289  ColorAT<T> operator-( const ColorAT<T> &rhs ) const { return ColorAT<T>( r - rhs.r, g - rhs.g, b - rhs.b, a - rhs.a ); }
290  ColorAT<T> operator*( const ColorAT<T> &rhs ) const { return ColorAT<T>( r * rhs.r, g * rhs.g, b * rhs.b, a * rhs.a ); }
291  ColorAT<T> operator/( const ColorAT<T> &rhs ) const { return ColorAT<T>( r / rhs.r, g / rhs.g, b / rhs.b, a / rhs.a ); }
292  const ColorAT<T>& operator+=( const ColorAT<T> &rhs ) { r += rhs.r; g += rhs.g; b += rhs.b; a += rhs.a; return *this; }
293  const ColorAT<T>& operator-=( const ColorAT<T> &rhs ) { r -= rhs.r; g -= rhs.g; b -= rhs.b; a -= rhs.a; return *this; }
294  const ColorAT<T>& operator*=( const ColorAT<T> &rhs ) { r *= rhs.r; g *= rhs.g; b *= rhs.b; a *= rhs.a; return *this; }
295  const ColorAT<T>& operator/=( const ColorAT<T> &rhs ) { r /= rhs.r; g /= rhs.g; b /= rhs.b; a /= rhs.a; return *this; }
296  ColorAT<T> operator+( T rhs ) const { return ColorAT<T>( r + rhs, g + rhs, b + rhs, a + rhs ); }
297  ColorAT<T> operator-( T rhs ) const { return ColorAT<T>( r - rhs, g - rhs, b - rhs, a - rhs ); }
298  ColorAT<T> operator*( T rhs ) const { return ColorAT<T>( r * rhs, g * rhs, b * rhs, a * rhs ); }
299  ColorAT<T> operator/( T rhs ) const { return ColorAT<T>( r / rhs, g / rhs, b / rhs, a / rhs ); }
300  const ColorAT<T>& operator+=( T rhs ) { r += rhs; g += rhs; b += rhs; a += rhs; return *this; }
301  const ColorAT<T>& operator-=( T rhs ) { r -= rhs; g -= rhs; b -= rhs; a -= rhs; return * this; }
302  const ColorAT<T>& operator*=( T rhs ) { r *= rhs; g *= rhs; b *= rhs; a *= rhs; return * this; }
303  const ColorAT<T>& operator/=( T rhs ) { r /= rhs; g /= rhs; b /= rhs; a /= rhs; return * this; }
304 
305  bool operator==( const ColorAT<T>& rhs ) const
306  {
307  return ( r == rhs.r ) && ( g == rhs.g ) && ( b == rhs.b ) && ( a == rhs.a );
308  }
309 
310  bool operator!=( const ColorAT<T>& rhs ) const
311  {
312  return ! ( *this == rhs );
313  }
314 
315  float length() const
316  {
317  return math<float>::sqrt( static_cast<float>( r*r + g*g + b*b ) );
318  }
319 
320  // tests for zero-length
321  void normalize()
322  {
323  float s = length();
324  if( s > 0.0f ) {
325  r = static_cast<T>( r / s );
326  g = static_cast<T>( g / s );
327  b = static_cast<T>( b / s );
328  }
329  }
330 
332  {
333  return ColorAT<T>( r * a, g * a, b * a, a );
334  }
335 
337  {
338  return r * r + g * g + b * b;
339  }
340 
341  ColorAT<T> lerp( T fact, const ColorAT<T> &d ) const
342  {
343  return ColorAT<T>( r + ( d.r - r ) * fact, g + ( d.g - g ) * fact, b + ( d.b - b ) * fact, a + ( d.a - a ) * fact );
344  }
345 
346  static ColorAT<T> zero()
347  {
348  return ColorAT<T>( static_cast<T>( 0 ), static_cast<T>( 0 ), static_cast<T>( 0 ), static_cast<T>( 0 ) );
349  }
350 
351  static ColorAT<T> black()
352  {
353  return ColorAT<T>( static_cast<T>( 0 ), static_cast<T>( 0 ), static_cast<T>( 0 ), CHANTRAIT<T>::max() );
354  }
355 
356  static ColorAT<T> white()
357  {
359  }
360 
362  {
363  return ColorAT<T>( value, value, value, alpha );
364  }
365 
367  static ColorAT<T> hex( uint32_t hexValue )
368  {
369  uint8_t red = ( hexValue >> 16 ) & 255;
370  uint8_t green = ( hexValue >> 8 ) & 255;
371  uint8_t blue = hexValue & 255;
373  }
374 
376  static ColorAT<T> hexA( uint32_t hexValue )
377  {
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;
383  }
384 
385  operator T*(){ return (T*) this; }
386  operator const T*() const { return (const T*) this; }
387  operator ColorT<T>(){ return ColorT<T>( r, g, b ); }
388 };
389 
390 // Operators
391 template <typename T, typename Y> inline ColorT<T> operator*( Y s, const ColorT<T>& c ) { return ColorT<T>( s*c.r, s*c.g, s*c.b ); }
392 template <typename T, typename Y> inline ColorAT<T> operator*( Y s, const ColorAT<T>& c ) { return ColorAT<T>( s*c.r, s*c.g, s*c.b, s*c.a ); }
393 
394 // Free Functions
395 extern ColorT<float> hsvToRGB( const Vec3f &hsv );
396 extern Vec3f rgbToHSV( const ColorT<float> &c );
398 extern ColorT<uint8_t> svgNameToRgb( const char *svgName, bool *found = NULL );
399 
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 );
404 
411 
412 } // namespace cinder
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
Definition: Color.h:36
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
Definition: Color.h:214
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
Definition: Color.h:37
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
Definition: Color.h:41
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