91#ifndef TGX_RGB565_ORDER_BGR
92#define TGX_RGB565_ORDER_BGR 1
95#ifndef TGX_RGB24_ORDER_BGR
96#define TGX_RGB24_ORDER_BGR 0
99#ifndef TGX_RGB32_ORDER_BGR
100#define TGX_RGB32_ORDER_BGR 1
103#ifndef TGX_RGB64_ORDER_BGR
104#define TGX_RGB64_ORDER_BGR 0
107#ifndef TGX_RGBf_ORDER_BGR
108#define TGX_RGBf_ORDER_BGR 0
133template<
typename T>
struct id_color_type
135 static const int value =
136 (std::is_same<T, RGB565>::value) ? 1 : (
137 (std::is_same<T, RGB24>::value) ? 2 : (
138 (std::is_same<T, RGB32>::value) ? 3 : (
139 (std::is_same<T, RGB64>::value) ? 4 : (
140 (std::is_same<T, RGBf>::value) ? 5 : (
141 (std::is_same<T, HSV>::value) ? 6 : 0)))));
148template<
typename T>
struct is_color
150 static const bool value = (id_color_type<T>::value != 0);
219 #if (MTOOLS_TGX_EXTENSIONS)
220 #include <mtools/extensions/tgx/tgx_ext_Color_RGB565.inl>
230#if TGX_RGB565_ORDER_BGR
258 B((uint8_t)b),
G((uint8_t)g),
R((uint8_t)r)
260 R((uint8_t)r),
G((uint8_t)g),
B((uint8_t)b)
293 B((uint8_t)(b * 31)),
294 G((uint8_t)(g * 63)),
297 R((uint8_t)(r * 31)),
298 G((uint8_t)(g * 63)),
375 explicit operator uint16_t&() {
return val; }
381 explicit operator const uint16_t& ()
const {
return val; }
393 explicit operator fVec3()
const {
return fVec3(
R / 31.0f,
G / 63.0f ,
B / 31.0f); }
492 return !(*
this == c);
505 blend256(fg_col, (uint32_t)(alpha * 256));
518 const uint32_t a = (alpha >> 3);
519 const uint32_t bg = (
val | (
val << 16)) & 0b00000111111000001111100000011111;
520 const uint32_t fg = (fg_col.
val | (fg_col.
val << 16)) & 0b00000111111000001111100000011111;
521 const uint32_t result = ((((fg - bg) * a) >> 5) + bg) & 0b00000111111000001111100000011111;
522 val = (uint16_t)((result >> 16) | result);
542 inline void mult256(
int mr,
int mg,
int mb,
int ma)
597 const uint32_t bg1 = (col1.
val | (col1.
val << 16)) & 0b00000111111000001111100000011111;
598 const uint32_t bg2 = (col2.
val | (col2.
val << 16)) & 0b00000111111000001111100000011111;
599 const uint32_t bg3 = (col3.
val | (col3.
val << 16)) & 0b00000111111000001111100000011111;
600 const uint32_t result = ((bg1*C1 + bg2 * C2 + bg3*(32 - C1 - C2)) >> 5) & 0b00000111111000001111100000011111;
601 return RGB565((uint16_t)((result >> 16) | result));
631 const int iax = (int)(ax * 256);
632 const int iay = (int)(ay * 256);
633 const int rax = 256 - iax;
634 const int ray = 256 - iay;
635 const int R = rax*(ray*C00.
R + iay*C01.
R) + iax*(ray*C10.
R + iay*C11.
R);
636 const int G = rax*(ray*C00.
G + iay*C01.
G) + iax*(ray*C10.
G + iay*C11.
G);
637 const int B = rax*(ray*C00.
B + iay*C01.
B) + iax*(ray*C10.
B + iay*C11.
B);
638 return RGB565(R >> 16,G >> 16,B >> 16);
649 return RGB565( ((
int)colA.
R + (
int)colB.
R) >> 1,
650 ((
int)colA.
G + (
int)colB.
G) >> 1,
651 ((
int)colA.
B + (
int)colB.
B) >> 1);
662 return RGB565(((
int)colA.
R + (
int)colB.
R + (
int)colC.
R + (
int)colD.
R) >> 2,
663 ((
int)colA.
G + (
int)colB.
G + (
int)colC.
G + (
int)colD.
G) >> 2,
664 ((
int)colA.
B + (
int)colB.
B + (
int)colC.
B + (
int)colD.
B) >> 2);
685 #if (MTOOLS_TGX_EXTENSIONS)
686 #include <mtools/extensions/tgx/tgx_ext_Color_RGB24.inl>
693#if TGX_RGB24_ORDER_BGR
714 constexpr RGB24(
int r,
int g,
int b) :
716 B((uint8_t)b),
G((uint8_t)g),
R((uint8_t)r)
718 R((uint8_t)r),
G((uint8_t)g),
B((uint8_t)b)
743 B((uint8_t)(b * 255)),
744 G((uint8_t)(g * 255)),
745 R((uint8_t)(r * 255))
747 R((uint8_t)(r * 255)),
748 G((uint8_t)(g * 255)),
749 B((uint8_t)(b * 255))
771 constexpr RGB24(uint8_t * p) :
R(p[0]),
G(p[1]),
B(p[2]) {}
837 explicit operator fVec3()
const {
return fVec3(
R / 255.0f,
G / 255.0f,
B / 255.0f); }
960 R = (uint8_t)(
R * v);
961 G = (uint8_t)(
G * v);
962 B = (uint8_t)(
B * v);
980 R = (uint8_t)(
R / v);
981 G = (uint8_t)(
G / v);
982 B = (uint8_t)(
B / v);
991 return((
R == c.
R) && (
G == c.
G) && (
B == c.
B));
1000 return !(*
this == c);
1013 blend256(fg_col, (uint32_t)(alpha * 256));
1026 const uint16_t a = (uint16_t)alpha;
1027 const uint16_t ia = (uint16_t)(256 - alpha);
1028 R = ((fg_col.
R * a) + (
R * ia)) >> 8;
1029 G = ((fg_col.
G * a) + (
G * ia)) >> 8;
1030 B = ((fg_col.
B * a) + (
B * ia)) >> 8;
1050 inline void mult256(
int mr,
int mg,
int mb,
int ma)
1102 return RGB24((
int)(col3.
R + (C1 * (col1.
R - col3.
R) + C2 * (col2.
R - col3.
R)) / totC),
1103 (
int)(col3.
G + (C1 * (col1.
G - col3.
G) + C2 * (col2.
G - col3.
G)) / totC),
1104 (
int)(col3.
B + (C1 * (col1.
B - col3.
B) + C2 * (col2.
B - col3.
B)) / totC));
1126 const int iax = (int)(ax * 256);
1127 const int iay = (int)(ay * 256);
1128 const int rax = 256 - iax;
1129 const int ray = 256 - iay;
1130 const int R = rax*(ray*C00.
R + iay*C01.
R) + iax*(ray*C10.
R + iay*C11.
R);
1131 const int G = rax*(ray*C00.
G + iay*C01.
G) + iax*(ray*C10.
G + iay*C11.
G);
1132 const int B = rax*(ray*C00.
B + iay*C01.
B) + iax*(ray*C10.
B + iay*C11.
B);
1133 return RGB24(R >> 16,G >> 16,B >> 16);
1142 return RGB24(((
int)colA.
R + (
int)colB.
R) >> 1,
1143 ((
int)colA.
G + (
int)colB.
G) >> 1,
1144 ((
int)colA.
B + (
int)colB.
B) >> 1);
1153 return RGB24(((
int)colA.
R + (
int)colB.
R + (
int)colC.
R + (
int)colD.
R) >> 2,
1154 ((
int)colA.
G + (
int)colB.
G + (
int)colC.
G + (
int)colD.
G) >> 2,
1155 ((
int)colA.
B + (
int)colB.
B + (
int)colC.
B + (
int)colD.
B) >> 2);
1180 #if (MTOOLS_TGX_EXTENSIONS)
1181 #include <mtools/extensions/tgx/tgx_ext_Color_RGB32.inl>
1193#if TGX_RGB32_ORDER_BGR
1220 B((uint8_t)b),
G((uint8_t)g),
R((uint8_t)r),
A((uint8_t)a)
1222 R((uint8_t)r),
G((uint8_t)g),
B((uint8_t)b),
A((uint8_t)a)
1245 RGB32(
float r,
float g,
float b,
float a = -1.0f) :
1247 B((uint8_t)(b * 255)),
1248 G((uint8_t)(g * 255)),
1249 R((uint8_t)(r * 255)),
1250 A((uint8_t)((a < 0.0f) ?
DEFAULT_A : ((uint8_t)roundf(a * 255.0f))))
1252 R((uint8_t)(r * 255.0f)),
1253 G((uint8_t)(g * 255.0f)),
1254 B((uint8_t)(b * 255.0f)),
1255 A((uint8_t)((a < 0.0f) ?
DEFAULT_A : ((uint8_t)roundf(a * 255.0f))))
1332 explicit operator uint32_t&() {
return val; }
1338 explicit operator const uint32_t& ()
const {
return val; }
1350 explicit operator fVec3()
const {
return fVec3(
R / 255.0f,
G / 255.0f,
B / 255.0f); }
1362 explicit operator fVec4()
const {
return fVec4(
R / 255.0f,
G / 255.0f,
B / 255.0f,
A / 255.0f); }
1490 R = (uint8_t)(
R * v);
1491 G = (uint8_t)(
G * v);
1492 B = (uint8_t)(
B * v);
1493 A = (uint8_t)(
A * v);
1512 R = (uint8_t)(
R / v);
1513 G = (uint8_t)(
G / v);
1514 B = (uint8_t)(
B / v);
1515 A = (uint8_t)(
A / v);
1533 return !(*
this == c);
1548 blend256(fg_col, (uint32_t)(alpha * 256));
1566 const uint32_t inv_alpha = (65536 - (alpha * (fg_col.
A + (fg_col.
A > 127)))) >> 8;
1567 const uint32_t ag = ((fg_col.
val & 0xFF00FF00) >> 8)*alpha + ((
val & 0xFF00FF00) >> 8)*inv_alpha;
1568 const uint32_t rb = (fg_col.
val & 0x00FF00FF) * alpha + (
val & 0x00FF00FF) * inv_alpha;
1569 val = (ag & 0xFF00FF00) | ((rb >> 8) & 0x00FF00FF);
1601 inline void mult256(
int mr,
int mg,
int mb,
int ma)
1619 R = (uint8_t)((((uint16_t)
R) *
A) / 255);
1620 G = (uint8_t)((((uint16_t)
G) *
A) / 255);
1621 B = (uint8_t)((((uint16_t)
B) *
A) / 255);
1631 return (((
float)
A)/ 255.0f);
1645 float mo = op * 255.0f;
1646 float mult = (
A == 0) ? 0.0f : (mo / ((
float)
A));
1647 (*this) =
RGB32((
int)(
R * mult), (
int)(
G * mult), (
int)(
B * mult), (
int)mo);
1670 uint32_t o = (uint32_t)(256 * op);
1671 uint32_t ag = (
val & 0xFF00FF00) >> 8;
1672 uint32_t rb =
val & 0x00FF00FF;
1673 uint32_t sag = o * ag;
1674 uint32_t srb = o * rb;
1675 sag = sag & 0xFF00FF00;
1676 srb = (srb >> 8) & 0x00FF00FF;
1677 return RGB32(sag | srb);
1713 return RGB32((
int)(col3.
R + (C1 * (col1.
R - col3.
R) + C2 * (col2.
R - col3.
R)) / totC),
1714 (
int)(col3.
G + (C1 * (col1.
G - col3.
G) + C2 * (col2.
G - col3.
G)) / totC),
1715 (
int)(col3.
B + (C1 * (col1.
B - col3.
B) + C2 * (col2.
B - col3.
B)) / totC),
1716 (
int)(col3.
A + (C1 * (col1.
A - col3.
A) + C2 * (col2.
A - col3.
A)) / totC));
1738 const int iax = (int)(ax * 256);
1739 const int iay = (int)(ay * 256);
1740 const int rax = 256 - iax;
1741 const int ray = 256 - iay;
1742 const int R = rax*(ray*C00.
R + iay*C01.
R) + iax*(ray*C10.
R + iay*C11.
R);
1743 const int G = rax*(ray*C00.
G + iay*C01.
G) + iax*(ray*C10.
G + iay*C11.
G);
1744 const int B = rax*(ray*C00.
B + iay*C01.
B) + iax*(ray*C10.
B + iay*C11.
B);
1745 const int A = rax*(ray*C00.
A + iay*C01.
A) + iax*(ray*C10.
A + iay*C11.
A);
1746 return RGB32(R >> 16,G >> 16,B >> 16,A >> 16);
1755 return RGB32(((
int)colA.
R + (
int)colB.
R) >> 1,
1756 ((
int)colA.
G + (
int)colB.
G) >> 1,
1757 ((
int)colA.
B + (
int)colB.
B) >> 1,
1758 ((
int)colA.
A + (
int)colB.
A) >> 1);
1767 return RGB32(((
int)colA.
R + (
int)colB.
R + (
int)colC.
R + (
int)colD.
R) >> 2,
1768 ((
int)colA.
G + (
int)colB.
G + (
int)colC.
G + (
int)colD.
G) >> 2,
1769 ((
int)colA.
B + (
int)colB.
B + (
int)colC.
B + (
int)colD.
B) >> 2,
1770 ((
int)colA.
A + (
int)colB.
A + (
int)colC.
A + (
int)colD.
A) >> 2);
1795 #if (MTOOLS_TGX_EXTENSIONS)
1796 #include <mtools/extensions/tgx/tgx_ext_Color_RGB64.inl>
1810#if TGX_RGB64_ORDER_BGR
1837 B((uint16_t)b),
G((uint16_t)g),
R((uint16_t)r),
A((uint16_t)a)
1839 R((uint16_t)r),
G((uint16_t)g),
B((uint16_t)b),
A((uint16_t)a)
1861 RGB64(
float r,
float g,
float b,
float a = -1.0f) :
1863 B((uint16_t)(b * 65535)),
1864 G((uint16_t)(g * 65535)),
1865 R((uint16_t)(r * 65535)),
1866 A((uint16_t)((a < 0.0f) ?
DEFAULT_A : a * 65535))
1868 R((uint16_t)(r * 65535)),
1869 G((uint16_t)(g * 65535)),
1870 B((uint16_t)(b * 65535)),
1871 A((uint16_t)((a < 0.0f) ?
DEFAULT_A : a * 65535))
1947 explicit operator uint64_t&() {
return val; }
1953 explicit operator const uint64_t&()
const {
return val; }
1965 explicit operator fVec3()
const {
return fVec3(
R / 65535.0f,
G / 65535.0f,
B / 65535.0f); }
1977 explicit operator fVec4()
const {
return fVec4(
R / 65535.0f,
G / 65535.0f,
B / 65535.0f,
A / 65535.0f); }
2105 R = (uint16_t)(
R * v);
2106 G = (uint16_t)(
G * v);
2107 B = (uint16_t)(
B * v);
2108 A = (uint16_t)(
A * v);
2127 R = (uint16_t)(
R / v);
2128 G = (uint16_t)(
G / v);
2129 B = (uint16_t)(
B / v);
2130 A = (uint16_t)(
A / v);
2148 return !(*
this == c);
2163 blend65536(fg_col, (uint32_t)(alpha * 65536));
2196 const uint32_t inv_alpha = (2147483648 - (alpha * (((uint32_t)fg_col.
A) + (fg_col.
A > 32767)))) >> 16;
2197 R = (uint16_t)((((uint32_t)fg_col.
R) * alpha + ((uint32_t)
R) * inv_alpha) >> 15);
2198 G = (uint16_t)((((uint32_t)fg_col.
G) * alpha + ((uint32_t)
G) * inv_alpha) >> 15);
2199 B = (uint16_t)((((uint32_t)fg_col.
B) * alpha + ((uint32_t)
B) * inv_alpha) >> 15);
2200 A = (uint16_t)((((uint32_t)fg_col.
A) * alpha + ((uint32_t)
A) * inv_alpha) >> 15);
2231 inline void mult256(
int mr,
int mg,
int mb,
int ma)
2249 R = (uint16_t)((((uint32_t)
R) *
A) / 65535);
2250 G = (uint16_t)((((uint32_t)
G) *
A) / 65535);
2251 B = (uint16_t)((((uint32_t)
B) *
A) / 65535);
2261 return (((
float)
A) / 65535.0f);
2275 float mo = op * 65535.0f;
2276 float mult = (
A == 0) ? 0.0f : (mo / ((
float)
A));
2277 (*this) =
RGB64((
int)(
R * mult), (
int)(
G * mult), (
int)(
B * mult), (
int)mo);
2299 return RGB64((
int)(
R * op), (
int)(
G * op), (
int)(
B * op), (
int)(
A * op));
2360 const float rax = 1.0f - ax;
2361 const float ray = 1.0f - ay;
2362 const int R = (int)roundf(rax*(ray*C00.
R + ay*C01.
R) + ax*(ray*C10.
R + ay*C11.
R));
2363 const int G = (int)roundf(rax*(ray*C00.
G + ay*C01.
G) + ax*(ray*C10.
G + ay*C11.
G));
2364 const int B = (int)roundf(rax*(ray*C00.
B + ay*C01.
B) + ax*(ray*C10.
B + ay*C11.
B));
2365 const int A = (int)roundf(rax*(ray*C00.
A + ay*C01.
A) + ax*(ray*C10.
A + ay*C11.
A));
2366 return RGB64(R,G,B,A);
2375 return RGB64(((
int)colA.
R + (
int)colB.
R) >> 1,
2376 ((
int)colA.
G + (
int)colB.
G) >> 1,
2377 ((
int)colA.
B + (
int)colB.
B) >> 1,
2378 ((
int)colA.
A + (
int)colB.
A) >> 1);
2387 return RGB64(((
int)colA.
R + (
int)colB.
R + (
int)colC.
R + (
int)colD.
R) >> 2,
2388 ((
int)colA.
G + (
int)colB.
G + (
int)colC.
G + (
int)colD.
G) >> 2,
2389 ((
int)colA.
B + (
int)colB.
B + (
int)colC.
B + (
int)colD.
B) >> 2,
2390 ((
int)colA.
A + (
int)colB.
A + (
int)colC.
A + (
int)colD.
A) >> 2);
2410 #if (MTOOLS_TGX_EXTENSIONS)
2411 #include <mtools/extensions/tgx/tgx_ext_Color_RGBf.inl>
2415#if TGX_RGBf_ORDER_BGR
2435 constexpr RGBf(
float r,
float g,
float b) :
2461 constexpr inline RGBf(uint16_t val);
2467 constexpr inline RGBf(uint32_t val);
2473 constexpr inline RGBf(uint64_t val);
2622 return RGBf(
R * a,
G * a,
B * a);
2631 return((
R == c.
R)&&(
G == c.
G)&&(
B == c.
B));
2640 return !(*
this == c);
2664 blend(fg_col, alpha / 256.0f);
2677 R += (fg_col.
R -
R) * alpha;
2678 G += (fg_col.
G -
G) * alpha;
2679 B += (fg_col.
B -
B) * alpha;
2698 inline void mult256(
int mr,
int mg,
int mb,
int ma)
2750 return RGBf(col1.
R + alpha * (col2.
R - col1.
R),
2751 col1.
G + alpha * (col2.
G - col1.
G),
2752 col1.
B + alpha * (col2.
B - col1.
B));
2763 return RGBf(col3.
R + (C1 * (col1.
R - col3.
R) + C2 * (col2.
R - col3.
R)) / totC,
2764 col3.
G + (C1 * (col1.
G - col3.
G) + C2 * (col2.
G - col3.
G)) / totC,
2765 col3.
B + (C1 * (col1.
B - col3.
B) + C2 * (col2.
B - col3.
B)) / totC);
2787 const float rax = 1.0f - ax;
2788 const float ray = 1.0f - ay;
2789 const float R = rax*(ray*C00.
R + ay*C01.
R) + ax*(ray*C10.
R + ay*C11.
R);
2790 const float G = rax*(ray*C00.
G + ay*C01.
G) + ax*(ray*C10.
G + ay*C11.
G);
2791 const float B = rax*(ray*C00.
B + ay*C01.
B) + ax*(ray*C10.
B + ay*C11.
B);
2801 return RGBf((colA.
R + colB.
R)/2, (colA.
G + colB.
G)/2, (colA.
B + colB.
B)/2);
2810 return RGBf((colA.
R + colB.
R + colC.
R + colD.
R) / 4, (colA.
G + colB.
G + colC.
G + colD.
G) / 4, (colA.
B + colB.
B + colC.
B + colD.
B) / 4);
2832 #if (MTOOLS_TGX_EXTENSIONS)
2833 #include <mtools/extensions/tgx/tgx_ext_Color_HSV.inl>
2851 constexpr HSV(
float h,
float s,
float v) :
H(h),
S(s),
V(v) {}
2993 return((
H == c.
H)&&(
S == c.
S)&&(
V == c.
V));
3002 return !(*
this == c);
3038 blend(fg_col, (alpha / 256.0f));
3063 inline void mult256(
int mr,
int mg,
int mb,
int ma)
const RGB32 RGB32_Cyan
Color cyan in RGB32 format.
const RGB32 RGB32_Yellow
Color yellow in RGB32 format.
const RGB32 RGB32_Blue
Color blue in RGB32 format.
RGBf interpolate(const RGBf &col1, const RGBf &col2, float alpha)
Interpolate between 2 colors.
Definition: Color.h:2748
const RGB32 RGB32_Black
Color black in RGB32 format.
#define TGX_RGB32_ORDER_BGR
color ordering for RGB565 (default B,G,R for compatibility with the mtools library)
Definition: Color.h:100
const RGB565 RGB565_Salmon
Color salmon in RGB565 format.
const RGB565 RGB565_Navy
Color navy in RGB565 format.
const RGB32 RGB32_Gray
Color gray in RGB32 format.
const RGB32 RGB32_Red
Color red in RGB32 format.
const RGB32 RGB32_Magenta
Color majenta in RGB32 format.
#define TGX_RGB24_ORDER_BGR
color ordering for RGB24 (default R,G,B)
Definition: Color.h:96
const RGB32 RGB32_Orange
Color orange in RGB32 format.
const RGB565 RGB565_Yellow
Color yellow in RGB565 format.
const RGB565 RGB565_White
Color white in RGB565 format.
#define TGX_RGB565_ORDER_BGR
color ordering for RGB565 (default B,G,R for compatibility with adafruit and most SPI display)
Definition: Color.h:92
#define TGX_RGB64_ORDER_BGR
color ordering for RGB64 (default R,G,B)
Definition: Color.h:104
const RGB32 RGB32_Navy
Color navy in RGB32 format.
const RGB32 RGB32_Green
Color green in RGB32 format.
const RGB565 RGB565_Orange
Color orange in RGB565 format.
const RGB32 RGB32_Maroon
Color maroon in RGB32 format.
const RGB32 RGB32_Purple
Color purple in RGB32 format.
#define TGX_RGBf_ORDER_BGR
color ordering for RGBf (default R,G,B)
Definition: Color.h:108
const RGB565 RGB565_Teal
Color teal in RGB565 format.
const RGB32 RGB32_Transparent
premultiplied transparent black (0,0,0,0)
const RGB565 RGB565_Green
Color green in RGB565 format.
RGB565 meanColor(RGB565 colA, RGB565 colB)
Return the average color between colA and colB.
Definition: Color.h:647
const RGB32 RGB32_Salmon
Color salmon in RGB32 format.
const RGB565 RGB565_Gray
Color gray in RGB565 format.
const RGB565 RGB565_Purple
Color purple in RGB565 format.
const RGB565 RGB565_Cyan
Color cyan in RGB565 format.
const RGB565 RGB565_Lime
Color lime in RGB565 format.
const RGB565 RGB565_Black
Color black in RGB565 format.
const RGB565 RGB565_Magenta
Color majenta in RGB565 format.
const RGB565 RGB565_Maroon
Color maroon in RGB565 format.
const RGB32 RGB32_Silver
Color silver in RGB32 format.
const RGB565 RGB565_Silver
Color silver in RGB565 format.
RGB565 interpolateColorsBilinear(const RGB565 &C00, const RGB565 &C10, const RGB565 &C01, const RGB565 &C11, const float ax, const float ay)
Bilinear interpolation between 4 colors.
Definition: Color.h:621
const RGB32 RGB32_Teal
Color teal in RGB32 format.
const RGB32 RGB32_White
Color white in RGB32 format.
const RGB565 RGB565_Red
Color red in RGB565 format.
const RGB32 RGB32_Olive
Color olive in RGB32 format.
const RGB32 RGB32_Lime
Color lime in RGB32 format.
RGB565 interpolateColorsTriangle(const RGB565 &col1, int32_t C1, const RGB565 &col2, int32_t C2, const RGB565 &col3, const int32_t totC)
Interpolate between 3 colors.
Definition: Color.h:591
const RGB565 RGB565_Blue
Color blue in RGB565 format.
const RGB565 RGB565_Olive
Color olive in RGB565 format.
Utility/miscellaneous functions used throughout the library.
TGX_INLINE T clamp(const T &v, const T &vmin, const T &vmax)
Template clamp version.
Definition: Misc.h:188
Color in H/S/V format [experimental].
Definition: Color.h:2829
constexpr HSV(fVec3 v)
Constructor from a fVec3 with components (x=H, y=S, z=V) in [0.0f, 1.0f].
Definition: Color.h:2857
float S
Saturation in [0;0f, 1.0f].
Definition: Color.h:2838
HSV & operator=(const RGB64 &c)
Assignement operator from a RGB64 color.
HSV & operator=(const HSV &)=default
Default assignement operator.
HSV(const HSV &)=default
Default Copy constructor.
HSV & operator=(fVec3 v)
Assignement operator from a fVec3 with components (x=H, y=S, z=V) in [0.0f, 1.0f].
Definition: Color.h:2967
void blend(const HSV &fg_col, float alpha)
alpha-blend fg_col over this one with a given opacity in the range 0.0f (fully transparent) to 1....
Definition: Color.h:3016
float opacity() const
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:3086
HSV(uint64_t val)
Constructor from a uint64_t (seen as RGB64, component A is ignored).
HSV & operator=(fVec4 v)
Assignement operator from a fVec4 with components (x=H, y=S, z=V, w=ignored) in [0....
Definition: Color.h:2979
float V
Value in [0.F ,1.0f].
Definition: Color.h:2839
HSV(const RGBf &c)
Constructor from a RGBf color.
float H
Hue in [0.0f ,1.0f].
Definition: Color.h:2837
HSV(const RGB32 &c)
Constructor from a RGB32 color.
HSV & operator=(const RGB24 &c)
Assignement operator from a RGB24 color.
HSV(const RGB565 &c)
Constructor from a RGB565 color.
void setOpacity(float op)
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:3097
HSV(const RGB64 &c)
Constructor from a RGB64 color.
HSV & operator=(const RGB565 &c)
Assignement operator from a RGB565 color.
constexpr HSV(fVec4 v)
Constructor from a fVec4 with components (x=H, y=S, z=V, w=ignored) in [0.0f, 1.0f].
Definition: Color.h:2864
void blend256(const HSV &fg_col, uint32_t alpha)
alpha-blend fg_col over this one with a given opacity in the integer range 0 (fully transparent) to 2...
Definition: Color.h:3036
constexpr bool operator!=(const HSV &c) const
Inequality comparator.
Definition: Color.h:3000
constexpr bool operator==(const HSV &c) const
Equality comparator.
Definition: Color.h:2991
HSV & operator=(const RGBf &c)
Assignement operator from a RGBf color.
HSV(uint16_t val)
Constructor from a uint16_t (seen as RGB565).
HSV()=default
Default constructor.
HSV(const RGB24 &c)
Constructor from a RGB24 color.
void mult256(int mr, int mg, int mb, int ma)
Multiply each color component by a given factor x/256 with x in [0,256].
Definition: Color.h:3063
HSV(uint32_t val)
Constructor from a uint32_t (seen as RGB32, component A is ignored).
constexpr HSV(float h, float s, float v)
Constructor from raw h, s, v values in [0.0f, 1.0f].
Definition: Color.h:2851
void premultiply()
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:3074
HSV & operator=(const RGB32 &c)
Assignement operator from a RGB32 color.
void mult256(int mr, int mg, int mb)
Multiply each color component by factor (m/256) with m in [0,256].
Definition: Color.h:3048
Color in R8/G8/B8 format.
Definition: Color.h:681
RGB24()=default
Default contructor.
float opacity() const
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:1073
void blend256(const RGB24 &fg_col, uint32_t alpha)
alpha-blend fg_col over this one with a given opacity in the integer range 0 (fully transparent) to 2...
Definition: Color.h:1024
void operator+=(const RGB24 &c)
Add another color, component by component.
Definition: Color.h:903
constexpr RGB24(const RGB64 &c)
Constructor from a RGB64 color.
uint8_t R
Red channel (8bits)
Definition: Color.h:698
RGB24 & operator=(const RGB64 &c)
Assignement operator from a RGB64 color.
void mult256(int mr, int mg, int mb)
Multiply each color component by a given factor m/256 with m in [0,256].
Definition: Color.h:1037
constexpr RGB24(int r, int g, int b)
Constructor from raw r,g,b values in [0,255].
Definition: Color.h:714
constexpr RGB24(const RGB565 &c)
Constructor from a RGB24 color.
RGB24 & operator=(const HSV &c)
Assignement operator from a HSV color.
RGB24(float r, float g, float b)
Constructor from float r,g,b in [0.0f, 1.0f].
Definition: Color.h:741
constexpr RGB24(const RGB32 &c)
Constructor from a RGB32 color.
void operator*=(float v)
Multiply each component by the scalar (floating point) value v.
Definition: Color.h:958
constexpr RGB24(const RGBf &c)
Constructor from a RGBf color.
RGB24 & operator=(const RGB32 &c)
Assignement operator from a RGB32 color.
constexpr RGB24(uint64_t c)
Constructor from a uint64_t (seen as RGB64).
constexpr RGB24(uint16_t c)
Constructor from a uint16_t (seen as RGB565).
void premultiply()
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:1061
RGB24(const HSV &c)
Constructor from a HSV color.
void mult256(int mr, int mg, int mb, int ma)
Multiply each color component by a given factor m/256 with m in [0,256].
Definition: Color.h:1050
RGB24(const RGB24 &)=default
Default Copy constructor.
constexpr RGB24(iVec3 v)
Constructor from a iVec3 with component (x=R, y=G, z=B).
Definition: Color.h:727
RGB24 & operator=(iVec3 v)
Assignement operator from a iVec3 vector (x=R, y=G, z=B).
RGB24(fVec4 v)
Constructor from a fVec3 with component (x=R, y=G, z=B, w=ignored) in [0.0f, 1.0f].
Definition: Color.h:764
void operator-=(const RGB24 &c)
Substract another color, component by component.
Definition: Color.h:914
constexpr bool operator!=(const RGB24 &c) const
Inequality comparator.
Definition: Color.h:998
uint8_t B
Blue channel (8bits)
Definition: Color.h:700
void blend(const RGB24 &fg_col, float alpha)
alpha-blend fg_col over this one with a given opacity in the range 0.0f (fully transparent) to 1....
Definition: Color.h:1011
RGB24 & operator=(const RGBf &c)
Assignement operator from a RGBf color.
constexpr RGB24(iVec4 v)
Constructor from a iVec4 with component (x=R, y=G, z=B, w=ignored).
Definition: Color.h:734
RGB24 & operator=(iVec4 v)
Assignement operator from a iVec4 vector (x=R, y=G, z=B, w=ignored).
void operator-=(uint8_t v)
Substract the scalar value v to each component.
Definition: Color.h:936
void operator*=(uint8_t v)
Multiply each component by the scalar value v.
Definition: Color.h:947
uint8_t G
Green channel (8bits)
Definition: Color.h:699
constexpr RGB24(uint32_t c)
Constructor from a uint32_t (seen as RGB32).
void operator/=(uint8_t v)
Divide each component by the scalar value v.
Definition: Color.h:968
void operator+=(uint8_t v)
Add the scalar value v to each component.
Definition: Color.h:925
RGB24(fVec3 v)
Constructor from a fVec3 with component (x=R, y=G, z=B) in [0.0f, 1.0f].
Definition: Color.h:757
void setOpacity(float op)
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:1084
constexpr RGB24(uint8_t *p)
Constructor from a uint8_t pointer to 3 bytes in the following order: R,G,B.
Definition: Color.h:771
RGB24 & operator=(const RGB24 &)=default
Default assignement operator.
RGB24 & operator=(fVec4 v)
Assignement operator from a fVec4 vector (x=R, y=G, z=B, w=ignored).
constexpr bool operator==(const RGB24 &c) const
Equality comparator.
Definition: Color.h:989
RGB24 & operator=(fVec3 v)
Assignement operator from a fVec3 vector (x=R, y=G, z=B).
RGB24 & operator=(const RGB565 &c)
Assignement operator from a RGB565 color.
void operator/=(float v)
Divide each component by the scalar (floating point value) v.
Definition: Color.h:978
Color in R8/G8/B8/A8 format.
Definition: Color.h:1176
uint32_t val
color as uint32_t
Definition: Color.h:1190
constexpr RGB32(uint64_t val)
Constructor from a uint64_t (seen as RGB64).
constexpr RGB32(const RGB64 &c)
Constructor from a RGB64 color.
static const uint8_t DEFAULT_A
fully opaque alpha value
Definition: Color.h:1185
constexpr RGB32(iVec4 v)
Constructor from a fVec4 with components (x=R, y=G, z=B, w=A) in [0,255].
Definition: Color.h:1238
RGB32 & operator=(const RGB24 &c)
Assignement operator from a RGB24 color.
constexpr RGB32(uint32_t c)
Constructor from a uint32_t.
Definition: Color.h:1278
void premultiply()
Convert the color from plain alpha to pre-multiplied alpha.
Definition: Color.h:1617
void setOpaque()
Set the alpha channel of the color to fully opaque.
Definition: Color.h:1684
void mult256(int mr, int mg, int mb)
Multiply each color component by a given factor m/256 with m in [0,256] except the A component.
Definition: Color.h:1590
RGB32 getMultOpacity(float op) const
Return a copy of this color with opacity multiplied by a given factor in [0.0f, 1....
Definition: Color.h:1667
RGB32 & operator=(fVec3 v)
Assignement operator from a vector (x=R, y=G, z=B) in [0.0f, 1.0f].
void setTransparent()
Set the alpha channel of the color to fully transparent.
Definition: Color.h:1693
constexpr RGB32(const RGB24 &c)
Constructor from a RGB24 color.
void operator-=(uint8_t v)
Substract the scalar value v to each component (including alpha channel).
Definition: Color.h:1464
void mult256(int mr, int mg, int mb, int ma)
Multiply each color component by a given factor m/256 with m in [0,256].
Definition: Color.h:1601
constexpr RGB32(int r, int g, int b, int a=DEFAULT_A)
Constructor from raw r,g,b,a values.
Definition: Color.h:1218
void operator*=(float v)
Multiply each component by the scalar (floating point) value v (including alpha channel).
Definition: Color.h:1488
RGB32 & operator=(iVec3 v)
Assignement operator from a vector (x=R, y=G, z=B).
RGB32 & operator=(const RGB32 &)=default
Default assignement operator.
constexpr RGB32(iVec3 v)
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0,255].
Definition: Color.h:1231
void operator+=(uint8_t v)
Add the scalar value v to each component (including alpha channel).
Definition: Color.h:1452
uint8_t A
Alpha channel (8bits)
Definition: Color.h:1197
RGB32()=default
Default constructor.
RGB32(fVec3 v)
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
Definition: Color.h:1264
constexpr RGB32(const RGB565 &c)
Constructor from a RGB565 color.
uint8_t R
Red channel (8bits)
Definition: Color.h:1196
void operator+=(const RGB32 &c)
Add another color, component by component (including alpha channel).
Definition: Color.h:1428
void blend(RGB32 fg_col)
alpha-blend fg_col over this one with a given opacity in the range 0.0f (fully transparent) to 1....
Definition: Color.h:1581
void operator-=(const RGB32 &c)
Substract another color, component by component (including alpha channel).
Definition: Color.h:1440
void blend256(const RGB32 &fg_col, uint32_t alpha)
alpha-blend fg_col over this one with a given opacity in the range 0.0f (fully transparent) to 1....
Definition: Color.h:1561
void operator/=(uint8_t v)
Divide each component by the scalar value v (including alpha channel).
Definition: Color.h:1499
RGB32 & operator=(const RGB565 &c)
Assignement operator from a RGB565 color.
RGB32(fVec4 v)
Constructor from a fVec4 with components (x=R, y=G, z=B, w=A) in [0.0f, 1.0f].
Definition: Color.h:1271
constexpr bool operator==(const RGB32 &c) const
Equality comparator.
Definition: Color.h:1522
RGB32 & operator=(iVec4 v)
Assignement operator from a vector (x=R, y=G, z=B, w=A).
uint8_t G
Green channel (8bits)
Definition: Color.h:1195
RGB32 & operator=(const HSV &c)
Assignement operator from a HSV color.
RGB32 & operator=(fVec4 v)
Assignement operator from a vector (x=R, y=G, z=B, w=A) in [0.0f, 1.0f].
RGB32(const HSV &c)
Constructor from a HSV color.
void operator*=(uint8_t v)
Multiply each component by the scalar value v (including alpha channel).
Definition: Color.h:1476
RGB32 & operator=(const RGB64 &c)
Assignement operator from a RGB64 color.
RGB32(float r, float g, float b, float a=-1.0f)
Constructor from float r,g,b,a in [0.0f, 1.0f].
Definition: Color.h:1245
uint8_t B
Blue channel (8bits)
Definition: Color.h:1194
RGB32 & operator=(const RGBf &c)
Assignement operator from a RGBf color.
constexpr RGB32(const RGBf &c)
Constructor from a RGBf color.
RGB32(const RGB32 &)=default
Default Copy constructor.
constexpr bool operator!=(const RGB32 &c) const
Inequality comparator.
Definition: Color.h:1531
constexpr RGB32(uint16_t val)
Constructor from a uint16_t (seen as RGB565).
void blend(const RGB32 &fg_col, float alpha)
alpha-blend fg_col over this one with a given opacity in the range 0.0f (fully transparent) to 1....
Definition: Color.h:1546
void multOpacity(float op)
Multiply the opacity of the color by a given factor in [0.0f, 1.0f].
Definition: Color.h:1656
void setOpacity(float op)
Change the opacity of the color to a given value in [0.0f, 1.0f].
Definition: Color.h:1642
float opacity() const
Return the opacity (alpha channel value) of this color in the range [0,1] (0=fully transparent,...
Definition: Color.h:1629
void operator/=(float v)
Divide each component by the scalar (floating point value) v, including the alpha channel.
Definition: Color.h:1510
Color in R5/G6/B5 format.
Definition: Color.h:216
void mult256(int mr, int mg, int mb, int ma)
Multiply each color component by a given factor x/256 with x in [0,256].
Definition: Color.h:542
RGB565(float r, float g, float b)
Constructor from float r,g,b in [0.0f, 1.0f].
Definition: Color.h:291
constexpr RGB565(const RGB24 &c)
Constructor from a RGB24 color.
RGB565(fVec3 v)
Constructor from a fVec3 vector with components (x=R, y=G, z=B) in [0.0f, 1.0f].
Definition: Color.h:307
void premultiply()
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:553
constexpr RGB565(const RGB565 &)=default
Default Copy constructor.
constexpr RGB565(iVec3 v)
Constructor from a iVec3 vector (x=R, y=G, z=B).
Definition: Color.h:272
void blend(RGB565 fg_col, float alpha)
alpha-blend fg_col over this one with a given opacity in the range 0.0f (fully transparent) to 1....
Definition: Color.h:503
RGB565()=default
Default constructor.
RGB565 & operator=(fVec4 v)
Assignement operator from a fVec4.
void mult256(int mr, int mg, int mb)
Multiply each color component by a given factor m/256 with m in [0,256].
Definition: Color.h:529
constexpr RGB565(const RGB64 &c)
Constructor from a RGB64 color.
constexpr RGB565(iVec4 v)
Constructor from an iVec4 vector (x=R, y=G, z=B, w=ignored).
Definition: Color.h:284
RGB565 & operator=(const RGB32 &c)
Assignement operator from a RGB32 color.
void setOpacity(float op)
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:576
constexpr bool operator==(const RGB565 &c) const
Equality comparator.
Definition: Color.h:481
constexpr RGB565(const RGBf &c)
Constructor from a RGBf color.
RGB565(fVec4 v)
Constructor from a fVec4 vector with components (x=R, y=G, z=B, w=ignored) in [0.0f,...
Definition: Color.h:314
constexpr RGB565(uint16_t c)
Constructor from a uint16_t.
Definition: Color.h:321
float opacity() const
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:565
RGB565 & operator=(const RGB565 &)=default
Default assignement operator.
constexpr RGB565(const RGB32 &c)
Constructor from a RGB32 color.
constexpr bool operator!=(const RGB565 &c) const
Inequality comparator.
Definition: Color.h:490
uint16_t G
Green channel (6 bits)
Definition: Color.h:232
void operator-=(const RGB565 &c)
Substract another color, component by component.
Definition: Color.h:470
RGB565 & operator=(iVec4 v)
Assignement operator from a iVec4.
constexpr RGB565(uint64_t val)
Constructor from a uint64_t (seen as RGB64).
uint16_t val
color as uint16_t
Definition: Color.h:227
void operator+=(const RGB565 &c)
Add another color, component by component.
Definition: Color.h:459
RGB565 & operator=(const RGB24 &c)
Assignement operator from a RGB24 color.
RGB565(const HSV &c)
Constructor from a HSV color.
RGB565 & operator=(const HSV &c)
Assignement operator from a HSV color.
uint16_t R
Red channel (5 bits)
Definition: Color.h:233
RGB565 & operator=(const RGBf &c)
Assignement operator from a RGBf color.
constexpr RGB565(int r, int g, int b)
Constructor from R,G,B values.
Definition: Color.h:256
RGB565 & operator=(fVec3 v)
Assignement operator from a fVec3.
void blend256(const RGB565 &fg_col, uint32_t alpha)
alpha-blend fg_col over this one with a given opacity in the integer range 0 (fully transparent) to 2...
Definition: Color.h:516
RGB565 & operator=(iVec3 v)
Assignement operator from an iVec3 vector.
RGB565 & operator=(const RGB64 &c)
Assignement operator from a RGB64 color.
constexpr RGB565(uint32_t val)
Constructor from a uint32_t (seen as RGB32).
uint16_t B
Blue channel (5 bits)
Definition: Color.h:231
Color in R16/G16/B16/A16 format.
Definition: Color.h:1791
uint16_t B
Blue channel (16 bits)
Definition: Color.h:1819
RGB64(const RGB64 &)=default
Default Copy ctor.
void operator/=(uint16_t v)
Divide each component by the scalar value v, including the alpha channel.
Definition: Color.h:2114
RGB64(const RGB32 &c)
Constructor from a RGB32 color.
RGB64()=default
Default constructor.
void operator*=(float v)
Multiply each component by the scalar (floating point) value v, including the alpha channel.
Definition: Color.h:2103
void operator-=(const RGB64 &c)
Substract another color, component by component, including the alpha channel.
Definition: Color.h:2055
void blend256(const RGB64 &fg_col, uint32_t alpha)
alpha-blend fg_col over this one with a given opacity in the integer range 0 (fully transparent) to 2...
Definition: Color.h:2176
void blend(const RGB64 &fg_col, float alpha)
alpha-blend fg_col over this one with a given opacity in the range 0.0f (fully transparent) to 1....
Definition: Color.h:2161
RGB64(const RGB565 &c)
Constructor from a RGB565 color.
void multOpacity(float op)
Multiply the opacity of the color by a given factor in [0.0f, 1.0f].
Definition: Color.h:2286
void setOpaque()
Set the alpha channel of the color to fully opaque.
Definition: Color.h:2306
RGB64(const RGB24 &c)
Constructor from a RGB24 color.
RGB64 getMultOpacity(float op) const
Return a copy of this color with opacity multiplied by a given factor in [0.0f, 1....
Definition: Color.h:2297
void operator+=(const RGB64 &c)
Add another color, component by component, including the alpha channel.
Definition: Color.h:2043
RGB64 & operator=(iVec4 v)
Assignement operator from a iVec4 with components (x=R, y=G, z=B, w=A) in [0,65535].
RGB64 & operator=(fVec3 v)
Assignement operator from a fVec3 with components (x=R, y=G, z=B) in [0.0f,1.0f].
uint16_t A
Alpha channel (16 bits)
Definition: Color.h:1820
RGB64(const RGBf &c)
Constructor from a RGBf color.
RGB64(const HSV &c)
Constructor from a HSV color.
RGB64 & operator=(const HSV &c)
Assignement operator from a HSV color.
RGB64(uint32_t val)
Constructor from a uint32_t (seen as RGB32).
float opacity() const
Return the opacity (alpha channel value) of this color in the range [0,1] (0=fully transparent,...
Definition: Color.h:2259
void blend65536(RGB64 fg_col, uint32_t alpha)
alpha-blend fg_col over this one with a given opacity in the integer range 0 (fully transparent) to 6...
Definition: Color.h:2191
void setOpacity(float op)
Change the opacity of the color to a given value in [0.0f, 1.0f].
Definition: Color.h:2272
RGB64 & operator=(const RGB24 &c)
Assignement operator from a RGB24 color.
uint64_t val
color as uint64_t
Definition: Color.h:1806
RGB64 & operator=(const RGBf &c)
Assignement operator from a RGBf color.
constexpr bool operator==(const RGB64 &c) const
Equality comparator.
Definition: Color.h:2137
static const uint16_t DEFAULT_A
fully opaque alpha value
Definition: Color.h:1800
constexpr bool operator!=(const RGB64 &c) const
Inequality comparator.
Definition: Color.h:2146
RGB64(uint16_t val)
Constructor from a uint16_t (seen as RGB565).
void blend(const RGB64 &fg_col)
alpha-blend fg_col over this one.
Definition: Color.h:2211
RGB64 & operator=(const RGB32 &c)
Assignement operator from a RGB32 color.
uint16_t G
Green channel (16 bits)
Definition: Color.h:1818
void operator+=(uint16_t v)
Add the scalar value v to each component, including the alpha channel.
Definition: Color.h:2067
RGB64 & operator=(iVec3 v)
Assignement operator from a iVec3 with components (x=R, y=G, z=B) in [0,65535].
RGB64 & operator=(const RGB565 &c)
Assignement operator from a RGB24 color.
void operator-=(uint16_t v)
Substract the scalar value v to each component, including the alpha channel.
Definition: Color.h:2079
RGB64(fVec3 v)
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
Definition: Color.h:1879
RGB64(fVec4 v)
Constructor from a fVec4 with components (x=R, y=G, z=B, w=A) in [0.0f, 1.0f].
Definition: Color.h:1886
void mult256(int mr, int mg, int mb, int ma)
Multiply each color component by a given factor m/256 with m in [0,256].
Definition: Color.h:2231
void mult256(int mr, int mg, int mb)
Multiply each color component by a given factor m/256 with m in [0,256].
Definition: Color.h:2220
constexpr RGB64(iVec3 v)
Constructor from a iVec3 with components (x=R, y=G, z=B) in [0,65535].
Definition: Color.h:1847
RGB64 & operator=(fVec4 v)
Assignement operator from a fVec3 with components (x=R, y=G, z=B, w=A) in [0.0f,1....
RGB64 & operator=(const RGB64 &)=default
Default assignement operator.
void operator/=(float v)
Divide each component by the scalar (floating point value) v, including the alpha channel.
Definition: Color.h:2125
uint16_t R
Red channel (16 bits)
Definition: Color.h:1817
constexpr RGB64(int r, int g, int b, int a=DEFAULT_A)
Constructor from raw r,g,b,a value in [0,65535].
Definition: Color.h:1835
void operator*=(uint16_t v)
Multiply each component by the scalar value v, including the alpha channel.
Definition: Color.h:2091
RGB64(float r, float g, float b, float a=-1.0f)
Constructor from float r,g,b,a in [0.0f, 1.0f].
Definition: Color.h:1861
constexpr RGB64(iVec4 v)
Constructor from a iVec4 with components (x=R, y=G, z=B, w=A) in [0,65535].
Definition: Color.h:1854
void premultiply()
Convert the color from plain alpha to pre-multiplied alpha.
Definition: Color.h:2247
constexpr RGB64(uint64_t c)
Constructor from a uint64_t.
Definition: Color.h:1893
void setTransparent()
Set the alpha channel of the color to fully transparent.
Definition: Color.h:2315
Color in R,G,B float format.
Definition: Color.h:2407
void mult256(int mr, int mg, int mb)
multiply each color component by a given factor m/256 with m in [0,256].
Definition: Color.h:2686
void operator+=(const RGBf &c)
Add another color, component by component.
Definition: Color.h:2569
constexpr RGBf(uint64_t val)
Constructor from a uint64_t (seen as RGB64, the A component is ignored).
constexpr RGBf(float r, float g, float b)
Constructor from raw r,g,b values in [0.0f, 1.0f].
Definition: Color.h:2435
void operator-=(const RGBf &c)
Substract another color, component by component.
Definition: Color.h:2580
float R
Red channel.
Definition: Color.h:2420
constexpr RGBf(fVec4 v)
Constructor from a fVec4 with components (x=R, y=G, z=B, w=ignored) in [0.0f, 1.0f].
Definition: Color.h:2454
constexpr RGBf(const RGB32 &c)
Constructor from a RGB32 color.
void operator*=(const RGBf &c)
Multiply each channel by the same channel on c.
Definition: Color.h:2591
constexpr RGBf(const RGBf &)=default
Default Copy constructor.
void clamp()
Clamp all color channel to [0.0f,1.0f].
Definition: Color.h:2647
RGBf & operator=(fVec3 v)
Assignement operator from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
RGBf & operator=(const RGB24 &c)
Assignement operator from a RGB24 color.
RGBf & operator=(const RGB64 &c)
Assignement operator from a RGB64 color.
RGBf & operator=(const HSV &c)
Assignement operator from a HSV color.
RGBf()=default
Default constructor.
RGBf operator*(const RGBf &c) const
Return the color obtained by multipliying the channels of both colors together.
Definition: Color.h:2601
RGBf & operator=(fVec4 v)
Assignement operator from a fVec4 with components (x=R, y=G, z=B, w=ignored) in [0....
constexpr RGBf(uint32_t val)
Constructor from a uint32_t (seen as RGB32, the A component is ignored).
RGBf & operator=(const RGB565 &c)
Assignement operator from a RGB565 color.
constexpr bool operator!=(const RGBf &c) const
Inequality comparator.
Definition: Color.h:2638
void mult256(int mr, int mg, int mb, int ma)
multiply each color component by a given factor m/256 with m in [0,256].
Definition: Color.h:2698
void blend(const RGBf &fg_col, float alpha)
alpha-blend fg_col over this one with a given opacity in the range 0.0f (fully transparent) to 1....
Definition: Color.h:2675
RGBf & operator=(const RGB32 &c)
Assignement operator from a RGB32 color.
float B
Blue channel.
Definition: Color.h:2422
constexpr RGBf(const RGB64 &c)
Constructor from a RGB64 color.
float opacity() const
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:2721
RGBf & operator=(const RGBf &)=default
Default assignement operator.
float G
Green channel.
Definition: Color.h:2421
void setOpacity(float op)
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:2732
void blend256(const RGB64 &fg_col, uint32_t alpha)
alpha-blend fg_col over this one with a given opacity in the integer range 0 (fully transparent) to 2...
Definition: Color.h:2662
RGBf(const HSV &c)
Constructor from a HSV color.
constexpr RGBf(fVec3 v)
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
Definition: Color.h:2447
constexpr bool operator==(const RGBf &c) const
Equality comparator.
Definition: Color.h:2629
void premultiply()
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:2709
constexpr RGBf(const RGB24 &c)
Constructor from a RGB24 color.
void operator*=(float a)
Multiply each channel by a constant.
Definition: Color.h:2609
RGBf operator*(float a) const
Return the color where all components are multiplied by a.
Definition: Color.h:2620
constexpr RGBf(uint16_t val)
Constructor from a uint16_t (seen as RGB565).
constexpr RGBf(const RGB565 &c)
Constructor from a RGB565 color.
T x
'x' coordinate (first dimension)
Definition: Vec2.h:72
T y
'y' coordinate (second dimension)
Definition: Vec2.h:73
Generic 3D vector [specializations iVec3, fVec3, dVec3].
Definition: Vec3.h:70
T z
'z' coordinate (third dimension)
Definition: Vec3.h:83
Geenric 4D vector [specializations iVec4, fVec4, dVec4].
Definition: Vec4.h:71