![]() |
TGX 1.0.3
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
|
Color in R16/G16/B16/A16 format. More...
#include <Color.h>
Public Member Functions | |
RGB64 ()=default | |
Default constructor. More... | |
constexpr | RGB64 (int r, int g, int b, int a=DEFAULT_A) |
Constructor from raw r,g,b,a value in [0,65535]. | |
constexpr | RGB64 (iVec3 v) |
Constructor from a iVec3 with components (x=R, y=G, z=B) in [0,65535]. More... | |
constexpr | RGB64 (iVec4 v) |
Constructor from a iVec4 with components (x=R, y=G, z=B, w=A) in [0,65535]. | |
RGB64 (float r, float g, float b, float a=-1.0f) | |
Constructor from float r,g,b,a in [0.0f, 1.0f]. More... | |
RGB64 (fVec3 v) | |
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f]. More... | |
RGB64 (fVec4 v) | |
Constructor from a fVec4 with components (x=R, y=G, z=B, w=A) in [0.0f, 1.0f]. | |
constexpr | RGB64 (uint64_t c) |
Constructor from a uint64_t. | |
RGB64 (uint16_t val) | |
Constructor from a uint16_t (seen as RGB565). | |
RGB64 (uint32_t val) | |
Constructor from a uint32_t (seen as RGB32). | |
RGB64 (const RGB64 &)=default | |
Default Copy ctor. | |
RGB64 (const RGB565 &c) | |
Constructor from a RGB565 color. More... | |
RGB64 (const RGB24 &c) | |
Constructor from a RGB24 color. More... | |
RGB64 (const RGB32 &c) | |
Constructor from a RGB32 color. | |
RGB64 (const RGBf &c) | |
Constructor from a RGBf color. More... | |
RGB64 (const HSV &c) | |
Constructor from a HSV color. More... | |
operator uint64_t & () | |
Cast into a uint64_t (non-const reference version) | |
operator const uint64_t & () const | |
Cast into a uint64_t (const reference version) | |
operator iVec3 () const | |
Cast into an iVec3 with components (x=R, y=G, z=B) in [0,65535]. More... | |
operator fVec3 () const | |
Cast into an fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f]. More... | |
operator iVec4 () const | |
Cast into an iVec4 with components (x=R, y=G, z=B, w=A) in [0,65535]. | |
operator fVec4 () const | |
Cast into an fVec4 with components (x=R, y=G, z=B, w=A) in [0.0f, 1.0f]. | |
RGB64 & | operator= (const RGB64 &)=default |
Default assignement operator. | |
RGB64 & | operator= (const RGB565 &c) |
Assignement operator from a RGB24 color. More... | |
RGB64 & | operator= (const RGB24 &c) |
Assignement operator from a RGB24 color. More... | |
RGB64 & | operator= (const RGB32 &c) |
Assignement operator from a RGB32 color. | |
RGB64 & | operator= (const RGBf &c) |
Assignement operator from a RGBf color. More... | |
RGB64 & | operator= (const HSV &c) |
Assignement operator from a HSV color. More... | |
RGB64 & | operator= (iVec3 v) |
Assignement operator from a iVec3 with components (x=R, y=G, z=B) in [0,65535]. More... | |
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]. More... | |
RGB64 & | operator= (fVec4 v) |
Assignement operator from a fVec3 with components (x=R, y=G, z=B, w=A) in [0.0f,1.0f]. | |
void | operator+= (const RGB64 &c) |
Add another color, component by component, including the alpha channel. | |
void | operator-= (const RGB64 &c) |
Substract another color, component by component, including the alpha channel. | |
void | operator+= (uint16_t v) |
Add the scalar value v to each component, including the alpha channel. | |
void | operator-= (uint16_t v) |
Substract the scalar value v to each component, including the alpha channel. | |
void | operator*= (uint16_t v) |
Multiply each component by the scalar value v, including the alpha channel. | |
void | operator*= (float v) |
Multiply each component by the scalar (floating point) value v, including the alpha channel. | |
void | operator/= (uint16_t v) |
Divide each component by the scalar value v, including the alpha channel. | |
void | operator/= (float v) |
Divide each component by the scalar (floating point value) v, including the alpha channel. | |
constexpr bool | operator== (const RGB64 &c) const |
Equality comparator. | |
constexpr bool | operator!= (const RGB64 &c) const |
Inequality comparator. | |
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.0f (fully opaque). More... | |
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 256 (fully opaque). More... | |
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 65536 (fully opaque). More... | |
void | blend (const RGB64 &fg_col) |
alpha-blend fg_col over this one. More... | |
void | mult256 (int mr, int mg, int mb) |
Multiply each color component by a given factor m/256 with m in [0,256]. More... | |
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]. | |
void | premultiply () |
Convert the color from plain alpha to pre-multiplied alpha. More... | |
float | opacity () const |
Return the opacity (alpha channel value) of this color in the range [0,1] (0=fully transparent, 1=fully opaque). | |
void | setOpacity (float op) |
Change the opacity of the color to a given value in [0.0f, 1.0f]. More... | |
void | multOpacity (float op) |
Multiply the opacity of the color by a given factor in [0.0f, 1.0f]. More... | |
RGB64 | getMultOpacity (float op) const |
Return a copy of this color with opacity multiplied by a given factor in [0.0f, 1.0f]. More... | |
void | setOpaque () |
Set the alpha channel of the color to fully opaque. | |
void | setTransparent () |
Set the alpha channel of the color to fully transparent. | |
Static Public Attributes | |
static const uint16_t | DEFAULT_A = 65535 |
fully opaque alpha value | |
Color in R16/G16/B16/A16 format.
Occupies 8 bytes in memory, aligned as uint64_t.
Can be converted from/to uint64_t.
the component A defaults to DEFAULT_A = 65535 (fully opaque) if not specified.
REMARK For all drawing/blending procedure, the color is assume to have pre-multiplied alpha. Use the premultiply() method to convert a plain alpha color to its pre-multiplied version (https://developer.nvidia.com/content/alpha-blending-pre-or-not-pre).
|
default |
Default constructor.
Color is undefined
|
inlineconstexpr |
Constructor from a iVec3 with components (x=R, y=G, z=B) in [0,65535].
Component A is set to DEFAULT_A.
|
inline |
Constructor from float r,g,b,a in [0.0f, 1.0f].
If unspecified, component A is set to DEFAULT_A.
|
inline |
Constructor from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
Component A is set to DEFAULT_A.
|
inline |
Constructor from a RGB565 color.
Component A is set to DEFAULT_A.
|
inline |
Constructor from a RGB24 color.
Component A is set to DEFAULT_A.
|
inline |
Constructor from a RGBf color.
Component A is set to DEFAULT_A.
|
inlineexplicit |
Cast into an iVec3 with components (x=R, y=G, z=B) in [0,65535].
Component A is ignored.
|
inlineexplicit |
Cast into an fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
Component A is ignored.
Assignement operator from a RGB24 color.
Component A is set to DEFAULT_A.
Assignement operator from a RGB24 color.
Component A is set to DEFAULT_A.
Assignement operator from a RGBf color.
Component A is set to DEFAULT_A.
Assignement operator from a HSV color.
Component A is set to DEFAULT_A.
Assignement operator from a iVec3 with components (x=R, y=G, z=B) in [0,65535].
Component A is set to DEFAULT_A.
Assignement operator from a fVec3 with components (x=R, y=G, z=B) in [0.0f,1.0f].
Component A is set to DEFAULT_A.
|
inline |
alpha-blend fg_col
over this one with a given opacity in the range 0.0f (fully transparent) to 1.0f (fully opaque).
WARNING The color fg_col is assumed to have pre-multiplied alpha.
fg_col | The foreground color. |
alpha | Additional opacity/alpha multiplier in [0.0f,1.0f]. |
|
inline |
alpha-blend fg_col
over this one with a given opacity in the integer range 0 (fully transparent) to 256 (fully opaque).
WARNING The color fg_col is assumed o have pre-multiplied alpha.
fg_col | The foreground color. |
alpha | The opacity/alpha multiplier in [0,256]. |
|
inline |
alpha-blend fg_col
over this one with a given opacity in the integer range 0 (fully transparent) to 65536 (fully opaque).
WARNING The color fg_col is assumed to have pre-multiplied alpha.
fg_col | The foreground color. |
alpha | The opacity/alpha multiplier in [0,65536]. |
|
inline |
alpha-blend fg_col
over this one.
WARNING The color fg_col is assumed to have pre-multiplied alpha.
fg_col | The foreground color. The alpha channel of the color is used for blending. |
|
inline |
Multiply each color component by a given factor m/256 with m in [0,256].
Component A is left unchanged.
|
inline |
Convert the color from plain alpha to pre-multiplied alpha.
Remark All colors type in TGX should have pre-multiplied alpha. This method should only be used when loading a color from external data (a png image for example) where the colors are not initially pre-multiplied.
|
inline |
Change the opacity of the color to a given value in [0.0f, 1.0f].
This method assumes (and returns) a color with pre-multiplied alpha.
Remark Use multOpacity() instead whenever possible because it is faster.
|
inline |
Multiply the opacity of the color by a given factor in [0.0f, 1.0f].
This method assumes (and returns) a color with pre-multiplied alpha.
|
inline |
Return a copy of this color with opacity multiplied by a given factor in [0.0f, 1.0f].
This method assumes (and returns) a color with pre-multiplied alpha.