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((uint16_t)((colA.
val & colB.
val) + (((colA.
val ^ colB.
val) & 0xF7DEu) >> 1)));
660 return RGB565(((
int)colA.
R + (
int)colB.
R + (
int)colC.
R + (
int)colD.
R) >> 2,
661 ((
int)colA.
G + (
int)colB.
G + (
int)colC.
G + (
int)colD.
G) >> 2,
662 ((
int)colA.
B + (
int)colB.
B + (
int)colC.
B + (
int)colD.
B) >> 2);
683 #if (MTOOLS_TGX_EXTENSIONS)
684 #include <mtools/extensions/tgx/tgx_ext_Color_RGB24.inl>
691#if TGX_RGB24_ORDER_BGR
712 constexpr RGB24(
int r,
int g,
int b) :
714 B((uint8_t)b),
G((uint8_t)g),
R((uint8_t)r)
716 R((uint8_t)r),
G((uint8_t)g),
B((uint8_t)b)
741 B((uint8_t)(b * 255)),
742 G((uint8_t)(g * 255)),
743 R((uint8_t)(r * 255))
745 R((uint8_t)(r * 255)),
746 G((uint8_t)(g * 255)),
747 B((uint8_t)(b * 255))
769 constexpr RGB24(uint8_t * p) :
R(p[0]),
G(p[1]),
B(p[2]) {}
835 explicit operator fVec3()
const {
return fVec3(
R / 255.0f,
G / 255.0f,
B / 255.0f); }
958 R = (uint8_t)(
R * v);
959 G = (uint8_t)(
G * v);
960 B = (uint8_t)(
B * v);
978 R = (uint8_t)(
R / v);
979 G = (uint8_t)(
G / v);
980 B = (uint8_t)(
B / v);
989 return((
R == c.
R) && (
G == c.
G) && (
B == c.
B));
998 return !(*
this == c);
1011 blend256(fg_col, (uint32_t)(alpha * 256));
1024 const uint16_t a = (uint16_t)alpha;
1025 const uint16_t ia = (uint16_t)(256 - alpha);
1026 R = ((fg_col.
R * a) + (
R * ia)) >> 8;
1027 G = ((fg_col.
G * a) + (
G * ia)) >> 8;
1028 B = ((fg_col.
B * a) + (
B * ia)) >> 8;
1048 inline void mult256(
int mr,
int mg,
int mb,
int ma)
1100 return RGB24((
int)(col3.
R + (C1 * (col1.
R - col3.
R) + C2 * (col2.
R - col3.
R)) / totC),
1101 (
int)(col3.
G + (C1 * (col1.
G - col3.
G) + C2 * (col2.
G - col3.
G)) / totC),
1102 (
int)(col3.
B + (C1 * (col1.
B - col3.
B) + C2 * (col2.
B - col3.
B)) / totC));
1124 const int iax = (int)(ax * 256);
1125 const int iay = (int)(ay * 256);
1126 const int rax = 256 - iax;
1127 const int ray = 256 - iay;
1128 const int R = rax*(ray*C00.
R + iay*C01.
R) + iax*(ray*C10.
R + iay*C11.
R);
1129 const int G = rax*(ray*C00.
G + iay*C01.
G) + iax*(ray*C10.
G + iay*C11.
G);
1130 const int B = rax*(ray*C00.
B + iay*C01.
B) + iax*(ray*C10.
B + iay*C11.
B);
1131 return RGB24(R >> 16,G >> 16,B >> 16);
1140 return RGB24(((
int)colA.
R + (
int)colB.
R) >> 1,
1141 ((
int)colA.
G + (
int)colB.
G) >> 1,
1142 ((
int)colA.
B + (
int)colB.
B) >> 1);
1151 return RGB24(((
int)colA.
R + (
int)colB.
R + (
int)colC.
R + (
int)colD.
R) >> 2,
1152 ((
int)colA.
G + (
int)colB.
G + (
int)colC.
G + (
int)colD.
G) >> 2,
1153 ((
int)colA.
B + (
int)colB.
B + (
int)colC.
B + (
int)colD.
B) >> 2);
1178 #if (MTOOLS_TGX_EXTENSIONS)
1179 #include <mtools/extensions/tgx/tgx_ext_Color_RGB32.inl>
1191#if TGX_RGB32_ORDER_BGR
1218 B((uint8_t)b),
G((uint8_t)g),
R((uint8_t)r),
A((uint8_t)a)
1220 R((uint8_t)r),
G((uint8_t)g),
B((uint8_t)b),
A((uint8_t)a)
1243 RGB32(
float r,
float g,
float b,
float a = -1.0f) :
1245 B((uint8_t)(b * 255)),
1246 G((uint8_t)(g * 255)),
1247 R((uint8_t)(r * 255)),
1248 A((uint8_t)((a < 0.0f) ?
DEFAULT_A : ((uint8_t)roundf(a * 255.0f))))
1250 R((uint8_t)(r * 255.0f)),
1251 G((uint8_t)(g * 255.0f)),
1252 B((uint8_t)(b * 255.0f)),
1253 A((uint8_t)((a < 0.0f) ?
DEFAULT_A : ((uint8_t)roundf(a * 255.0f))))
1330 explicit operator uint32_t&() {
return val; }
1336 explicit operator const uint32_t& ()
const {
return val; }
1348 explicit operator fVec3()
const {
return fVec3(
R / 255.0f,
G / 255.0f,
B / 255.0f); }
1360 explicit operator fVec4()
const {
return fVec4(
R / 255.0f,
G / 255.0f,
B / 255.0f,
A / 255.0f); }
1488 R = (uint8_t)(
R * v);
1489 G = (uint8_t)(
G * v);
1490 B = (uint8_t)(
B * v);
1491 A = (uint8_t)(
A * v);
1510 R = (uint8_t)(
R / v);
1511 G = (uint8_t)(
G / v);
1512 B = (uint8_t)(
B / v);
1513 A = (uint8_t)(
A / v);
1531 return !(*
this == c);
1546 blend256(fg_col, (uint32_t)(alpha * 256));
1564 const uint32_t inv_alpha = (65536 - (alpha * (fg_col.
A + (fg_col.
A > 127)))) >> 8;
1565 const uint32_t ag = ((fg_col.
val & 0xFF00FF00) >> 8)*alpha + ((
val & 0xFF00FF00) >> 8)*inv_alpha;
1566 const uint32_t rb = (fg_col.
val & 0x00FF00FF) * alpha + (
val & 0x00FF00FF) * inv_alpha;
1567 val = (ag & 0xFF00FF00) | ((rb >> 8) & 0x00FF00FF);
1599 inline void mult256(
int mr,
int mg,
int mb,
int ma)
1617 R = (uint8_t)((((uint16_t)
R) *
A) / 255);
1618 G = (uint8_t)((((uint16_t)
G) *
A) / 255);
1619 B = (uint8_t)((((uint16_t)
B) *
A) / 255);
1629 return (((
float)
A)/ 255.0f);
1643 float mo = op * 255.0f;
1644 float mult = (
A == 0) ? 0.0f : (mo / ((
float)
A));
1645 (*this) =
RGB32((
int)(
R * mult), (
int)(
G * mult), (
int)(
B * mult), (
int)mo);
1668 uint32_t o = (uint32_t)(256 * op);
1669 uint32_t ag = (
val & 0xFF00FF00) >> 8;
1670 uint32_t rb =
val & 0x00FF00FF;
1671 uint32_t sag = o * ag;
1672 uint32_t srb = o * rb;
1673 sag = sag & 0xFF00FF00;
1674 srb = (srb >> 8) & 0x00FF00FF;
1675 return RGB32(sag | srb);
1711 return RGB32((
int)(col3.
R + (C1 * (col1.
R - col3.
R) + C2 * (col2.
R - col3.
R)) / totC),
1712 (
int)(col3.
G + (C1 * (col1.
G - col3.
G) + C2 * (col2.
G - col3.
G)) / totC),
1713 (
int)(col3.
B + (C1 * (col1.
B - col3.
B) + C2 * (col2.
B - col3.
B)) / totC),
1714 (
int)(col3.
A + (C1 * (col1.
A - col3.
A) + C2 * (col2.
A - col3.
A)) / totC));
1736 const int iax = (int)(ax * 256);
1737 const int iay = (int)(ay * 256);
1738 const int rax = 256 - iax;
1739 const int ray = 256 - iay;
1740 const int R = rax*(ray*C00.
R + iay*C01.
R) + iax*(ray*C10.
R + iay*C11.
R);
1741 const int G = rax*(ray*C00.
G + iay*C01.
G) + iax*(ray*C10.
G + iay*C11.
G);
1742 const int B = rax*(ray*C00.
B + iay*C01.
B) + iax*(ray*C10.
B + iay*C11.
B);
1743 const int A = rax*(ray*C00.
A + iay*C01.
A) + iax*(ray*C10.
A + iay*C11.
A);
1744 return RGB32(R >> 16,G >> 16,B >> 16,A >> 16);
1753 return RGB32(((
int)colA.
R + (
int)colB.
R) >> 1,
1754 ((
int)colA.
G + (
int)colB.
G) >> 1,
1755 ((
int)colA.
B + (
int)colB.
B) >> 1,
1756 ((
int)colA.
A + (
int)colB.
A) >> 1);
1765 return RGB32(((
int)colA.
R + (
int)colB.
R + (
int)colC.
R + (
int)colD.
R) >> 2,
1766 ((
int)colA.
G + (
int)colB.
G + (
int)colC.
G + (
int)colD.
G) >> 2,
1767 ((
int)colA.
B + (
int)colB.
B + (
int)colC.
B + (
int)colD.
B) >> 2,
1768 ((
int)colA.
A + (
int)colB.
A + (
int)colC.
A + (
int)colD.
A) >> 2);
1793 #if (MTOOLS_TGX_EXTENSIONS)
1794 #include <mtools/extensions/tgx/tgx_ext_Color_RGB64.inl>
1808#if TGX_RGB64_ORDER_BGR
1835 B((uint16_t)b),
G((uint16_t)g),
R((uint16_t)r),
A((uint16_t)a)
1837 R((uint16_t)r),
G((uint16_t)g),
B((uint16_t)b),
A((uint16_t)a)
1859 RGB64(
float r,
float g,
float b,
float a = -1.0f) :
1861 B((uint16_t)(b * 65535)),
1862 G((uint16_t)(g * 65535)),
1863 R((uint16_t)(r * 65535)),
1864 A((uint16_t)((a < 0.0f) ?
DEFAULT_A : a * 65535))
1866 R((uint16_t)(r * 65535)),
1867 G((uint16_t)(g * 65535)),
1868 B((uint16_t)(b * 65535)),
1869 A((uint16_t)((a < 0.0f) ?
DEFAULT_A : a * 65535))
1945 explicit operator uint64_t&() {
return val; }
1951 explicit operator const uint64_t&()
const {
return val; }
1963 explicit operator fVec3()
const {
return fVec3(
R / 65535.0f,
G / 65535.0f,
B / 65535.0f); }
1975 explicit operator fVec4()
const {
return fVec4(
R / 65535.0f,
G / 65535.0f,
B / 65535.0f,
A / 65535.0f); }
2103 R = (uint16_t)(
R * v);
2104 G = (uint16_t)(
G * v);
2105 B = (uint16_t)(
B * v);
2106 A = (uint16_t)(
A * v);
2125 R = (uint16_t)(
R / v);
2126 G = (uint16_t)(
G / v);
2127 B = (uint16_t)(
B / v);
2128 A = (uint16_t)(
A / v);
2146 return !(*
this == c);
2161 blend65536(fg_col, (uint32_t)(alpha * 65536));
2194 const uint32_t inv_alpha = (2147483648 - (alpha * (((uint32_t)fg_col.
A) + (fg_col.
A > 32767)))) >> 16;
2195 R = (uint16_t)((((uint32_t)fg_col.
R) * alpha + ((uint32_t)
R) * inv_alpha) >> 15);
2196 G = (uint16_t)((((uint32_t)fg_col.
G) * alpha + ((uint32_t)
G) * inv_alpha) >> 15);
2197 B = (uint16_t)((((uint32_t)fg_col.
B) * alpha + ((uint32_t)
B) * inv_alpha) >> 15);
2198 A = (uint16_t)((((uint32_t)fg_col.
A) * alpha + ((uint32_t)
A) * inv_alpha) >> 15);
2229 inline void mult256(
int mr,
int mg,
int mb,
int ma)
2247 R = (uint16_t)((((uint32_t)
R) *
A) / 65535);
2248 G = (uint16_t)((((uint32_t)
G) *
A) / 65535);
2249 B = (uint16_t)((((uint32_t)
B) *
A) / 65535);
2259 return (((
float)
A) / 65535.0f);
2273 float mo = op * 65535.0f;
2274 float mult = (
A == 0) ? 0.0f : (mo / ((
float)
A));
2275 (*this) =
RGB64((
int)(
R * mult), (
int)(
G * mult), (
int)(
B * mult), (
int)mo);
2297 return RGB64((
int)(
R * op), (
int)(
G * op), (
int)(
B * op), (
int)(
A * op));
2358 const float rax = 1.0f - ax;
2359 const float ray = 1.0f - ay;
2360 const int R = (int)roundf(rax*(ray*C00.
R + ay*C01.
R) + ax*(ray*C10.
R + ay*C11.
R));
2361 const int G = (int)roundf(rax*(ray*C00.
G + ay*C01.
G) + ax*(ray*C10.
G + ay*C11.
G));
2362 const int B = (int)roundf(rax*(ray*C00.
B + ay*C01.
B) + ax*(ray*C10.
B + ay*C11.
B));
2363 const int A = (int)roundf(rax*(ray*C00.
A + ay*C01.
A) + ax*(ray*C10.
A + ay*C11.
A));
2364 return RGB64(R,G,B,A);
2373 return RGB64(((
int)colA.
R + (
int)colB.
R) >> 1,
2374 ((
int)colA.
G + (
int)colB.
G) >> 1,
2375 ((
int)colA.
B + (
int)colB.
B) >> 1,
2376 ((
int)colA.
A + (
int)colB.
A) >> 1);
2385 return RGB64(((
int)colA.
R + (
int)colB.
R + (
int)colC.
R + (
int)colD.
R) >> 2,
2386 ((
int)colA.
G + (
int)colB.
G + (
int)colC.
G + (
int)colD.
G) >> 2,
2387 ((
int)colA.
B + (
int)colB.
B + (
int)colC.
B + (
int)colD.
B) >> 2,
2388 ((
int)colA.
A + (
int)colB.
A + (
int)colC.
A + (
int)colD.
A) >> 2);
2408 #if (MTOOLS_TGX_EXTENSIONS)
2409 #include <mtools/extensions/tgx/tgx_ext_Color_RGBf.inl>
2413#if TGX_RGBf_ORDER_BGR
2433 constexpr RGBf(
float r,
float g,
float b) :
2459 constexpr inline RGBf(uint16_t val);
2465 constexpr inline RGBf(uint32_t val);
2471 constexpr inline RGBf(uint64_t val);
2620 return RGBf(
R * a,
G * a,
B * a);
2629 return((
R == c.
R)&&(
G == c.
G)&&(
B == c.
B));
2638 return !(*
this == c);
2662 blend(fg_col, alpha / 256.0f);
2673 TGX_INLINE
inline void blend(
const RGBf & fg_col,
float alpha)
2675 R += (fg_col.
R -
R) * alpha;
2676 G += (fg_col.
G -
G) * alpha;
2677 B += (fg_col.
B -
B) * alpha;
2684 TGX_INLINE
inline void mult256(
int mr,
int mg,
int mb)
2696 TGX_INLINE
inline void mult256(
int mr,
int mg,
int mb,
int ma)
2748 return RGBf(col1.
R + alpha * (col2.
R - col1.
R),
2749 col1.
G + alpha * (col2.
G - col1.
G),
2750 col1.
B + alpha * (col2.
B - col1.
B));
2761 return RGBf(col3.
R + (C1 * (col1.
R - col3.
R) + C2 * (col2.
R - col3.
R)) / totC,
2762 col3.
G + (C1 * (col1.
G - col3.
G) + C2 * (col2.
G - col3.
G)) / totC,
2763 col3.
B + (C1 * (col1.
B - col3.
B) + C2 * (col2.
B - col3.
B)) / totC);
2785 const float rax = 1.0f - ax;
2786 const float ray = 1.0f - ay;
2787 const float R = rax*(ray*C00.
R + ay*C01.
R) + ax*(ray*C10.
R + ay*C11.
R);
2788 const float G = rax*(ray*C00.
G + ay*C01.
G) + ax*(ray*C10.
G + ay*C11.
G);
2789 const float B = rax*(ray*C00.
B + ay*C01.
B) + ax*(ray*C10.
B + ay*C11.
B);
2799 return RGBf((colA.
R + colB.
R)/2, (colA.
G + colB.
G)/2, (colA.
B + colB.
B)/2);
2808 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);
2830 #if (MTOOLS_TGX_EXTENSIONS)
2831 #include <mtools/extensions/tgx/tgx_ext_Color_HSV.inl>
2849 constexpr HSV(
float h,
float s,
float v) :
H(h),
S(s),
V(v) {}
2991 return((
H == c.
H)&&(
S == c.
S)&&(
V == c.
V));
3000 return !(*
this == c);
3036 blend(fg_col, (alpha / 256.0f));
3061 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.
TGX_INLINE 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_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
TGX_INLINE 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 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.
TGX_INLINE RGBf interpolate(const RGBf &col1, const RGBf &col2, float alpha)
Interpolate between 2 colors.
Definition: Color.h:2746
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.
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.
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(T v, T vmin, T vmax)
Template clamp version.
Definition: Misc.h:157
Color in H/S/V format [experimental].
Definition: Color.h:2827
constexpr HSV(fVec3 v)
Constructor from a fVec3 with components (x=H, y=S, z=V) in [0.0f, 1.0f].
Definition: Color.h:2855
float S
Saturation in [0;0f, 1.0f].
Definition: Color.h:2836
HSV & operator=(const RGB64 &c)
Assignment operator from a RGB64 color.
HSV & operator=(const HSV &)=default
Default assignment operator.
HSV(const HSV &)=default
Default Copy constructor.
HSV & operator=(fVec3 v)
Assignment operator from a fVec3 with components (x=H, y=S, z=V) in [0.0f, 1.0f].
Definition: Color.h:2965
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:3014
float opacity() const
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:3084
HSV(uint64_t val)
Constructor from a uint64_t (seen as RGB64, component A is ignored).
HSV & operator=(fVec4 v)
Assignment operator from a fVec4 with components (x=H, y=S, z=V, w=ignored) in [0....
Definition: Color.h:2977
float V
Value in [0.F ,1.0f].
Definition: Color.h:2837
HSV(const RGBf &c)
Constructor from a RGBf color.
float H
Hue in [0.0f ,1.0f].
Definition: Color.h:2835
HSV(const RGB32 &c)
Constructor from a RGB32 color.
HSV & operator=(const RGB24 &c)
Assignment 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:3095
HSV(const RGB64 &c)
Constructor from a RGB64 color.
HSV & operator=(const RGB565 &c)
Assignment 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:2862
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:3034
constexpr bool operator!=(const HSV &c) const
Inequality comparator.
Definition: Color.h:2998
constexpr bool operator==(const HSV &c) const
Equality comparator.
Definition: Color.h:2989
HSV & operator=(const RGBf &c)
Assignment 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:3061
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:2849
void premultiply()
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:3072
HSV & operator=(const RGB32 &c)
Assignment 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:3046
Color in R8/G8/B8 format.
Definition: Color.h:679
RGB24()=default
Default contructor.
float opacity() const
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:1071
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:1022
void operator+=(const RGB24 &c)
Add another color, component by component.
Definition: Color.h:901
constexpr RGB24(const RGB64 &c)
Constructor from a RGB64 color.
uint8_t R
Red channel (8bits)
Definition: Color.h:696
RGB24 & operator=(const RGB64 &c)
Assignment 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:1035
constexpr RGB24(int r, int g, int b)
Constructor from raw r,g,b values in [0,255].
Definition: Color.h:712
constexpr RGB24(const RGB565 &c)
Constructor from a RGB24 color.
RGB24 & operator=(const HSV &c)
Assignment 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:739
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:956
constexpr RGB24(const RGBf &c)
Constructor from a RGBf color.
RGB24 & operator=(const RGB32 &c)
Assignment 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:1059
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:1048
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:725
RGB24 & operator=(iVec3 v)
Assignment 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:762
void operator-=(const RGB24 &c)
Substract another color, component by component.
Definition: Color.h:912
constexpr bool operator!=(const RGB24 &c) const
Inequality comparator.
Definition: Color.h:996
uint8_t B
Blue channel (8bits)
Definition: Color.h:698
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:1009
RGB24 & operator=(const RGBf &c)
Assignment 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:732
RGB24 & operator=(iVec4 v)
Assignment 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:934
void operator*=(uint8_t v)
Multiply each component by the scalar value v.
Definition: Color.h:945
uint8_t G
Green channel (8bits)
Definition: Color.h:697
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:966
void operator+=(uint8_t v)
Add the scalar value v to each component.
Definition: Color.h:923
RGB24(fVec3 v)
Constructor from a fVec3 with component (x=R, y=G, z=B) in [0.0f, 1.0f].
Definition: Color.h:755
void setOpacity(float op)
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:1082
constexpr RGB24(uint8_t *p)
Constructor from a uint8_t pointer to 3 bytes in the following order: R,G,B.
Definition: Color.h:769
RGB24 & operator=(const RGB24 &)=default
Default assignment operator.
RGB24 & operator=(fVec4 v)
Assignment 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:987
RGB24 & operator=(fVec3 v)
Assignment operator from a fVec3 vector (x=R, y=G, z=B).
RGB24 & operator=(const RGB565 &c)
Assignment operator from a RGB565 color.
void operator/=(float v)
Divide each component by the scalar (floating point value) v.
Definition: Color.h:976
Color in R8/G8/B8/A8 format.
Definition: Color.h:1174
uint32_t val
color as uint32_t
Definition: Color.h:1188
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:1183
constexpr RGB32(iVec4 v)
Constructor from a fVec4 with components (x=R, y=G, z=B, w=A) in [0,255].
Definition: Color.h:1236
RGB32 & operator=(const RGB24 &c)
Assignment operator from a RGB24 color.
constexpr RGB32(uint32_t c)
Constructor from a uint32_t.
Definition: Color.h:1276
void premultiply()
Convert the color from plain alpha to pre-multiplied alpha.
Definition: Color.h:1615
void setOpaque()
Set the alpha channel of the color to fully opaque.
Definition: Color.h:1682
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:1588
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:1665
RGB32 & operator=(fVec3 v)
Assignment 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:1691
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:1462
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:1599
constexpr RGB32(int r, int g, int b, int a=DEFAULT_A)
Constructor from raw r,g,b,a values.
Definition: Color.h:1216
void operator*=(float v)
Multiply each component by the scalar (floating point) value v (including alpha channel).
Definition: Color.h:1486
RGB32 & operator=(iVec3 v)
Assignment operator from a vector (x=R, y=G, z=B).
RGB32 & operator=(const RGB32 &)=default
Default assignment operator.
constexpr RGB32(iVec3 v)
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0,255].
Definition: Color.h:1229
void operator+=(uint8_t v)
Add the scalar value v to each component (including alpha channel).
Definition: Color.h:1450
uint8_t A
Alpha channel (8bits)
Definition: Color.h:1195
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:1262
constexpr RGB32(const RGB565 &c)
Constructor from a RGB565 color.
uint8_t R
Red channel (8bits)
Definition: Color.h:1194
void operator+=(const RGB32 &c)
Add another color, component by component (including alpha channel).
Definition: Color.h:1426
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:1579
void operator-=(const RGB32 &c)
Substract another color, component by component (including alpha channel).
Definition: Color.h:1438
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:1559
void operator/=(uint8_t v)
Divide each component by the scalar value v (including alpha channel).
Definition: Color.h:1497
RGB32 & operator=(const RGB565 &c)
Assignment 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:1269
constexpr bool operator==(const RGB32 &c) const
Equality comparator.
Definition: Color.h:1520
RGB32 & operator=(iVec4 v)
Assignment operator from a vector (x=R, y=G, z=B, w=A).
uint8_t G
Green channel (8bits)
Definition: Color.h:1193
RGB32 & operator=(const HSV &c)
Assignment operator from a HSV color.
RGB32 & operator=(fVec4 v)
Assignment 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:1474
RGB32 & operator=(const RGB64 &c)
Assignment 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:1243
uint8_t B
Blue channel (8bits)
Definition: Color.h:1192
RGB32 & operator=(const RGBf &c)
Assignment 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:1529
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:1544
void multOpacity(float op)
Multiply the opacity of the color by a given factor in [0.0f, 1.0f].
Definition: Color.h:1654
void setOpacity(float op)
Change the opacity of the color to a given value in [0.0f, 1.0f].
Definition: Color.h:1640
float opacity() const
Return the opacity (alpha channel value) of this color in the range [0,1] (0=fully transparent,...
Definition: Color.h:1627
void operator/=(float v)
Divide each component by the scalar (floating point value) v, including the alpha channel.
Definition: Color.h:1508
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)
Assignment 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)
Assignment 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 assignment 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)
Assignment 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)
Assignment operator from a RGB24 color.
RGB565(const HSV &c)
Constructor from a HSV color.
RGB565 & operator=(const HSV &c)
Assignment operator from a HSV color.
uint16_t R
Red channel (5 bits)
Definition: Color.h:233
RGB565 & operator=(const RGBf &c)
Assignment 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)
Assignment 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)
Assignment operator from an iVec3 vector.
RGB565 & operator=(const RGB64 &c)
Assignment 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:1789
uint16_t B
Blue channel (16 bits)
Definition: Color.h:1817
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:2112
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:2101
void operator-=(const RGB64 &c)
Substract another color, component by component, including the alpha channel.
Definition: Color.h:2053
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:2174
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:2159
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:2284
void setOpaque()
Set the alpha channel of the color to fully opaque.
Definition: Color.h:2304
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:2295
void operator+=(const RGB64 &c)
Add another color, component by component, including the alpha channel.
Definition: Color.h:2041
RGB64 & operator=(iVec4 v)
Assignment operator from a iVec4 with components (x=R, y=G, z=B, w=A) in [0,65535].
RGB64 & operator=(fVec3 v)
Assignment 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:1818
RGB64(const RGBf &c)
Constructor from a RGBf color.
RGB64(const HSV &c)
Constructor from a HSV color.
RGB64 & operator=(const HSV &c)
Assignment 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:2257
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:2189
void setOpacity(float op)
Change the opacity of the color to a given value in [0.0f, 1.0f].
Definition: Color.h:2270
RGB64 & operator=(const RGB24 &c)
Assignment operator from a RGB24 color.
uint64_t val
color as uint64_t
Definition: Color.h:1804
RGB64 & operator=(const RGBf &c)
Assignment operator from a RGBf color.
constexpr bool operator==(const RGB64 &c) const
Equality comparator.
Definition: Color.h:2135
static const uint16_t DEFAULT_A
fully opaque alpha value
Definition: Color.h:1798
constexpr bool operator!=(const RGB64 &c) const
Inequality comparator.
Definition: Color.h:2144
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:2209
RGB64 & operator=(const RGB32 &c)
Assignment operator from a RGB32 color.
uint16_t G
Green channel (16 bits)
Definition: Color.h:1816
void operator+=(uint16_t v)
Add the scalar value v to each component, including the alpha channel.
Definition: Color.h:2065
RGB64 & operator=(iVec3 v)
Assignment operator from a iVec3 with components (x=R, y=G, z=B) in [0,65535].
RGB64 & operator=(const RGB565 &c)
Assignment 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:2077
RGB64(fVec3 v)
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
Definition: Color.h:1877
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:1884
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:2229
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:2218
constexpr RGB64(iVec3 v)
Constructor from a iVec3 with components (x=R, y=G, z=B) in [0,65535].
Definition: Color.h:1845
RGB64 & operator=(fVec4 v)
Assignment operator from a fVec3 with components (x=R, y=G, z=B, w=A) in [0.0f,1.0f].
RGB64 & operator=(const RGB64 &)=default
Default assignment operator.
void operator/=(float v)
Divide each component by the scalar (floating point value) v, including the alpha channel.
Definition: Color.h:2123
uint16_t R
Red channel (16 bits)
Definition: Color.h:1815
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:1833
void operator*=(uint16_t v)
Multiply each component by the scalar value v, including the alpha channel.
Definition: Color.h:2089
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:1859
constexpr RGB64(iVec4 v)
Constructor from a iVec4 with components (x=R, y=G, z=B, w=A) in [0,65535].
Definition: Color.h:1852
void premultiply()
Convert the color from plain alpha to pre-multiplied alpha.
Definition: Color.h:2245
constexpr RGB64(uint64_t c)
Constructor from a uint64_t.
Definition: Color.h:1891
void setTransparent()
Set the alpha channel of the color to fully transparent.
Definition: Color.h:2313
Color in R,G,B float format.
Definition: Color.h:2405
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:2433
float R
Red channel.
Definition: Color.h:2418
TGX_INLINE RGBf operator*(const RGBf &c) const
Return the color obtained by multipliying the channels of both colors together.
Definition: Color.h:2599
constexpr RGBf(const RGB32 &c)
Constructor from a RGB32 color.
TGX_INLINE void blend256(const RGBf &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:2660
constexpr RGBf(const fVec4 &v)
Constructor from a fVec4 with components (x=R, y=G, z=B, w=ignored) in [0.0f, 1.0f].
Definition: Color.h:2452
constexpr RGBf(const RGBf &)=default
Default Copy constructor.
TGX_INLINE void clamp()
Clamp all color channel to [0.0f,1.0f].
Definition: Color.h:2645
TGX_INLINE 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:2684
RGBf & operator=(const RGB24 &c)
Assignment operator from a RGB24 color.
RGBf & operator=(const RGB64 &c)
Assignment operator from a RGB64 color.
TGX_INLINE void operator*=(float a)
Multiply each channel by a constant.
Definition: Color.h:2607
TGX_INLINE RGBf operator*(float a) const
Return the color where all components are multiplied by a.
Definition: Color.h:2618
TGX_INLINE 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:2696
RGBf & operator=(const HSV &c)
Assignment operator from a HSV color.
RGBf()=default
Default constructor.
constexpr RGBf(uint32_t val)
Constructor from a uint32_t (seen as RGB32, the A component is ignored).
RGBf & operator=(const RGB565 &c)
Assignment operator from a RGB565 color.
constexpr bool operator!=(const RGBf &c) const
Inequality comparator.
Definition: Color.h:2636
TGX_INLINE float opacity() const
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:2719
RGBf & operator=(const RGB32 &c)
Assignment operator from a RGB32 color.
TGX_INLINE void operator-=(const RGBf &c)
Substract another color, component by component.
Definition: Color.h:2578
float B
Blue channel.
Definition: Color.h:2420
constexpr RGBf(const RGB64 &c)
Constructor from a RGB64 color.
RGBf & operator=(const RGBf &)=default
Default assignment operator.
float G
Green channel.
Definition: Color.h:2419
RGBf(const HSV &c)
Constructor from a HSV color.
constexpr bool operator==(const RGBf &c) const
Equality comparator.
Definition: Color.h:2627
RGBf & operator=(const fVec4 &v)
Assignment operator from a fVec4 with components (x=R, y=G, z=B, w=ignored) in [0....
TGX_INLINE void operator*=(const RGBf &c)
Multiply each channel by the same channel on c.
Definition: Color.h:2589
constexpr RGBf(const RGB24 &c)
Constructor from a RGB24 color.
RGBf & operator=(const fVec3 &v)
Assignment operator from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
constexpr RGBf(const fVec3 &v)
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
Definition: Color.h:2445
constexpr RGBf(uint16_t val)
Constructor from a uint16_t (seen as RGB565).
constexpr RGBf(const RGB565 &c)
Constructor from a RGB565 color.
TGX_INLINE void setOpacity(float op)
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:2730
TGX_INLINE void operator+=(const RGBf &c)
Add another color, component by component.
Definition: Color.h:2567
TGX_INLINE void premultiply()
Dummy function for compatibility with color types having an alpha channel.
Definition: Color.h:2707
TGX_INLINE 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:2673
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