Saga3D API Documentation  1.0-RC4
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 "enumType.hpp"
9 #include "EPixelFormat.h"
10 #include "SagaConfig.h"
11 #include <glm/gtx/extended_min_max.hpp>
12 #include <glm/gtc/constants.hpp>
13 #include <glm/gtc/epsilon.hpp>
14 #include <glm/vec4.hpp>
15 
16 namespace saga
17 {
18 namespace video
19 {
21 
27  {
28  "RGBA8",
29  "RGB8",
30  "RGBA4",
31  "R5G6B5",
32  "R5G5B5A1",
33  "R10G10B10A2",
34  "RGBA32F",
35  "RGBA16F",
36  "R32F",
37  "R16F",
38  "L8",
39  "DXT1",
40  "DXT3",
41  "DXT5",
42  "DEPTH",
43  "DEPTH_STENCIL",
44  "PVRTC2_RGB",
45  "PVRTC4_RGB",
46  "PVRTC2_RGBA",
47  "PVRTC4_RGBA",
48  "ETC2_RGB8",
49  "ETC2_SRGB8",
50  "UNKNOWN",
51  0
52  };
53 
54 
56  inline std::uint16_t RGBA16(std::uint32_t r, std::uint32_t g, std::uint32_t b, std::uint32_t a= 0xFF)
57  {
58  return (std::uint16_t)((a & 0x80) << 8 |
59  (r & 0xF8) << 7 |
60  (g & 0xF8) << 2 |
61  (b & 0xF8) >> 3);
62  }
63 
64 
66  inline std::uint16_t RGB16(std::uint32_t r, std::uint32_t g, std::uint32_t b)
67  {
68  return RGBA16(r,g,b);
69  }
70 
71 
73  inline std::uint16_t RGB16from16(std::uint16_t r, std::uint16_t g, std::uint16_t b)
74  {
75  return (0x8000 |
76  (r & 0x1F) << 10 |
77  (g & 0x1F) << 5 |
78  (b & 0x1F));
79  }
80 
81 
83  inline std::uint16_t X8RGB8toA1R5G5B5(std::uint32_t color)
84  {
85  return (std::uint16_t)(0x8000 |
86  (color & 0x00F80000) >> 9 |
87  (color & 0x0000F800) >> 6 |
88  (color & 0x000000F8) >> 3);
89  }
90 
91 
93  inline std::uint16_t A8RGB8toA1R5G5B5(std::uint32_t color)
94  {
95  return (std::uint16_t)((color & 0x80000000) >> 16|
96  (color & 0x00F80000) >> 9 |
97  (color & 0x0000F800) >> 6 |
98  (color & 0x000000F8) >> 3);
99  }
100 
101 
103  inline std::uint16_t A8RGB8toR5G6B5(std::uint32_t color)
104  {
105  return (std::uint16_t)((color & 0x00F80000) >> 8 |
106  (color & 0x0000FC00) >> 5 |
107  (color & 0x000000F8) >> 3);
108  }
109 
110 
112 
113  inline std::uint32_t A1R5G5B5toA8RGB8(std::uint16_t color)
114  {
115  return (((-((std::int32_t) color & 0x00008000) >> (std::int32_t) 31) & 0xFF000000) |
116  ((color & 0x00007C00) << 9) | ((color & 0x00007000) << 4) |
117  ((color & 0x000003E0) << 6) | ((color & 0x00000380) << 1) |
118  ((color & 0x0000001F) << 3) | ((color & 0x0000001C) >> 2)
119  );
120  }
121 
122 
124  inline std::uint32_t R5G6B5toA8RGB8(std::uint16_t color)
125  {
126  return 0xFF000000 |
127  ((color & 0xF800) << 8)|
128  ((color & 0x07E0) << 5)|
129  ((color & 0x001F) << 3);
130  }
131 
132 
134  inline std::uint16_t R5G6B5toA1R5G5B5(std::uint16_t color)
135  {
136  return 0x8000 | (((color & 0xFFC0) >> 1) | (color & 0x1F));
137  }
138 
139 
141  inline std::uint16_t A1R5G5B5toR5G6B5(std::uint16_t color)
142  {
143  return (((color & 0x7FE0) << 1) | (color & 0x1F));
144  }
145 
146 
147 
149 
151  inline std::uint32_t getAlpha(std::uint16_t color)
152  {
153  return ((color >> 15)&0x1);
154  }
155 
156 
158 
159  inline std::uint32_t getRed(std::uint16_t color)
160  {
161  return ((color >> 10)&0x1F);
162  }
163 
164 
166 
167  inline std::uint32_t getGreen(std::uint16_t color)
168  {
169  return ((color >> 5)&0x1F);
170  }
171 
172 
174 
175  inline std::uint32_t getBlue(std::uint16_t color)
176  {
177  return (color & 0x1F);
178  }
179 
180 
182  inline std::int32_t getAverage(std::int16_t color)
183  {
184  return ((getRed(color)<<3) + (getGreen(color)<<3) + (getBlue(color)<<3)) / 3;
185  }
186 
187 
189 
197  class SColor
198  {
199  public:
200 
202 
203  SColor() {}
204 
206 
207  SColor (std::uint32_t a, std::uint32_t r, std::uint32_t g, std::uint32_t b)
208  : color(((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)) {}
209 
211  SColor(std::uint32_t clr)
212  : color(clr) {}
213 
215 
217  std::uint32_t getAlpha() const { return color>>24; }
218 
220 
222  std::uint32_t getRed() const { return (color>>16) & 0xff; }
223 
225 
227  std::uint32_t getGreen() const { return (color>>8) & 0xff; }
228 
230 
232  std::uint32_t getBlue() const { return color & 0xff; }
233 
235  float getLightness() const
236  {
237  return 0.5f*(glm::max(glm::max(getRed(),getGreen()),getBlue())+glm::min(glm::min(getRed(),getGreen()),getBlue()));
238  }
239 
241  float getLuminance() const
242  {
243  return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue();
244  }
245 
247  std::uint32_t getAverage() const
248  {
249  return (getRed() + getGreen() + getBlue()) / 3;
250  }
251 
253 
255  void setAlpha(std::uint32_t a) { color = ((a & 0xff)<<24) | (color & 0x00ffffff); }
256 
258 
260  void setRed(std::uint32_t r) { color = ((r & 0xff)<<16) | (color & 0xff00ffff); }
261 
263 
265  void setGreen(std::uint32_t g) { color = ((g & 0xff)<<8) | (color & 0xffff00ff); }
266 
268 
270  void setBlue(std::uint32_t b) { color = (b & 0xff) | (color & 0xffffff00); }
271 
273 
274  std::uint16_t toA1R5G5B5() const { return A8RGB8toA1R5G5B5(color); }
275 
277 
280  void toOpenGLColor(std::uint8_t* dest) const
281  {
282  *dest = (std::uint8_t)getRed();
283  *++dest = (std::uint8_t)getGreen();
284  *++dest = (std::uint8_t)getBlue();
285  *++dest = (std::uint8_t)getAlpha();
286  }
287 
288  glm::uvec4 toGLM() const { return {getRed(), getGreen(), getBlue(), getAlpha()}; }
289 
291 
305  void set(std::uint32_t a, std::uint32_t r, std::uint32_t g, std::uint32_t b)
306  {
307  color = (((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff));
308  }
309  void set(std::uint32_t col) { color = col; }
310 
312 
313  bool operator==(const SColor& other) const { return other.color == color; }
314 
316 
317  bool operator!=(const SColor& other) const { return other.color != color; }
318 
320 
321  bool operator<(const SColor& other) const { return (color < other.color); }
322 
324 
326  SColor operator+(const SColor& other) const
327  {
328  return SColor(glm::min(getAlpha() + other.getAlpha(), 255u),
329  glm::min(getRed() + other.getRed(), 255u),
330  glm::min(getGreen() + other.getGreen(), 255u),
331  glm::min(getBlue() + other.getBlue(), 255u));
332  }
333 
335 
338  SColor getInterpolated(const SColor &other, float d) const
339  {
340  d = glm::clamp(d, 0.f, 1.f);
341  const float inv = 1.0f - d;
342  return SColor((std::uint32_t)glm::round(other.getAlpha()*inv + getAlpha()*d),
343  (std::uint32_t)glm::round(other.getRed()*inv + getRed()*d),
344  (std::uint32_t)glm::round(other.getGreen()*inv + getGreen()*d),
345  (std::uint32_t)glm::round(other.getBlue()*inv + getBlue()*d));
346  }
347 
349 
352  SColor getInterpolated_quadratic(const SColor& c1, const SColor& c2, float d) const
353  {
354  // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d;
355  d = glm::clamp(d, 0.f, 1.f);
356  const float inv = 1.f - d;
357  const float mul0 = inv * inv;
358  const float mul1 = 2.f * d * inv;
359  const float mul2 = d * d;
360 
361  return SColor(
362  glm::clamp((int) glm::floor(
363  getAlpha() * mul0 + c1.getAlpha() * mul1 + c2.getAlpha() * mul2), 0, 255),
364  glm::clamp((int) glm::floor(
365  getRed() * mul0 + c1.getRed() * mul1 + c2.getRed() * mul2), 0, 255),
366  glm::clamp((int) glm::floor(
367  getGreen() * mul0 + c1.getGreen() * mul1 + c2.getGreen() * mul2), 0, 255),
368  glm::clamp((int) glm::floor(
369  getBlue() * mul0 + c1.getBlue() * mul1 + c2.getBlue() * mul2), 0, 255));
370  }
371 
373 
376  void setData(const void* data, E_PIXEL_FORMAT format)
377  {
378  switch (format)
379  {
381  color = R5G6B5toA8RGB8(*(std::uint16_t*)data);
382  break;
384  color = *(std::uint32_t*)data;
385  break;
387  {
388  std::uint8_t* p = (std::uint8_t*)data;
389  set(255, p[0],p[1],p[2]);
390  }
391  break;
392  default:
393  color = 0xffffffff;
394  break;
395  }
396  }
397 
399 
402  void getData(void* data, E_PIXEL_FORMAT format) const
403  {
404  switch(format)
405  {
407  {
408  std::uint16_t * dest = (std::uint16_t*)data;
409  *dest = video::A8RGB8toR5G6B5(color);
410  }
411  break;
412 
414  {
415  std::uint8_t* dest = (std::uint8_t*)data;
416  dest[0] = (std::uint8_t)getRed();
417  dest[1] = (std::uint8_t)getGreen();
418  dest[2] = (std::uint8_t)getBlue();
419  }
420  break;
421 
423  {
424  std::uint32_t * dest = (std::uint32_t*)data;
425  *dest = color;
426  }
427  break;
428 
429  default:
430  break;
431  }
432  }
433 
435  std::uint32_t color;
436  };
437 
438 
440 
446  class SColorf
447  {
448  public:
450 
451  SColorf() : r(0.0f), g(0.0f), b(0.0f), a(1.0f) {}
452 
454 
464  SColorf(float r, float g, float b, float a = 1.0f) : r(r), g(g), b(b), a(a) {}
465 
467 
470  {
471  const float inv = 1.0f / 255.0f;
472  r = c.getRed() * inv;
473  g = c.getGreen() * inv;
474  b = c.getBlue() * inv;
475  a = c.getAlpha() * inv;
476  }
477 
479  SColor toSColor() const
480  {
481  return SColor((std::uint32_t)glm::round(a*255.0f), (std::uint32_t)glm::round(r*255.0f), (std::uint32_t)glm::round(g*255.0f), (std::uint32_t)glm::round(b*255.0f));
482  }
483 
485 
491  void set(float rr, float gg, float bb) {r = rr; g =gg; b = bb; }
492 
494 
502  void set(float aa, float rr, float gg, float bb) {a = aa; r = rr; g =gg; b = bb; }
503 
505 
508  SColorf getInterpolated(const SColorf &other, float d) const
509  {
510  d = glm::clamp(d, 0.f, 1.f);
511  const float inv = 1.0f - d;
512  return SColorf(other.r*inv + r*d,
513  other.g*inv + g*d, other.b*inv + b*d, other.a*inv + a*d);
514  }
515 
517 
520  inline SColorf getInterpolated_quadratic(const SColorf& c1, const SColorf& c2,
521  float d) const
522  {
523  d = glm::clamp(d, 0.f, 1.f);
524  // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d;
525  const float inv = 1.f - d;
526  const float mul0 = inv * inv;
527  const float mul1 = 2.f * d * inv;
528  const float mul2 = d * d;
529 
530  return SColorf (r * mul0 + c1.r * mul1 + c2.r * mul2,
531  g * mul0 + c1.g * mul1 + c2.g * mul2,
532  b * mul0 + c1.b * mul1 + c2.b * mul2,
533  a * mul0 + c1.a * mul1 + c2.a * mul2);
534  }
535 
536 
538  void setColorComponentValue(std::int32_t index, float value)
539  {
540  switch(index)
541  {
542  case 0: r = value; break;
543  case 1: g = value; break;
544  case 2: b = value; break;
545  case 3: a = value; break;
546  }
547  }
548 
550  float getAlpha() const { return a; }
551 
553  float getRed() const { return r; }
554 
556  float getGreen() const { return g; }
557 
559  float getBlue() const { return b; }
560 
562  float r;
563 
565  float g;
566 
568  float b;
569 
571  float a;
572  };
573 
574 
576 
580  class SColorHSL
581  {
582  public:
583  SColorHSL (float h = 0.f, float s = 0.f, float l = 0.f)
584  : Hue (h), Saturation (s), Luminance (l) {}
585 
586  void fromRGB(const SColorf &color);
587  void toRGB(SColorf &color) const;
588 
589  float Hue;
590  float Saturation;
591  float Luminance;
592 
593  private:
594  inline float toRGB1(float rm1, float rm2, float rh) const;
595 
596  };
597 
598  inline void SColorHSL::fromRGB(const SColorf &color)
599  {
600  const float maxVal = glm::max(color.getRed(), color.getGreen(), color.getBlue());
601  const float minVal = (float) glm::min(color.getRed(), color.getGreen(), color.getBlue());
602  Luminance = (maxVal+minVal)*50;
603  if (glm::epsilonEqual(maxVal, minVal, glm::epsilon<float>()))
604  {
605  Hue= 0.f;
606  Saturation= 0.f;
607  return;
608  }
609 
610  const float delta = maxVal-minVal;
611  if (Luminance <= 50)
612  {
613  Saturation = (delta)/(maxVal+minVal);
614  }
615  else
616  {
617  Saturation = (delta)/(2-maxVal-minVal);
618  }
619  Saturation *= 100;
620 
621  if (glm::epsilonEqual(maxVal, color.getRed(), glm::epsilon<float>()))
622  Hue = (color.getGreen()-color.getBlue())/delta;
623  else if (glm::epsilonEqual(maxVal, color.getGreen(), glm::epsilon<float>()))
624  Hue = 2+((color.getBlue()-color.getRed())/delta);
625  else // blue is max
626  Hue = 4+((color.getRed()-color.getGreen())/delta);
627 
628  Hue *= 60.0f;
629  while (Hue < 0.f)
630  Hue += 360;
631  }
632 
633 
634  inline void SColorHSL::toRGB(SColorf &color) const
635  {
636  const float l = Luminance/100;
637  if (glm::abs(Saturation)) // grey
638  {
639  color.set(l, l, l);
640  return;
641  }
642 
643  float rm2;
644 
645  if (Luminance <= 50)
646  {
647  rm2 = l + l * (Saturation/100);
648  }
649  else
650  {
651  rm2 = l + (1 - l) * (Saturation/100);
652  }
653 
654  const float rm1 = 2.0f * l - rm2;
655 
656  const float h = Hue / 360.0f;
657  color.set(toRGB1(rm1, rm2, h + 1.f/3.f),
658  toRGB1(rm1, rm2, h),
659  toRGB1(rm1, rm2, h - 1.f/3.f)
660  );
661  }
662 
663 
664  // algorithm from Foley/Van-Dam
665  inline float SColorHSL::toRGB1(float rm1, float rm2, float rh) const
666  {
667  if (rh<0)
668  rh += 1;
669  if (rh>1)
670  rh -= 1;
671 
672  if (rh < 1.f/6.f)
673  rm1 = rm1 + (rm2 - rm1) * rh*6.f;
674  else if (rh < 0.5f)
675  rm1 = rm2;
676  else if (rh < 2.f/3.f)
677  rm1 = rm1 + (rm2 - rm1) * ((2.f/3.f)-rh)*6.f;
678 
679  return rm1;
680  }
681 
682 } // namespace video
683 } // namespace saga
684 
685 #endif
saga::video::SColor::setAlpha
void setAlpha(std::uint32_t a)
Sets the alpha component of the Color.
Definition: SColor.h:255
saga::video::SColorf::SColorf
SColorf(SColor c)
Constructs a color from 32 bit Color.
Definition: SColor.h:469
saga::video::E_PIXEL_FORMAT::RGB8
@ RGB8
saga::video::SColorHSL::fromRGB
void fromRGB(const SColorf &color)
Definition: SColor.h:598
saga::core::enumToPOD
constexpr auto enumToPOD(E e) noexcept
Definition: enumType.hpp:13
saga::video::RGB16from16
std::uint16_t RGB16from16(std::uint16_t r, std::uint16_t g, std::uint16_t b)
Creates a 16bit A1R5G5B5 color, based on 16bit input values.
Definition: SColor.h:73
saga::video::SColor::getAlpha
std::uint32_t getAlpha() const
Returns the alpha component of the color.
Definition: SColor.h:217
saga::video::SColorf::r
float r
red color component
Definition: SColor.h:562
EPixelFormat.h
saga::video::SColorf::getAlpha
float getAlpha() const
Returns the alpha component of the color in the range 0.0 (transparent) to 1.0 (opaque)
Definition: SColor.h:550
saga::video::SColorf::SColorf
SColorf(float r, float g, float b, float a=1.0f)
Constructs a color from up to four color values: red, green, blue, and alpha.
Definition: SColor.h:464
saga::video::SColorf::getGreen
float getGreen() const
Returns the green component of the color in the range 0.0 to 1.0.
Definition: SColor.h:556
saga::video::A1R5G5B5toR5G6B5
std::uint16_t A1R5G5B5toR5G6B5(std::uint16_t color)
Returns R5G6B5 Color from A1R5G5B5 color.
Definition: SColor.h:141
saga::video::SColorHSL
Class representing a color in HSL format.
Definition: SColor.h:580
saga::video::SColorf::getInterpolated_quadratic
SColorf getInterpolated_quadratic(const SColorf &c1, const SColorf &c2, float d) const
Returns interpolated color. (quadratic)
Definition: SColor.h:520
saga::video::SColorHSL::SColorHSL
SColorHSL(float h=0.f, float s=0.f, float l=0.f)
Definition: SColor.h:583
saga::video::SColorf
Class representing a color with four floats.
Definition: SColor.h:446
saga::video::A8RGB8toA1R5G5B5
std::uint16_t A8RGB8toA1R5G5B5(std::uint32_t color)
Converts a 32bit (A8RGB8) color to a 16bit A1R5G5B5 color.
Definition: SColor.h:93
saga::video::SColorf::setColorComponentValue
void setColorComponentValue(std::int32_t index, float value)
Sets a color component by index. R= 0, G=1, B=2, A=3.
Definition: SColor.h:538
saga::video::SColorHSL::toRGB
void toRGB(SColorf &color) const
Definition: SColor.h:634
saga::video::SColor::setBlue
void setBlue(std::uint32_t b)
Sets the blue component of the Color.
Definition: SColor.h:270
saga::video::RGB16
std::uint16_t RGB16(std::uint32_t r, std::uint32_t g, std::uint32_t b)
Creates a 16 bit A1R5G5B5 color.
Definition: SColor.h:66
saga::video::SColor::getData
void getData(void *data, E_PIXEL_FORMAT format) const
Write the color to data in the defined format.
Definition: SColor.h:402
saga::video::SColor::operator+
SColor operator+(const SColor &other) const
Adds two colors, result is clamped to 0..255 values.
Definition: SColor.h:326
saga::video::RGBA16
std::uint16_t RGBA16(std::uint32_t r, std::uint32_t g, std::uint32_t b, std::uint32_t a=0xFF)
Creates a 16 bit A1R5G5B5 color.
Definition: SColor.h:56
saga::video::SColorf::getInterpolated
SColorf getInterpolated(const SColorf &other, float d) const
Interpolates the color with a float value to another color.
Definition: SColor.h:508
saga::video::SColorf::getRed
float getRed() const
Returns the red component of the color in the range 0.0 to 1.0.
Definition: SColor.h:553
saga::video::SColor::toOpenGLColor
void toOpenGLColor(std::uint8_t *dest) const
Converts color to OpenGL color format.
Definition: SColor.h:280
saga::video::SColorf::b
float b
blue component
Definition: SColor.h:568
saga::video::SColorf::set
void set(float aa, float rr, float gg, float bb)
Sets all four color components to new values at once.
Definition: SColor.h:502
saga::video::SColor::getInterpolated_quadratic
SColor getInterpolated_quadratic(const SColor &c1, const SColor &c2, float d) const
Returns interpolated color. (quadratic)
Definition: SColor.h:352
saga::video::getAverage
std::int32_t getAverage(std::int16_t color)
Returns the average from a 16 bit A1R5G5B5 color.
Definition: SColor.h:182
saga::video::R5G6B5toA1R5G5B5
std::uint16_t R5G6B5toA1R5G5B5(std::uint16_t color)
Returns A1R5G5B5 Color from R5G6B5 color.
Definition: SColor.h:134
saga::video::getBlue
std::uint32_t getBlue(std::uint16_t color)
Returns the blue component from A1R5G5B5 color.
Definition: SColor.h:175
saga::video::SColorf::SColorf
SColorf()
Default constructor for SColorf.
Definition: SColor.h:451
saga::video::E_PIXEL_FORMAT::RGBA8
@ RGBA8
Vulkan swapchain format.
enumType.hpp
saga::video::SColor::getBlue
std::uint32_t getBlue() const
Returns the blue component of the color.
Definition: SColor.h:232
saga::video::SColor::set
void set(std::uint32_t a, std::uint32_t r, std::uint32_t g, std::uint32_t b)
Sets all four components of the color at once.
Definition: SColor.h:305
saga::video::A1R5G5B5toA8RGB8
std::uint32_t A1R5G5B5toA8RGB8(std::uint16_t color)
Convert A8RGB8 Color from A1R5G5B5 color.
Definition: SColor.h:113
saga::video::SColor::SColor
SColor(std::uint32_t a, std::uint32_t r, std::uint32_t g, std::uint32_t b)
Constructs the color from 4 values representing the alpha, red, green and blue component.
Definition: SColor.h:207
saga::video::getRed
std::uint32_t getRed(std::uint16_t color)
Returns the red component from A1R5G5B5 color.
Definition: SColor.h:159
saga::video::SColorHSL::Luminance
float Luminance
Definition: SColor.h:591
saga::video::SColor::getLightness
float getLightness() const
Get lightness of the color in the range [0,255].
Definition: SColor.h:235
saga::video::SColor::getAverage
std::uint32_t getAverage() const
Get average intensity of the color in the range [0,255].
Definition: SColor.h:247
saga::video::SColor::SColor
SColor()
Constructor of the Color. Does nothing.
Definition: SColor.h:203
saga::video::SColorf::g
float g
green color component
Definition: SColor.h:565
saga::video::getGreen
std::uint32_t getGreen(std::uint16_t color)
Returns the green component from A1R5G5B5 color.
Definition: SColor.h:167
saga::video::X8RGB8toA1R5G5B5
std::uint16_t X8RGB8toA1R5G5B5(std::uint32_t color)
Converts a 32bit (X8RGB8) color to a 16bit A1R5G5B5 color.
Definition: SColor.h:83
saga::video::SColorf::toSColor
SColor toSColor() const
Converts this color to a SColor without floats.
Definition: SColor.h:479
saga::video::SColor::color
std::uint32_t color
color in A8RGB8 Format
Definition: SColor.h:435
saga::video::SColor::set
void set(std::uint32_t col)
Definition: SColor.h:309
saga::video::SColor::setGreen
void setGreen(std::uint32_t g)
Sets the green component of the Color.
Definition: SColor.h:265
saga::video::getAlpha
std::uint32_t getAlpha(std::uint16_t color)
Returns the alpha component from A1R5G5B5 color.
Definition: SColor.h:151
saga::video::SColor::getRed
std::uint32_t getRed() const
Returns the red component of the color.
Definition: SColor.h:222
saga::video::ColorFormatNames
const char *const ColorFormatNames[saga::core::enumToPOD(E_PIXEL_FORMAT::UNKNOWN)+2]
An enum class for the color format of textures used by the Irrlicht Engine.
Definition: SColor.h:26
saga::video::SColor::operator==
bool operator==(const SColor &other) const
Compares the color to another color.
Definition: SColor.h:313
saga::video::E_PIXEL_FORMAT
E_PIXEL_FORMAT
Enumeration for all primitive types there are.
Definition: EPixelFormat.h:10
saga::video::SColor::setRed
void setRed(std::uint32_t r)
Sets the red component of the Color.
Definition: SColor.h:260
saga::video::SColor::setData
void setData(const void *data, E_PIXEL_FORMAT format)
set the color by expecting data in the given format
Definition: SColor.h:376
saga::video::SColor
Class representing a 32 bit ARGB color.
Definition: SColor.h:197
saga::video::SColor::getGreen
std::uint32_t getGreen() const
Returns the green component of the color.
Definition: SColor.h:227
saga::video::SColor::SColor
SColor(std::uint32_t clr)
Constructs the color from a 32 bit value. Could be another color.
Definition: SColor.h:211
saga::video::E_PIXEL_FORMAT::R5G6B5
@ R5G6B5
saga::video::A8RGB8toR5G6B5
std::uint16_t A8RGB8toR5G6B5(std::uint32_t color)
Converts a 32bit (A8RGB8) color to a 16bit R5G6B5 color.
Definition: SColor.h:103
saga::video::SColor::operator!=
bool operator!=(const SColor &other) const
Compares the color to another color.
Definition: SColor.h:317
saga::video::SColor::getInterpolated
SColor getInterpolated(const SColor &other, float d) const
Interpolates the color with a float value to another color.
Definition: SColor.h:338
saga::video::E_PIXEL_FORMAT::UNKNOWN
@ UNKNOWN
saga::video::R5G6B5toA8RGB8
std::uint32_t R5G6B5toA8RGB8(std::uint16_t color)
Returns A8RGB8 Color from R5G6B5 color.
Definition: SColor.h:124
saga::video::SColor::getLuminance
float getLuminance() const
Get luminance of the color in the range [0,255].
Definition: SColor.h:241
saga::video::SColorHSL::Saturation
float Saturation
Definition: SColor.h:590
saga::video::SColorf::getBlue
float getBlue() const
Returns the blue component of the color in the range 0.0 to 1.0.
Definition: SColor.h:559
saga::video::SColor::toA1R5G5B5
std::uint16_t toA1R5G5B5() const
Calculates a 16 bit A1R5G5B5 value of this color.
Definition: SColor.h:274
saga::video::SColorHSL::Hue
float Hue
Definition: SColor.h:589
saga::video::SColor::toGLM
glm::uvec4 toGLM() const
Definition: SColor.h:288
saga::video::SColorf::set
void set(float rr, float gg, float bb)
Sets three color components to new values at once.
Definition: SColor.h:491
saga
Definition: aabbox3d.h:11
saga::core::clamp
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition: irrMath.h:206
saga::video::SColorf::a
float a
alpha color component
Definition: SColor.h:571
saga::video::SColor::operator<
bool operator<(const SColor &other) const
comparison operator
Definition: SColor.h:321