Irrlicht 3D Engine
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 
37 
40  ECF_DXT1,
42 
45 
48 
51 
54 
57 
60 
63 
66 
69 
72 
75 
78 
81 
86  ECF_R16F,
88 
91 
94 
97 
100 
103 
106  ECF_R8,
108 
111 
114 
117 
120  ECF_D16,
122 
125 
128 
131  };
132 
134  const c8* const ColorFormatNames[ECF_UNKNOWN+2] =
135  {
136  "A1R5G5B5",
137  "R5G6B5",
138  "R8G8B8",
139  "A8R8G8B8",
140  "DXT1",
141  "DXT2",
142  "DXT3",
143  "DXT4",
144  "DXT5",
145  "PVRTC_RGB2",
146  "PVRTC_ARGB2",
147  "PVRTC_RGB4",
148  "PVRTC_ARGB4",
149  "PVRTC2_ARGB2",
150  "PVRTC2_ARGB4",
151  "ETC1",
152  "ETC2_RGB",
153  "ETC2_ARGB",
154  "R16F",
155  "G16R16F",
156  "A16B16G16R16F",
157  "R32F",
158  "G32R32F",
159  "A32B32G32R32F",
160  "R8",
161  "R8G8",
162  "R16",
163  "R16G16",
164  "D16",
165  "D32",
166  "D24S8",
167  "UNKNOWN",
168  0
169  };
170 
171 
173  inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a=0xFF)
174  {
175  return (u16)((a & 0x80) << 8 |
176  (r & 0xF8) << 7 |
177  (g & 0xF8) << 2 |
178  (b & 0xF8) >> 3);
179  }
180 
181 
183  inline u16 RGB16(u32 r, u32 g, u32 b)
184  {
185  return RGBA16(r,g,b);
186  }
187 
188 
190  inline u16 RGB16from16(u16 r, u16 g, u16 b)
191  {
192  return (0x8000 |
193  (r & 0x1F) << 10 |
194  (g & 0x1F) << 5 |
195  (b & 0x1F));
196  }
197 
198 
200  inline u16 X8R8G8B8toA1R5G5B5(u32 color)
201  {
202  return (u16)(0x8000 |
203  ( color & 0x00F80000) >> 9 |
204  ( color & 0x0000F800) >> 6 |
205  ( color & 0x000000F8) >> 3);
206  }
207 
208 
210  inline u16 A8R8G8B8toA1R5G5B5(u32 color)
211  {
212  return (u16)(( color & 0x80000000) >> 16|
213  ( color & 0x00F80000) >> 9 |
214  ( color & 0x0000F800) >> 6 |
215  ( color & 0x000000F8) >> 3);
216  }
217 
218 
220  inline u16 A8R8G8B8toR5G6B5(u32 color)
221  {
222  return (u16)(( color & 0x00F80000) >> 8 |
223  ( color & 0x0000FC00) >> 5 |
224  ( color & 0x000000F8) >> 3);
225  }
226 
227 
229 
230  inline u32 A1R5G5B5toA8R8G8B8(u16 color)
231  {
232  return ( (( -( (s32) color & 0x00008000 ) >> (s32) 31 ) & 0xFF000000 ) |
233  (( color & 0x00007C00 ) << 9) | (( color & 0x00007000 ) << 4) |
234  (( color & 0x000003E0 ) << 6) | (( color & 0x00000380 ) << 1) |
235  (( color & 0x0000001F ) << 3) | (( color & 0x0000001C ) >> 2)
236  );
237  }
238 
239 
241  inline u32 R5G6B5toA8R8G8B8(u16 color)
242  {
243  return 0xFF000000 |
244  ((color & 0xF800) << 8)|
245  ((color & 0x07E0) << 5)|
246  ((color & 0x001F) << 3);
247  }
248 
249 
251  inline u16 R5G6B5toA1R5G5B5(u16 color)
252  {
253  return 0x8000 | (((color & 0xFFC0) >> 1) | (color & 0x1F));
254  }
255 
256 
258  inline u16 A1R5G5B5toR5G6B5(u16 color)
259  {
260  return (((color & 0x7FE0) << 1) | (color & 0x1F));
261  }
262 
263 
264 
266 
268  inline u32 getAlpha(u16 color)
269  {
270  return ((color >> 15)&0x1);
271  }
272 
273 
275 
276  inline u32 getRed(u16 color)
277  {
278  return ((color >> 10)&0x1F);
279  }
280 
281 
283 
284  inline u32 getGreen(u16 color)
285  {
286  return ((color >> 5)&0x1F);
287  }
288 
289 
291 
292  inline u32 getBlue(u16 color)
293  {
294  return (color & 0x1F);
295  }
296 
297 
299  inline s32 getAverage(s16 color)
300  {
301  return ((getRed(color)<<3) + (getGreen(color)<<3) + (getBlue(color)<<3)) / 3;
302  }
303 
304 
306 
314  class SColor
315  {
316  public:
317 
319 
320  SColor() {}
321 
323 
324  SColor (u32 a, u32 r, u32 g, u32 b)
325  : color(((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)) {}
326 
328  SColor(u32 clr)
329  : color(clr) {}
330 
332 
334  u32 getAlpha() const { return color>>24; }
335 
337 
339  u32 getRed() const { return (color>>16) & 0xff; }
340 
342 
344  u32 getGreen() const { return (color>>8) & 0xff; }
345 
347 
349  u32 getBlue() const { return color & 0xff; }
350 
353  {
355  }
356 
359  {
360  return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue();
361  }
362 
364  u32 getAverage() const
365  {
366  return ( getRed() + getGreen() + getBlue() ) / 3;
367  }
368 
370 
372  void setAlpha(u32 a) { color = ((a & 0xff)<<24) | (color & 0x00ffffff); }
373 
375 
377  void setRed(u32 r) { color = ((r & 0xff)<<16) | (color & 0xff00ffff); }
378 
380 
382  void setGreen(u32 g) { color = ((g & 0xff)<<8) | (color & 0xffff00ff); }
383 
385 
387  void setBlue(u32 b) { color = (b & 0xff) | (color & 0xffffff00); }
388 
390 
391  u16 toA1R5G5B5() const { return A8R8G8B8toA1R5G5B5(color); }
392 
394 
397  void toOpenGLColor(u8* dest) const
398  {
399  *dest = (u8)getRed();
400  *++dest = (u8)getGreen();
401  *++dest = (u8)getBlue();
402  *++dest = (u8)getAlpha();
403  }
404 
406 
420  void set(u32 a, u32 r, u32 g, u32 b)
421  {
422  color = (((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff));
423  }
424  void set(u32 col) { color = col; }
425 
427 
428  bool operator==(const SColor& other) const { return other.color == color; }
429 
431 
432  bool operator!=(const SColor& other) const { return other.color != color; }
433 
435 
436  bool operator<(const SColor& other) const { return (color < other.color); }
437 
439 
441  SColor operator+(const SColor& other) const
442  {
443  return SColor(core::min_(getAlpha() + other.getAlpha(), 255u),
444  core::min_(getRed() + other.getRed(), 255u),
445  core::min_(getGreen() + other.getGreen(), 255u),
446  core::min_(getBlue() + other.getBlue(), 255u));
447  }
448 
450 
453  SColor getInterpolated(const SColor &other, f32 d) const
454  {
455  d = core::clamp(d, 0.f, 1.f);
456  const f32 inv = 1.0f - d;
457  return SColor((u32)core::round32(other.getAlpha()*inv + getAlpha()*d),
458  (u32)core::round32(other.getRed()*inv + getRed()*d),
459  (u32)core::round32(other.getGreen()*inv + getGreen()*d),
460  (u32)core::round32(other.getBlue()*inv + getBlue()*d));
461  }
462 
464 
467  SColor getInterpolated_quadratic(const SColor& c1, const SColor& c2, f32 d) const
468  {
469  // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d;
470  d = core::clamp(d, 0.f, 1.f);
471  const f32 inv = 1.f - d;
472  const f32 mul0 = inv * inv;
473  const f32 mul1 = 2.f * d * inv;
474  const f32 mul2 = d * d;
475 
476  return SColor(
478  getAlpha() * mul0 + c1.getAlpha() * mul1 + c2.getAlpha() * mul2 ), 0, 255 ),
480  getRed() * mul0 + c1.getRed() * mul1 + c2.getRed() * mul2 ), 0, 255 ),
482  getGreen() * mul0 + c1.getGreen() * mul1 + c2.getGreen() * mul2 ), 0, 255 ),
484  getBlue() * mul0 + c1.getBlue() * mul1 + c2.getBlue() * mul2 ), 0, 255 ));
485  }
486 
488 
491  void setData(const void *data, ECOLOR_FORMAT format)
492  {
493  switch (format)
494  {
495  case ECF_A1R5G5B5:
496  color = A1R5G5B5toA8R8G8B8(*(u16*)data);
497  break;
498  case ECF_R5G6B5:
499  color = R5G6B5toA8R8G8B8(*(u16*)data);
500  break;
501  case ECF_A8R8G8B8:
502  color = *(u32*)data;
503  break;
504  case ECF_R8G8B8:
505  {
506  u8* p = (u8*)data;
507  set(255, p[0],p[1],p[2]);
508  }
509  break;
510  default:
511  color = 0xffffffff;
512  break;
513  }
514  }
515 
517 
520  void getData(void *data, ECOLOR_FORMAT format) const
521  {
522  switch(format)
523  {
524  case ECF_A1R5G5B5:
525  {
526  u16 * dest = (u16*)data;
527  *dest = video::A8R8G8B8toA1R5G5B5( color );
528  }
529  break;
530 
531  case ECF_R5G6B5:
532  {
533  u16 * dest = (u16*)data;
534  *dest = video::A8R8G8B8toR5G6B5( color );
535  }
536  break;
537 
538  case ECF_R8G8B8:
539  {
540  u8* dest = (u8*)data;
541  dest[0] = (u8)getRed();
542  dest[1] = (u8)getGreen();
543  dest[2] = (u8)getBlue();
544  }
545  break;
546 
547  case ECF_A8R8G8B8:
548  {
549  u32 * dest = (u32*)data;
550  *dest = color;
551  }
552  break;
553 
554  default:
555  break;
556  }
557  }
558 
561  };
562 
563 
565 
571  class SColorf
572  {
573  public:
575 
576  SColorf() : r(0.0f), g(0.0f), b(0.0f), a(1.0f) {}
577 
579 
589  SColorf(f32 r, f32 g, f32 b, f32 a = 1.0f) : r(r), g(g), b(b), a(a) {}
590 
592 
595  {
596  const f32 inv = 1.0f / 255.0f;
597  r = c.getRed() * inv;
598  g = c.getGreen() * inv;
599  b = c.getBlue() * inv;
600  a = c.getAlpha() * inv;
601  }
602 
604  SColor toSColor() const
605  {
606  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));
607  }
608 
610 
616  void set(f32 rr, f32 gg, f32 bb) {r = rr; g =gg; b = bb; }
617 
619 
627  void set(f32 aa, f32 rr, f32 gg, f32 bb) {a = aa; r = rr; g =gg; b = bb; }
628 
630 
633  SColorf getInterpolated(const SColorf &other, f32 d) const
634  {
635  d = core::clamp(d, 0.f, 1.f);
636  const f32 inv = 1.0f - d;
637  return SColorf(other.r*inv + r*d,
638  other.g*inv + g*d, other.b*inv + b*d, other.a*inv + a*d);
639  }
640 
642 
645  inline SColorf getInterpolated_quadratic(const SColorf& c1, const SColorf& c2,
646  f32 d) const
647  {
648  d = core::clamp(d, 0.f, 1.f);
649  // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d;
650  const f32 inv = 1.f - d;
651  const f32 mul0 = inv * inv;
652  const f32 mul1 = 2.f * d * inv;
653  const f32 mul2 = d * d;
654 
655  return SColorf (r * mul0 + c1.r * mul1 + c2.r * mul2,
656  g * mul0 + c1.g * mul1 + c2.g * mul2,
657  b * mul0 + c1.b * mul1 + c2.b * mul2,
658  a * mul0 + c1.a * mul1 + c2.a * mul2);
659  }
660 
661 
663  void setColorComponentValue(s32 index, f32 value)
664  {
665  switch(index)
666  {
667  case 0: r = value; break;
668  case 1: g = value; break;
669  case 2: b = value; break;
670  case 3: a = value; break;
671  }
672  }
673 
675  f32 getAlpha() const { return a; }
676 
678  f32 getRed() const { return r; }
679 
681  f32 getGreen() const { return g; }
682 
684  f32 getBlue() const { return b; }
685 
688 
691 
694 
697  };
698 
699 
701 
705  class SColorHSL
706  {
707  public:
708  SColorHSL ( f32 h = 0.f, f32 s = 0.f, f32 l = 0.f )
709  : Hue ( h ), Saturation ( s ), Luminance ( l ) {}
710 
711  void fromRGB(const SColorf &color);
712  void toRGB(SColorf &color) const;
713 
717 
718  private:
719  inline f32 toRGB1(f32 rm1, f32 rm2, f32 rh) const;
720 
721  };
722 
723  inline void SColorHSL::fromRGB(const SColorf &color)
724  {
725  const f32 maxVal = core::max_(color.getRed(), color.getGreen(), color.getBlue());
726  const f32 minVal = (f32)core::min_(color.getRed(), color.getGreen(), color.getBlue());
727  Luminance = (maxVal+minVal)*50;
728  if (core::equals(maxVal, minVal))
729  {
730  Hue=0.f;
731  Saturation=0.f;
732  return;
733  }
734 
735  const f32 delta = maxVal-minVal;
736  if ( Luminance <= 50 )
737  {
738  Saturation = (delta)/(maxVal+minVal);
739  }
740  else
741  {
742  Saturation = (delta)/(2-maxVal-minVal);
743  }
744  Saturation *= 100;
745 
746  if (core::equals(maxVal, color.getRed()))
747  Hue = (color.getGreen()-color.getBlue())/delta;
748  else if (core::equals(maxVal, color.getGreen()))
749  Hue = 2+((color.getBlue()-color.getRed())/delta);
750  else // blue is max
751  Hue = 4+((color.getRed()-color.getGreen())/delta);
752 
753  Hue *= 60.0f;
754  while ( Hue < 0.f )
755  Hue += 360;
756  }
757 
758 
759  inline void SColorHSL::toRGB(SColorf &color) const
760  {
761  const f32 l = Luminance/100;
762  if (core::iszero(Saturation)) // grey
763  {
764  color.set(l, l, l);
765  return;
766  }
767 
768  f32 rm2;
769 
770  if ( Luminance <= 50 )
771  {
772  rm2 = l + l * (Saturation/100);
773  }
774  else
775  {
776  rm2 = l + (1 - l) * (Saturation/100);
777  }
778 
779  const f32 rm1 = 2.0f * l - rm2;
780 
781  const f32 h = Hue / 360.0f;
782  color.set( toRGB1(rm1, rm2, h + 1.f/3.f),
783  toRGB1(rm1, rm2, h),
784  toRGB1(rm1, rm2, h - 1.f/3.f)
785  );
786  }
787 
788 
789  // algorithm from Foley/Van-Dam
790  inline f32 SColorHSL::toRGB1(f32 rm1, f32 rm2, f32 rh) const
791  {
792  if (rh<0)
793  rh += 1;
794  if (rh>1)
795  rh -= 1;
796 
797  if (rh < 1.f/6.f)
798  rm1 = rm1 + (rm2 - rm1) * rh*6.f;
799  else if (rh < 0.5f)
800  rm1 = rm2;
801  else if (rh < 2.f/3.f)
802  rm1 = rm1 + (rm2 - rm1) * ((2.f/3.f)-rh)*6.f;
803 
804  return rm1;
805  }
806 
807 } // end namespace video
808 } // end namespace irr
809 
810 #endif
24 bit color, no alpha channel, but 8 bit for red, green and blue.
Definition: SColor.h:32
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:675
u16 RGB16(u32 r, u32 g, u32 b)
Creates a 16 bit A1R5G5B5 color.
Definition: SColor.h:183
REALINLINE s32 round32(f32 x)
Definition: irrMath.h:718
void setBlue(u32 b)
Sets the blue component of the Color.
Definition: SColor.h:387
u32 getAlpha() const
Returns the alpha component of the color.
Definition: SColor.h:334
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:616
f32 b
blue component
Definition: SColor.h:693
16 bit format using 16 bits for depth.
Definition: SColor.h:121
DXT3 color format.
Definition: SColor.h:47
PVRTC RGB 4bpp.
Definition: SColor.h:62
f32 g
green color component
Definition: SColor.h:690
DXT4 color format.
Definition: SColor.h:50
64 bit format using 32 bits for the red and green channels.
Definition: SColor.h:99
SColor getInterpolated(const SColor &other, f32 d) const
Interpolates the color with a f32 value to another color.
Definition: SColor.h:453
SColor operator+(const SColor &other) const
Adds two colors, result is clamped to 0..255 values.
Definition: SColor.h:441
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:134
u32 getGreen() const
Returns the green component of the color.
Definition: SColor.h:344
void setRed(u32 r)
Sets the red component of the Color.
Definition: SColor.h:377
64 bit format using 16 bits for the red, green, blue and alpha channels.
Definition: SColor.h:93
32 bit format using 32 bits for the red channel.
Definition: SColor.h:96
char c8
8 bit character variable.
Definition: irrTypes.h:35
void toRGB(SColorf &color) const
Definition: SColor.h:759
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:173
f32 getLightness() const
Get lightness of the color in the range [0,255].
Definition: SColor.h:352
void set(u32 a, u32 r, u32 g, u32 b)
Sets all four components of the color at once.
Definition: SColor.h:420
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
u32 A1R5G5B5toA8R8G8B8(u16 color)
Convert A8R8G8B8 Color from A1R5G5B5 color.
Definition: SColor.h:230
16 bit format using 16 bits for the red channel.
Definition: SColor.h:87
32 bit format using 24 bits for depth and 8 bits for stencil.
Definition: SColor.h:127
PVRTC RGB 2bpp.
Definition: SColor.h:56
void set(u32 col)
Definition: SColor.h:424
void toOpenGLColor(u8 *dest) const
Converts color to OpenGL color format.
Definition: SColor.h:397
u16 RGB16from16(u16 r, u16 g, u16 b)
Creates a 16bit A1R5G5B5 color, based on 16bit input values.
Definition: SColor.h:190
void setAlpha(u32 a)
Sets the alpha component of the Color.
Definition: SColor.h:372
SColorHSL(f32 h=0.f, f32 s=0.f, f32 l=0.f)
Definition: SColor.h:708
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:645
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:491
f32 a
alpha color component
Definition: SColor.h:696
SColor()
Constructor of the Color. Does nothing.
Definition: SColor.h:320
PVRTC2 ARGB 4bpp.
Definition: SColor.h:71
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:663
bool operator<(const SColor &other) const
comparison operator
Definition: SColor.h:436
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
u16 R5G6B5toA1R5G5B5(u16 color)
Returns A1R5G5B5 Color from R5G6B5 color.
Definition: SColor.h:251
f32 getBlue() const
Returns the blue component of the color in the range 0.0 to 1.0.
Definition: SColor.h:684
f32 getRed() const
Returns the red component of the color in the range 0.0 to 1.0.
Definition: SColor.h:678
u32 getAlpha(u16 color)
Returns the alpha component from A1R5G5B5 color.
Definition: SColor.h:268
Unknown color format:
Definition: SColor.h:130
128 bit format using 32 bits for the red, green, blue and alpha channels.
Definition: SColor.h:102
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:107
SColor toSColor() const
Converts this color to a SColor without floats.
Definition: SColor.h:604
u16 A1R5G5B5toR5G6B5(u16 color)
Returns R5G6B5 Color from A1R5G5B5 color.
Definition: SColor.h:258
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:44
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:324
PVRTC2 ARGB 2bpp.
Definition: SColor.h:68
void setGreen(u32 g)
Sets the green component of the Color.
Definition: SColor.h:382
void set(f32 aa, f32 rr, f32 gg, f32 bb)
Sets all four color components to new values at once.
Definition: SColor.h:627
bool operator==(const SColor &other) const
Compares the color to another color.
Definition: SColor.h:428
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:432
s32 getAverage(s16 color)
Returns the average from a 16 bit A1R5G5B5 color.
Definition: SColor.h:299
u16 toA1R5G5B5() const
Calculates a 16 bit A1R5G5B5 value of this color.
Definition: SColor.h:391
u16 X8R8G8B8toA1R5G5B5(u32 color)
Converts a 32bit (X8R8G8B8) color to a 16bit A1R5G5B5 color.
Definition: SColor.h:200
16 bit format using 16 bits for the red channel.
Definition: SColor.h:113
Class representing a 32 bit ARGB color.
Definition: SColor.h:314
32 bit format using 16 bits for the red and green channels.
Definition: SColor.h:116
void getData(void *data, ECOLOR_FORMAT format) const
Write the color to data in the defined format.
Definition: SColor.h:520
f32 getLuminance() const
Get luminance of the color in the range [0,255].
Definition: SColor.h:358
u32 getGreen(u16 color)
Returns the green component from A1R5G5B5 color.
Definition: SColor.h:284
DXT5 color format.
Definition: SColor.h:53
u16 A8R8G8B8toR5G6B5(u32 color)
Converts a 32bit (A8R8G8B8) color to a 16bit R5G6B5 color.
Definition: SColor.h:220
Standard 16 bit color format.
Definition: SColor.h:29
u32 getBlue(u16 color)
Returns the blue component from A1R5G5B5 color.
Definition: SColor.h:292
u16 A8R8G8B8toA1R5G5B5(u32 color)
Converts a 32bit (A8R8G8B8) color to a 16bit A1R5G5B5 color.
Definition: SColor.h:210
SColorf()
Default constructor for SColorf.
Definition: SColor.h:576
f32 getGreen() const
Returns the green component of the color in the range 0.0 to 1.0.
Definition: SColor.h:681
ETC1 RGB.
Definition: SColor.h:74
SColorf(SColor c)
Constructs a color from 32 bit Color.
Definition: SColor.h:594
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:589
f32 r
red color component
Definition: SColor.h:687
DXT1 color format.
Definition: SColor.h:41
32 bit format using 32 bits for depth.
Definition: SColor.h:124
REALINLINE s32 floor32(f32 x)
Definition: irrMath.h:653
SColorf getInterpolated(const SColorf &other, f32 d) const
Interpolates the color with a f32 value to another color.
Definition: SColor.h:633
u32 getRed(u16 color)
Returns the red component from A1R5G5B5 color.
Definition: SColor.h:276
Class representing a color in HSL format.
Definition: SColor.h:705
SColor(u32 clr)
Constructs the color from a 32 bit value. Could be another color.
Definition: SColor.h:328
Class representing a color with four floats.
Definition: SColor.h:571
u32 getRed() const
Returns the red component of the color.
Definition: SColor.h:339
32 bit format using 16 bits for the red and green channels.
Definition: SColor.h:90
16 bit format using 8 bits for the red and green channels.
Definition: SColor.h:110
u32 getBlue() const
Returns the blue component of the color.
Definition: SColor.h:349
u32 getAverage() const
Get average intensity of the color in the range [0,255].
Definition: SColor.h:364
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:65
u32 color
color in A8R8G8B8 Format
Definition: SColor.h:560
SColor getInterpolated_quadratic(const SColor &c1, const SColor &c2, f32 d) const
Returns interpolated color. ( quadratic )
Definition: SColor.h:467
PVRTC ARGB 2bpp.
Definition: SColor.h:59
u32 R5G6B5toA8R8G8B8(u16 color)
Returns A8R8G8B8 Color from R5G6B5 color.
Definition: SColor.h:241
void fromRGB(const SColorf &color)
Definition: SColor.h:723