| 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::HSV Struct Reference

Color in H/S/V format [experimental]. More...

`#include <Color.h>`

## Public Member Functions
| HSV ()=default
| Default constructor. More...
constexpr | HSV (float h, float s, float v)
| Constructor from raw h, s, v values in [0.0f, 1.0f].
constexpr | HSV (fVec3 v)
| Constructor from a fVec3 with components (x=H, y=S, z=V) in [0.0f, 1.0f].
constexpr | HSV (fVec4 v)
| Constructor from a fVec4 with components (x=H, y=S, z=V, w=ignored) in [0.0f, 1.0f].
| HSV (const HSV &)=default
| Default Copy constructor.
| HSV (uint16_t val)
| Constructor from a uint16_t (seen as RGB565).
| HSV (uint32_t val)
| Constructor from a uint32_t (seen as RGB32, component A is ignored).
| HSV (uint64_t val)
| Constructor from a uint64_t (seen as RGB64, component A is ignored).
| HSV (const RGB565 &c)
| Constructor from a RGB565 color.
| HSV (const RGB24 &c)
| Constructor from a RGB24 color.
| HSV (const RGB32 &c)
| Constructor from a RGB32 color. More...
| HSV (const RGB64 &c)
| Constructor from a RGB64 color. More...
| HSV (const RGBf &c)
| Constructor from a RGBf color.
| operator fVec3 () const
| Cast into an fVec3 with components (x=H, y=S, z=V) in [0.0f, 1.0f].
HSV & | operator= (const HSV &)=default
| Default assignement operator.
HSV & | operator= (const RGB565 &c)
| Assignement operator from a RGB565 color.
HSV & | operator= (const RGB24 &c)
| Assignement operator from a RGB24 color.
HSV & | operator= (const RGB32 &c)
| Assignement operator from a RGB32 color. More...
HSV & | operator= (const RGB64 &c)
| Assignement operator from a RGB64 color. More...
HSV & | operator= (const RGBf &c)
| Assignement operator from a RGBf color.
HSV & | operator= (fVec3 v)
| Assignement operator from a fVec3 with components (x=H, y=S, z=V) in [0.0f, 1.0f].
HSV & | operator= (fVec4 v)
| Assignement operator from a fVec4 with components (x=H, y=S, z=V, w=ignored) in [0.0f, 1.0f].
constexpr bool | operator== (const HSV &c) const
| Equality comparator.
constexpr bool | operator!= (const HSV &c) const
| Inequality comparator.
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.0f (fully opaque). More...
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 256 (fully opaque). More...
void | mult256 (int mr, int mg, int mb)
| Multiply each color component by 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 x/256 with x 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 | H
| Hue in [0.0f ,1.0f].
float | S
| Saturation in [0;0f, 1.0f].
float | V
| Value in [0.F ,1.0f].

## Detailed Description

Color in H/S/V format [experimental].

The color is stored in Hue/Saturation/Value color space. Each component is a float in `[0,1.0f]`. The total size of the object is 4*3 = 12 bytes, aligned as float.

See: https://en.wikipedia.org/wiki/HSL_and_HSV

Warning
  Experimental Operations with HSV colors are very slow. This color format should not be used with the 3D rasterizer.

## Constructor & Destructor Documentation

## ◆ HSV() [1/3]

tgx::HSV::HSV | ( |  | ) |
| default

Default constructor.

Color is undefined.

## ◆ HSV() [2/3]

tgx::HSV::HSV | ( | const RGB32 & | c | ) |

Constructor from a RGB32 color.

The component A is ignored.

## ◆ HSV() [3/3]

tgx::HSV::HSV | ( | const RGB64 & | c | ) |

Constructor from a RGB64 color.

The component A is ignored.

## Member Function Documentation

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

HSV & tgx::HSV::operator= | ( | const RGB32 & | c | ) |

Assignement operator from a RGB32 color.

The component A is ignored.

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

HSV & tgx::HSV::operator= | ( | const RGB64 & | c | ) |

Assignement operator from a RGB64 color.

The component A is ignored.

## ◆ blend()

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

Blending is done by converting the color to RGB space, then alpha blending, and then converting back to HSV.

Parameters

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

## ◆ blend256()

void tgx::HSV::blend256 | ( | const HSV & | 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).

Blending is done by converting the color to RGB space, then alpha blending, and then converting back to HSV.

Parameters

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

## ◆ mult256() [1/2]

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

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

Uses the R,G,B components for compatibility (and just forward to the corresponding RGBf method).

## ◆ mult256() [2/2]

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

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

Parameter ma is ignored since there is not alpha channel.

Uses the R,G,B components for compatibility (and just forward to the corresponding RGBf method).

## ◆ premultiply()

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

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

Return 1.0f (fully opaque)

## ◆ setOpacity()

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