| TGX 1.1.1 A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
tgx::RGB24 Struct Reference

Color in R8/G8/B8 format. More...

`#include <Color.h>`

## Public Member Functions
| RGB24 ()=default
| Default contructor. More...
constexpr | RGB24 (int r, int g, int b)
| Constructor from raw r,g,b values in [0,255].
constexpr | RGB24 (iVec3 v)
| Constructor from a iVec3 with component (x=R, y=G, z=B). More...
constexpr | RGB24 (iVec4 v)
| Constructor from a iVec4 with component (x=R, y=G, z=B, w=ignored). More...
| RGB24 (float r, float g, float b)
| Constructor from float r,g,b in [0.0f, 1.0f].
| RGB24 (fVec3 v)
| Constructor from a fVec3 with component (x=R, y=G, z=B) in [0.0f, 1.0f].
| RGB24 (fVec4 v)
| Constructor from a fVec3 with component (x=R, y=G, z=B, w=ignored) in [0.0f, 1.0f].
constexpr | RGB24 (uint8_t *p)
| Constructor from a uint8_t pointer to 3 bytes in the following order: R,G,B.
| RGB24 (const RGB24 &)=default
| Default Copy constructor.
constexpr | RGB24 (uint16_t c)
| Constructor from a uint16_t (seen as RGB565).
constexpr | RGB24 (uint32_t c)
| Constructor from a uint32_t (seen as RGB32).
constexpr | RGB24 (uint64_t c)
| Constructor from a uint64_t (seen as RGB64).
constexpr | RGB24 (const RGB565 &c)
| Constructor from a RGB24 color.
constexpr | RGB24 (const RGB32 &c)
| Constructor from a RGB32 color. More...
constexpr | RGB24 (const RGB64 &c)
| Constructor from a RGB64 color. More...
constexpr | RGB24 (const RGBf &c)
| Constructor from a RGBf color.
| RGB24 (const HSV &c)
| Constructor from a HSV color.
| operator iVec3 () const
| Cast into an iVec3. More...
| operator fVec3 () const
| Cast into an fVec3. More...
RGB24 & | operator= (const RGB24 &)=default
| Default assignment operator.
RGB24 & | operator= (const RGB565 &c)
| Assignment operator from a RGB565 color.
RGB24 & | operator= (const RGB32 &c)
| Assignment operator from a RGB32 color. More...
RGB24 & | operator= (const RGB64 &c)
| Assignment operator from a RGB64 color. More...
RGB24 & | operator= (const RGBf &c)
| Assignment operator from a RGBf color.
RGB24 & | operator= (const HSV &c)
| Assignment operator from a HSV color.
RGB24 & | operator= (iVec3 v)
| Assignment operator from a iVec3 vector (x=R, y=G, z=B). More...
RGB24 & | operator= (iVec4 v)
| Assignment operator from a iVec4 vector (x=R, y=G, z=B, w=ignored). More...
RGB24 & | operator= (fVec3 v)
| Assignment operator from a fVec3 vector (x=R, y=G, z=B). More...
RGB24 & | operator= (fVec4 v)
| Assignment operator from a fVec4 vector (x=R, y=G, z=B, w=ignored). More...
void | operator+= (const RGB24 &c)
| Add another color, component by component.
void | operator-= (const RGB24 &c)
| Substract another color, component by component.
void | operator+= (uint8_t v)
| Add the scalar value v to each component.
void | operator-= (uint8_t v)
| Substract the scalar value v to each component.
void | operator*= (uint8_t v)
| Multiply each component by the scalar value v.
void | operator*= (float v)
| Multiply each component by the scalar (floating point) value v.
void | operator/= (uint8_t v)
| Divide each component by the scalar value v.
void | operator/= (float v)
| Divide each component by the scalar (floating point value) v.
constexpr bool | operator== (const RGB24 &c) const
| Equality comparator.
constexpr bool | operator!= (const RGB24 &c) const
| Inequality comparator.
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.0f (fully opaque). More...
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 256 (fully opaque). More...
void | mult256 (int mr, int mg, int mb)
| Multiply each color component by a given factor m/256 with m in [0,256].
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]. More...
void | premultiply ()
| Dummy function for compatibility with color types having an alpha channel. More...
float | opacity () const
| Dummy function for compatibility with color types having an alpha channel. More...
void | setOpacity (float op)
| Dummy function for compatibility with color types having an alpha channel. More...

## Public Attributes
uint8_t | R
| Red channel (8bits)
uint8_t | G
| Green channel (8bits)
uint8_t | B
| Blue channel (8bits)

## Detailed Description

Color in R8/G8/B8 format.

Occupies 3 bytes in memory. No alignment.

Remark This color type should only be used when memory space is really tight but RGB565 does not offer enough resolution. Use RGB32 instead when possible (even if not using the alpha component) because most operations will be faster with correct 4 bytes alignment.

## Constructor & Destructor Documentation

## ◆ RGB24() [1/5]

tgx::RGB24::RGB24 | ( |  | ) |
| default

Default contructor.

Color is undefined.

## ◆ RGB24() [2/5]

constexpr tgx::RGB24::RGB24 | ( | iVec3 | v | ) |
| inline constexpr

Constructor from a iVec3 with component (x=R, y=G, z=B).

All values in [0,255].

## ◆ RGB24() [3/5]

constexpr tgx::RGB24::RGB24 | ( | iVec4 | v | ) |
| inline constexpr

Constructor from a iVec4 with component (x=R, y=G, z=B, w=ignored).

All values in [0,255].

## ◆ RGB24() [4/5]

constexpr tgx::RGB24::RGB24 | ( | const RGB32 & | c | ) |
| inline constexpr

Constructor from a RGB32 color.

The component A is ignored

## ◆ RGB24() [5/5]

constexpr tgx::RGB24::RGB24 | ( | const RGB64 & | c | ) |
| inline constexpr

Constructor from a RGB64 color.

The component A is ignored

## Member Function Documentation

## ◆ operator iVec3()

tgx::RGB24::operator iVec3 | ( |  | ) | const
| inline explicit

Cast into an iVec3.

Raw values in [0,255].

## ◆ operator fVec3()

tgx::RGB24::operator fVec3 | ( |  | ) | const
| inline explicit

Cast into an fVec3.

Values in [0.0f, 1.0f].

## ◆ operator=() [1/6]

RGB24 & tgx::RGB24::operator= | ( | const RGB32 & | c | ) |
| inline

Assignment operator from a RGB32 color.

The component A is ignored.

## ◆ operator=() [2/6]

RGB24 & tgx::RGB24::operator= | ( | const RGB64 & | c | ) |
| inline

Assignment operator from a RGB64 color.

The component A is ignored.

## ◆ operator=() [3/6]

RGB24 & tgx::RGB24::operator= | ( | iVec3 | v | ) |
| inline

Assignment operator from a iVec3 vector (x=R, y=G, z=B).

Raw values.

## ◆ operator=() [4/6]

RGB24 & tgx::RGB24::operator= | ( | iVec4 | v | ) |
| inline

Assignment operator from a iVec4 vector (x=R, y=G, z=B, w=ignored).

Raw values.

## ◆ operator=() [5/6]

RGB24 & tgx::RGB24::operator= | ( | fVec3 | v | ) |
| inline

Assignment operator from a fVec3 vector (x=R, y=G, z=B).

All values in [0.0f, 1.0f].

## ◆ operator=() [6/6]

RGB24 & tgx::RGB24::operator= | ( | fVec4 | v | ) |
| inline

Assignment operator from a fVec4 vector (x=R, y=G, z=B, w=ignored).

All values in [0.0f, 1.0f].

## ◆ blend()

void tgx::RGB24::blend | ( | const RGB24 & | fg_col,
|  | float | alpha
| ) |  |
| inline

alpha-blend `fg_col` over this one with a given opacity in the range 0.0f (fully transparent) to 1.0f (fully opaque).

Parameters

  fg_col | The foreground color.
  alpha | The opacity/alpha multiplier in [0.0f, 1.0f].

## ◆ blend256()

void tgx::RGB24::blend256 | ( | const RGB24 & | fg_col,
|  | uint32_t | alpha
| ) |  |
| inline

alpha-blend `fg_col` over this one with a given opacity in the integer range 0 (fully transparent) to 256 (fully opaque).

Parameters

  fg_col | The foreground color.
  alpha | The opacity/alpha multiplier in [0, 256].

## ◆ mult256()

void tgx::RGB24::mult256 | ( | int | mr,
|  | int | mg,
|  | int | mb,
|  | int | ma
| ) |  |
| inline

Multiply each color component by a given factor m/256 with m in [0,256].

Parameter ma is ignored since there is not alpha channel.

## ◆ premultiply()

void tgx::RGB24::premultiply | ( |  | ) |
| inline

Dummy function for compatibility with color types having an alpha channel.

Does nothing since the color is always fully opaque.

## ◆ opacity()

float tgx::RGB24::opacity | ( |  | ) | const
| inline

Dummy function for compatibility with color types having an alpha channel.

Return 1.0f (fully opaque)

## ◆ setOpacity()

void tgx::RGB24::setOpacity | ( | float | op | ) |
| inline

Dummy function for compatibility with color types having an alpha channel.

Does nothing since the color is always fully opaque.

The documentation for this struct was generated from the following file:

- src/Color.h