arsa  2.7
SColor.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __COLOR_H_INCLUDED__
6 #define __COLOR_H_INCLUDED__
7 
8 #include "irrTypes.h"
9 #include "irrMath.h"
10 
11 namespace irr
12 {
13 namespace video
14 {
16 
21  {
23 
27 
30 
33  // format or even not working at all. It's mostly better to use 16-bit or 32-bit formats.
35 
39 
42  ECF_DXT1,
44 
47 
50 
53 
56 
59 
62 
65 
68 
71 
74 
77 
80 
83 
88  ECF_R16F,
90 
93 
96 
99 
102 
105 
108  ECF_R8,
110 
113 
116 
119 
122  ECF_D16,
124 
127 
130 
133  };
134 
136  const c8* const ColorFormatNames[ECF_UNKNOWN+2] =
137  {
138  "A1R5G5B5",
139  "R5G6B5",
140  "R8G8B8",
141  "A8R8G8B8",
142  "DXT1",
143  "DXT2",
144  "DXT3",
145  "DXT4",
146  "DXT5",
147  "PVRTC_RGB2",
148  "PVRTC_ARGB2",
149  "PVRTC_RGB4",
150  "PVRTC_ARGB4",
151  "PVRTC2_ARGB2",
152  "PVRTC2_ARGB4",
153  "ETC1",
154  "ETC2_RGB",
155  "ETC2_ARGB",
156  "R16F",
157  "G16R16F",
158  "A16B16G16R16F",
159  "R32F",
160  "G32R32F",
161  "A32B32G32R32F",
162  "R8",
163  "R8G8",
164  "R16",
165  "R16G16",
166  "D16",
167  "D32",
168  "D24S8",
169  "UNKNOWN",
170  0
171  };
172 
173 
175  inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a=0xFF)
176  {
177  return (u16)((a & 0x80) << 8 |
178  (r & 0xF8) << 7 |
179  (g & 0xF8) << 2 |
180  (b & 0xF8) >> 3);
181  }
182 
183 
185  inline u16 RGB16(u32 r, u32 g, u32 b)
186  {
187  return RGBA16(r,g,b);
188  }
189 
190 
192  inline u16 RGB16from16(u16 r, u16 g, u16 b)
193  {
194  return (0x8000 |
195  (r & 0x1F) << 10 |
196  (g & 0x1F) << 5 |
197  (b & 0x1F));
198  }
199 
200 
203  {
204  return (u16)(0x8000 |
205  ( color & 0x00F80000) >> 9 |
206  ( color & 0x0000F800) >> 6 |
207  ( color & 0x000000F8) >> 3);
208  }
209 
210 
213  {
214  return (u16)(( color & 0x80000000) >> 16|
215  ( color & 0x00F80000) >> 9 |
216  ( color & 0x0000F800) >> 6 |
217  ( color & 0x000000F8) >> 3);
218  }
219 
220 
223  {
224  return (u16)(( color & 0x00F80000) >> 8 |
225  ( color & 0x0000FC00) >> 5 |
226  ( color & 0x000000F8) >> 3);
227  }
228 
229 
231 
233  {
234  return ( (( -( (s32) color & 0x00008000 ) >> (s32) 31 ) & 0xFF000000 ) |
235  (( color & 0x00007C00 ) << 9) | (( color & 0x00007000 ) << 4) |
236  (( color & 0x000003E0 ) << 6) | (( color & 0x00000380 ) << 1) |
237  (( color & 0x0000001F ) << 3) | (( color & 0x0000001C ) >> 2)
238  );
239  }
240 
241 
244  {
245  return 0xFF000000 |
246  ((color & 0xF800) << 8)|
247  ((color & 0x07E0) << 5)|
248  ((color & 0x001F) << 3);
249  }
250 
251 
254  {
255  return 0x8000 | (((color & 0xFFC0) >> 1) | (color & 0x1F));
256  }
257 
258 
261  {
262  return (((color & 0x7FE0) << 1) | (color & 0x1F));
263  }
264 
265 
266 
268 
271  {
272  return ((color >> 15)&0x1);
273  }
274 
275 
277 
278  inline u32 getRed(u16 color)
279  {
280  return ((color >> 10)&0x1F);
281  }
282 
283 
285 
287  {
288  return ((color >> 5)&0x1F);
289  }
290 
291 
293 
295  {
296  return (color & 0x1F);
297  }
298 
299 
302  {
303  return ((getRed(color)<<3) + (getGreen(color)<<3) + (getBlue(color)<<3)) / 3;
304  }
305 
306 
308 
316  class SColor
317  {
318  public:
319 
321 
322  SColor() {}
323 
325 
327  : color(((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)) {}
328 
330  SColor(u32 clr)
331  : color(clr) {}
332 
334 
336  u32 getAlpha() const { return color>>24; }
337 
339 
341  u32 getRed() const { return (color>>16) & 0xff; }
342 
344 
346  u32 getGreen() const { return (color>>8) & 0xff; }
347 
349 
351  u32 getBlue() const { return color & 0xff; }
352 
355  {
357  }
358 
361  {
362  return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue();
363  }
364 
366  u32 getAverage() const
367  {
368  return ( getRed() + getGreen() + getBlue() ) / 3;
369  }
370 
372 
374  void setAlpha(u32 a) { color = ((a & 0xff)<<24) | (color & 0x00ffffff); }
375 
377 
379  void setRed(u32 r) { color = ((r & 0xff)<<16) | (color & 0xff00ffff); }
380 
382 
384  void setGreen(u32 g) { color = ((g & 0xff)<<8) | (color & 0xffff00ff); }
385 
387 
389  void setBlue(u32 b) { color = (b & 0xff) | (color & 0xffffff00); }
390 
392 
393  u16 toA1R5G5B5() const { return A8R8G8B8toA1R5G5B5(color); }
394 
396 
399  void toOpenGLColor(u8* dest) const
400  {
401  *dest = (u8)getRed();
402  *++dest = (u8)getGreen();
403  *++dest = (u8)getBlue();
404  *++dest = (u8)getAlpha();
405  }
406 
408 
422  void set(u32 a, u32 r, u32 g, u32 b)
423  {
424  color = (((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff));
425  }
426  void set(u32 col) { color = col; }
427 
429 
430  bool operator==(const SColor& other) const { return other.color == color; }
431 
433 
434  bool operator!=(const SColor& other) const { return other.color != color; }
435 
437 
438  bool operator<(const SColor& other) const { return (color < other.color); }
439 
441 
443  SColor operator+(const SColor& other) const
444  {
445  return SColor(core::min_(getAlpha() + other.getAlpha(), 255u),
446  core::min_(getRed() + other.getRed(), 255u),
447  core::min_(getGreen() + other.getGreen(), 255u),
448  core::min_(getBlue() + other.getBlue(), 255u));
449  }
450 
452 
455  SColor getInterpolated(const SColor &other, f32 d) const
456  {
457  d = core::clamp(d, 0.f, 1.f);
458  const f32 inv = 1.0f - d;
459  return SColor((u32)core::round32(other.getAlpha()*inv + getAlpha()*d),
460  (u32)core::round32(other.getRed()*inv + getRed()*d),
461  (u32)core::round32(other.getGreen()*inv + getGreen()*d),
462  (u32)core::round32(other.getBlue()*inv + getBlue()*d));
463  }
464 
466 
469  SColor getInterpolated_quadratic(const SColor& c1, const SColor& c2, f32 d) const
470  {
471  // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d;
472  d = core::clamp(d, 0.f, 1.f);
473  const f32 inv = 1.f - d;
474  const f32 mul0 = inv * inv;
475  const f32 mul1 = 2.f * d * inv;
476  const f32 mul2 = d * d;
477 
478  return SColor(
480  getAlpha() * mul0 + c1.getAlpha() * mul1 + c2.getAlpha() * mul2 ), 0, 255 ),
482  getRed() * mul0 + c1.getRed() * mul1 + c2.getRed() * mul2 ), 0, 255 ),
484  getGreen() * mul0 + c1.getGreen() * mul1 + c2.getGreen() * mul2 ), 0, 255 ),
486  getBlue() * mul0 + c1.getBlue() * mul1 + c2.getBlue() * mul2 ), 0, 255 ));
487  }
488 
490 
493  void setData(const void *data, ECOLOR_FORMAT format)
494  {
495  switch (format)
496  {
497  case ECF_A1R5G5B5:
499  break;
500  case ECF_R5G6B5:
502  break;
503  case ECF_A8R8G8B8:
504  color = *(u32*)data;
505  break;
506  case ECF_R8G8B8:
507  {
508  const u8* p = (u8*)data;
509  set(255, p[0],p[1],p[2]);
510  }
511  break;
512  default:
513  color = 0xffffffff;
514  break;
515  }
516  }
517 
519 
522  void getData(void *data, ECOLOR_FORMAT format) const
523  {
524  switch(format)
525  {
526  case ECF_A1R5G5B5:
527  {
528  u16 * dest = (u16*)data;
529  *dest = video::A8R8G8B8toA1R5G5B5( color );
530  }
531  break;
532 
533  case ECF_R5G6B5:
534  {
535  u16 * dest = (u16*)data;
536  *dest = video::A8R8G8B8toR5G6B5( color );
537  }
538  break;
539 
540  case ECF_R8G8B8:
541  {
542  u8* dest = (u8*)data;
543  dest[0] = (u8)getRed();
544  dest[1] = (u8)getGreen();
545  dest[2] = (u8)getBlue();
546  }
547  break;
548 
549  case ECF_A8R8G8B8:
550  {
551  u32 * dest = (u32*)data;
552  *dest = color;
553  }
554  break;
555 
556  default:
557  break;
558  }
559  }
560 
563  };
564 
565 
567 
573  class SColorf
574  {
575  public:
577 
578  SColorf() : r(0.0f), g(0.0f), b(0.0f), a(1.0f) {}
579 
581 
591  SColorf(f32 r, f32 g, f32 b, f32 a = 1.0f) : r(r), g(g), b(b), a(a) {}
592 
594 
597  {
598  const f32 inv = 1.0f / 255.0f;
599  r = c.getRed() * inv;
600  g = c.getGreen() * inv;
601  b = c.getBlue() * inv;
602  a = c.getAlpha() * inv;
603  }
604 
606  SColor toSColor() const
607  {
608  return SColor((u32)core::round32(a*255.0f), (u32)core::round32(r*255.0f), (u32)core::round32(g*255.0f), (u32)core::round32(b*255.0f));
609  }
610 
612 
618  void set(f32 rr, f32 gg, f32 bb) {r = rr; g =gg; b = bb; }
619 
621 
629  void set(f32 aa, f32 rr, f32 gg, f32 bb) {a = aa; r = rr; g =gg; b = bb; }
630 
632 
635  SColorf getInterpolated(const SColorf &other, f32 d) const
636  {
637  d = core::clamp(d, 0.f, 1.f);
638  const f32 inv = 1.0f - d;
639  return SColorf(other.r*inv + r*d,
640  other.g*inv + g*d, other.b*inv + b*d, other.a*inv + a*d);
641  }
642 
644 
647  inline SColorf getInterpolated_quadratic(const SColorf& c1, const SColorf& c2,
648  f32 d) const
649  {
650  d = core::clamp(d, 0.f, 1.f);
651  // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d;
652  const f32 inv = 1.f - d;
653  const f32 mul0 = inv * inv;
654  const f32 mul1 = 2.f * d * inv;
655  const f32 mul2 = d * d;
656 
657  return SColorf (r * mul0 + c1.r * mul1 + c2.r * mul2,
658  g * mul0 + c1.g * mul1 + c2.g * mul2,
659  b * mul0 + c1.b * mul1 + c2.b * mul2,
660  a * mul0 + c1.a * mul1 + c2.a * mul2);
661  }
662 
663 
666  {
667  switch(index)
668  {
669  case 0: r = value; break;
670  case 1: g = value; break;
671  case 2: b = value; break;
672  case 3: a = value; break;
673  }
674  }
675 
677  f32 getAlpha() const { return a; }
678 
680  f32 getRed() const { return r; }
681 
683  f32 getGreen() const { return g; }
684 
686  f32 getBlue() const { return b; }
687 
690 
693 
696 
699  };
700 
701 
703 
707  class SColorHSL
708  {
709  public:
710  SColorHSL ( f32 h = 0.f, f32 s = 0.f, f32 l = 0.f )
711  : Hue ( h ), Saturation ( s ), Luminance ( l ) {}
712 
713  void fromRGB(const SColorf &color);
714  void toRGB(SColorf &color) const;
715 
719 
720  private:
721  inline f32 toRGB1(f32 rm1, f32 rm2, f32 rh) const;
722 
723  };
724 
725  inline void SColorHSL::fromRGB(const SColorf &color)
726  {
727  const f32 maxVal = core::max_(color.getRed(), color.getGreen(), color.getBlue());
728  const f32 minVal = (f32)core::min_(color.getRed(), color.getGreen(), color.getBlue());
729  Luminance = (maxVal+minVal)*50;
730  if (core::equals(maxVal, minVal))
731  {
732  Hue=0.f;
733  Saturation=0.f;
734  return;
735  }
736 
737  const f32 delta = maxVal-minVal;
738  if ( Luminance <= 50 )
739  {
740  Saturation = (delta)/(maxVal+minVal);
741  }
742  else
743  {
744  Saturation = (delta)/(2-maxVal-minVal);
745  }
746  Saturation *= 100;
747 
748  if (core::equals(maxVal, color.getRed()))
749  Hue = (color.getGreen()-color.getBlue())/delta;
750  else if (core::equals(maxVal, color.getGreen()))
751  Hue = 2+((color.getBlue()-color.getRed())/delta);
752  else // blue is max
753  Hue = 4+((color.getRed()-color.getGreen())/delta);
754 
755  Hue *= 60.0f;
756  while ( Hue < 0.f )
757  Hue += 360;
758  }
759 
760 
761  inline void SColorHSL::toRGB(SColorf &color) const
762  {
763  const f32 l = Luminance/100;
764  if (core::iszero(Saturation)) // grey
765  {
766  color.set(l, l, l);
767  return;
768  }
769 
770  f32 rm2;
771 
772  if ( Luminance <= 50 )
773  {
774  rm2 = l + l * (Saturation/100);
775  }
776  else
777  {
778  rm2 = l + (1 - l) * (Saturation/100);
779  }
780 
781  const f32 rm1 = 2.0f * l - rm2;
782 
783  const f32 h = Hue / 360.0f;
784  color.set( toRGB1(rm1, rm2, h + 1.f/3.f),
785  toRGB1(rm1, rm2, h),
786  toRGB1(rm1, rm2, h - 1.f/3.f)
787  );
788  }
789 
790 
791  // algorithm from Foley/Van-Dam
792  inline f32 SColorHSL::toRGB1(f32 rm1, f32 rm2, f32 rh) const
793  {
794  if (rh<0)
795  rh += 1;
796  if (rh>1)
797  rh -= 1;
798 
799  if (rh < 1.f/6.f)
800  rm1 = rm1 + (rm2 - rm1) * rh*6.f;
801  else if (rh < 0.5f)
802  rm1 = rm2;
803  else if (rh < 2.f/3.f)
804  rm1 = rm1 + (rm2 - rm1) * ((2.f/3.f)-rh)*6.f;
805 
806  return rm1;
807  }
808 
809 } // end namespace video
810 } // end namespace irr
811 
812 #endif
signed short s16
16 bit signed variable.
Definition: irrTypes.h:52
f32 getAlpha() const
Returns the alpha component of the color in the range 0.0 (transparent) to 1.0 (opaque)
Definition: SColor.h:677
u16 RGB16(u32 r, u32 g, u32 b)
Creates a 16 bit A1R5G5B5 color.
Definition: SColor.h:185
REALINLINE s32 round32(f32 x)
Definition: irrMath.h:657
void setBlue(u32 b)
Sets the blue component of the Color.
Definition: SColor.h:389
u32 getAlpha() const
Returns the alpha component of the color.
Definition: SColor.h:336
bool iszero(const f64 a, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals zero, taking rounding errors into account
Definition: irrMath.h:307
void set(f32 rr, f32 gg, f32 bb)
Sets three color components to new values at once.
Definition: SColor.h:618
f32 b
blue component
Definition: SColor.h:695
GLuint GLfloat GLfloat GLfloat x1
16 bit format using 16 bits for depth.
Definition: SColor.h:123
DXT3 color format.
Definition: SColor.h:49
PVRTC RGB 4bpp.
Definition: SColor.h:64
f32 g
green color component
Definition: SColor.h:692
DXT4 color format.
Definition: SColor.h:52
64 bit format using 32 bits for the red and green channels.
Definition: SColor.h:101
SColor getInterpolated(const SColor &other, f32 d) const
Interpolates the color with a f32 value to another color.
Definition: SColor.h:455
SColor operator+(const SColor &other) const
Adds two colors, result is clamped to 0..255 values.
Definition: SColor.h:443
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
const c8 *const ColorFormatNames[ECF_UNKNOWN+2]
Names for ECOLOR_FORMAT types.
Definition: SColor.h:136
u32 getGreen() const
Returns the green component of the color.
Definition: SColor.h:346
void setRed(u32 r)
Sets the red component of the Color.
Definition: SColor.h:379
64 bit format using 16 bits for the red, green, blue and alpha channels.
Definition: SColor.h:95
32 bit format using 32 bits for the red channel.
Definition: SColor.h:98
GLfloat GLfloat GLfloat GLfloat h
char c8
8 bit character variable.
Definition: irrTypes.h:35
GLfloat GLfloat p
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
void toRGB(SColorf &color) const
Definition: SColor.h:761
ECOLOR_FORMAT
An enum for the color format of textures used by the Irrlicht Engine.
Definition: SColor.h:20
u16 RGBA16(u32 r, u32 g, u32 b, u32 a=0xFF)
Creates a 16 bit A1R5G5B5 color.
Definition: SColor.h:175
f32 getLightness() const
Get lightness of the color in the range [0,255].
Definition: SColor.h:354
void set(u32 a, u32 r, u32 g, u32 b)
Sets all four components of the color at once.
Definition: SColor.h:422
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
u32 A1R5G5B5toA8R8G8B8(u16 color)
Convert A8R8G8B8 Color from A1R5G5B5 color.
Definition: SColor.h:232
16 bit format using 16 bits for the red channel.
Definition: SColor.h:89
32 bit format using 24 bits for depth and 8 bits for stencil.
Definition: SColor.h:129
PVRTC RGB 2bpp.
Definition: SColor.h:58
void set(u32 col)
Definition: SColor.h:426
void toOpenGLColor(u8 *dest) const
Converts color to OpenGL color format.
Definition: SColor.h:399
u16 RGB16from16(u16 r, u16 g, u16 b)
Creates a 16bit A1R5G5B5 color, based on 16bit input values.
Definition: SColor.h:192
void setAlpha(u32 a)
Sets the alpha component of the Color.
Definition: SColor.h:374
SColorHSL(f32 h=0.f, f32 s=0.f, f32 l=0.f)
Definition: SColor.h:710
unsigned char u8
8 bit unsigned variable.
Definition: irrTypes.h:22
SColorf getInterpolated_quadratic(const SColorf &c1, const SColorf &c2, f32 d) const
Returns interpolated color. ( quadratic )
Definition: SColor.h:647
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
void setData(const void *data, ECOLOR_FORMAT format)
set the color by expecting data in the given format
Definition: SColor.h:493
SDL_AudioFormat format
Definition: SDL_audio.h:194
f32 a
alpha color component
Definition: SColor.h:698
SColor()
Constructor of the Color. Does nothing.
Definition: SColor.h:322
PVRTC2 ARGB 4bpp.
Definition: SColor.h:73
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
Definition: irrMath.h:246
void setColorComponentValue(s32 index, f32 value)
Sets a color component by index. R=0, G=1, B=2, A=3.
Definition: SColor.h:665
bool operator<(const SColor &other) const
comparison operator
Definition: SColor.h:438
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
u16 R5G6B5toA1R5G5B5(u16 color)
Returns A1R5G5B5 Color from R5G6B5 color.
Definition: SColor.h:253
f32 getBlue() const
Returns the blue component of the color in the range 0.0 to 1.0.
Definition: SColor.h:686
f32 getRed() const
Returns the red component of the color in the range 0.0 to 1.0.
Definition: SColor.h:680
u32 getAlpha(u16 color)
Returns the alpha component from A1R5G5B5 color.
Definition: SColor.h:270
GLsizei const GLfloat * value
Unknown color format:
Definition: SColor.h:132
128 bit format using 32 bits for the red, green, blue and alpha channels.
Definition: SColor.h:104
GLfloat f
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
16 bit color format used by the software driver.
Definition: SColor.h:26
8 bit format using 8 bits for the red channel.
Definition: SColor.h:109
SColor toSColor() const
Converts this color to a SColor without floats.
Definition: SColor.h:606
u16 A1R5G5B5toR5G6B5(u16 color)
Returns R5G6B5 Color from A1R5G5B5 color.
Definition: SColor.h:260
const T & min_(const T &a, const T &b)
returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)
Definition: irrMath.h:124
DXT2 color format.
Definition: SColor.h:46
SColor(u32 a, u32 r, u32 g, u32 b)
Constructs the color from 4 values representing the alpha, red, green and blue component.
Definition: SColor.h:326
PVRTC2 ARGB 2bpp.
Definition: SColor.h:70
void setGreen(u32 g)
Sets the green component of the Color.
Definition: SColor.h:384
void set(f32 aa, f32 rr, f32 gg, f32 bb)
Sets all four color components to new values at once.
Definition: SColor.h:629
bool operator==(const SColor &other) const
Compares the color to another color.
Definition: SColor.h:430
const T & max_(const T &a, const T &b)
returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)
Definition: irrMath.h:138
bool operator!=(const SColor &other) const
Compares the color to another color.
Definition: SColor.h:434
s32 getAverage(s16 color)
Returns the average from a 16 bit A1R5G5B5 color.
Definition: SColor.h:301
GLuint index
u16 toA1R5G5B5() const
Calculates a 16 bit A1R5G5B5 value of this color.
Definition: SColor.h:393
u16 X8R8G8B8toA1R5G5B5(u32 color)
Converts a 32bit (X8R8G8B8) color to a 16bit A1R5G5B5 color.
Definition: SColor.h:202
16 bit format using 16 bits for the red channel.
Definition: SColor.h:115
Class representing a 32 bit ARGB color.
Definition: SColor.h:316
32 bit format using 16 bits for the red and green channels.
Definition: SColor.h:118
void getData(void *data, ECOLOR_FORMAT format) const
Write the color to data in the defined format.
Definition: SColor.h:522
f32 getLuminance() const
Get luminance of the color in the range [0,255].
Definition: SColor.h:360
u32 getGreen(u16 color)
Returns the green component from A1R5G5B5 color.
Definition: SColor.h:286
DXT5 color format.
Definition: SColor.h:55
GLboolean GLboolean GLboolean b
GLdouble s
Definition: SDL_opengl.h:2063
u16 A8R8G8B8toR5G6B5(u32 color)
Converts a 32bit (A8R8G8B8) color to a 16bit R5G6B5 color.
Definition: SColor.h:222
Standard 16 bit color format.
Definition: SColor.h:29
u32 getBlue(u16 color)
Returns the blue component from A1R5G5B5 color.
Definition: SColor.h:294
u16 A8R8G8B8toA1R5G5B5(u32 color)
Converts a 32bit (A8R8G8B8) color to a 16bit A1R5G5B5 color.
Definition: SColor.h:212
SColorf()
Default constructor for SColorf.
Definition: SColor.h:578
GLuint color
f32 getGreen() const
Returns the green component of the color in the range 0.0 to 1.0.
Definition: SColor.h:683
ETC1 RGB.
Definition: SColor.h:76
SColorf(SColor c)
Constructs a color from 32 bit Color.
Definition: SColor.h:596
SColorf(f32 r, f32 g, f32 b, f32 a=1.0f)
Constructs a color from up to four color values: red, green, blue, and alpha.
Definition: SColor.h:591
f32 r
red color component
Definition: SColor.h:689
GLboolean GLboolean GLboolean GLboolean a
DXT1 color format.
Definition: SColor.h:43
32 bit format using 32 bits for depth.
Definition: SColor.h:126
REALINLINE s32 floor32(f32 x)
Definition: irrMath.h:646
SColorf getInterpolated(const SColorf &other, f32 d) const
Interpolates the color with a f32 value to another color.
Definition: SColor.h:635
u32 getRed(u16 color)
Returns the red component from A1R5G5B5 color.
Definition: SColor.h:278
Class representing a color in HSL format.
Definition: SColor.h:707
const GLubyte * c
SColor(u32 clr)
Constructs the color from a 32 bit value. Could be another color.
Definition: SColor.h:330
GLboolean GLboolean g
Class representing a color with four floats.
Definition: SColor.h:573
u32 getRed() const
Returns the red component of the color.
Definition: SColor.h:341
32 bit format using 16 bits for the red and green channels.
Definition: SColor.h:92
16 bit format using 8 bits for the red and green channels.
Definition: SColor.h:112
u32 getBlue() const
Returns the blue component of the color.
Definition: SColor.h:351
u32 getAverage() const
Get average intensity of the color in the range [0,255].
Definition: SColor.h:366
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition: irrMath.h:167
PVRTC ARGB 4bpp.
Definition: SColor.h:67
u32 color
color in A8R8G8B8 Format
Definition: SColor.h:562
SColor getInterpolated_quadratic(const SColor &c1, const SColor &c2, f32 d) const
Returns interpolated color. ( quadratic )
Definition: SColor.h:469
PVRTC ARGB 2bpp.
Definition: SColor.h:61
u32 R5G6B5toA8R8G8B8(u16 color)
Returns A8R8G8B8 Color from R5G6B5 color.
Definition: SColor.h:243
void fromRGB(const SColorf &color)
Definition: SColor.h:725