| TGX 1.0.8 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::RGBf Struct Reference

Color in R,G,B float format. More...

`#include <Color.h>`

## Public Member Functions
| RGBf ()=default
| Default constructor. More...
constexpr | RGBf (float r, float g, float b)
| Constructor from raw r,g,b values in [0.0f, 1.0f].
constexpr | RGBf (fVec3 v)
| Constructor from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
constexpr | RGBf (fVec4 v)
| Constructor from a fVec4 with components (x=R, y=G, z=B, w=ignored) in [0.0f, 1.0f].
constexpr | RGBf (uint16_t val)
| Constructor from a uint16_t (seen as RGB565).
constexpr | RGBf (uint32_t val)
| Constructor from a uint32_t (seen as RGB32, the A component is ignored).
constexpr | RGBf (uint64_t val)
| Constructor from a uint64_t (seen as RGB64, the A component is ignored).
constexpr | RGBf (const RGBf &)=default
| Default Copy constructor.
constexpr | RGBf (const RGB565 &c)
| Constructor from a RGB565 color.
constexpr | RGBf (const RGB24 &c)
| Constructor from a RGB24 color.
constexpr | RGBf (const RGB32 &c)
| Constructor from a RGB32 color. More...
constexpr | RGBf (const RGB64 &c)
| Constructor from a RGB64 color. More...
| RGBf (const HSV &c)
| Constructor from a HSV color.
| operator fVec3 () const
| Cast into an fVec3 in [0.0f, 1.0f].
RGBf & | operator= (const RGBf &)=default
| Default assignement operator.
RGBf & | operator= (const RGB565 &c)
| Assignement operator from a RGB565 color.
RGBf & | operator= (const RGB24 &c)
| Assignement operator from a RGB24 color.
RGBf & | operator= (const RGB32 &c)
| Assignement operator from a RGB32 color. More...
RGBf & | operator= (const RGB64 &c)
| Assignement operator from a RGB64 color. More...
RGBf & | operator= (const HSV &c)
| Assignement operator from a HSV color.
RGBf & | operator= (fVec3 v)
| Assignement operator from a fVec3 with components (x=R, y=G, z=B) in [0.0f, 1.0f].
RGBf & | operator= (fVec4 v)
| Assignement operator from a fVec4 with components (x=R, y=G, z=B, w=ignored) in [0.0f, 1.0f].
void | operator+= (const RGBf &c)
| Add another color, component by component.
void | operator-= (const RGBf &c)
| Substract another color, component by component.
void | operator*= (const RGBf &c)
| Multiply each channel by the same channel on c.
RGBf | operator* (const RGBf &c) const
| Return the color obtained by multipliying the channels of both colors together.
void | operator*= (float a)
| Multiply each channel by a constant.
RGBf | operator* (float a) const
| Return the color where all components are multiplied by a.
constexpr bool | operator== (const RGBf &c) const
| Equality comparator.
constexpr bool | operator!= (const RGBf &c) const
| Inequality comparator.
void | clamp ()
| Clamp all color channel to [0.0f,1.0f].
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 | 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.0f (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
float | R
| Red channel.
float | G
| Green channel.
float | B
| Blue channel.

## Detailed Description

Color in R,G,B float format.

Occupies 4*3 = 12 bytes in memory, aligned as float.

- There is no alpha channel.
- Useful for high precision computation. This color format is used internally by the 3D rasterizer for all color interpolation/shading.

## Constructor & Destructor Documentation

## ◆ RGBf() [1/3]

tgx::RGBf::RGBf | ( |  | ) |
| default

Default constructor.

Color is undefined.

## ◆ RGBf() [2/3]

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

Constructor from a RGB32 color.

The A component of c is ignored.

## ◆ RGBf() [3/3]

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

Constructor from a RGB64 color.

The A component of c is ignored.

## Member Function Documentation

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

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

Assignement operator from a RGB32 color.

The component A is ignored.

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

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

Assignement operator from a RGB64 color.

The component A is ignored.

## ◆ blend256()

void tgx::RGBf::blend256 | ( | const RGB64 & | 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].

## ◆ blend()

void tgx::RGBf::blend | ( | const RGBf & | 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].

## ◆ mult256()

void tgx::RGBf::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::RGBf::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::RGBf::opacity | ( |  | ) | const
| inline

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

Return 1.0f (fully opaque)

## ◆ setOpacity()

void tgx::RGBf::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