RGBA color struct with 8-bit channels.
More...
#include <color.h>
|
| | Color () |
| | Construct a default Color (black, fully opaque).
|
| |
| | Color (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
| | Construct a Color from RGBA values.
|
| |
| Color | lighten (float percentage) const |
| | Lighten a color by a given percentage.
|
| |
| Color | darken (float percentage) const |
| | Darken a color by a given percentage.
|
| |
| Color | blend (const Color &color) const |
| | Blend two colors together using alpha blending.
|
| |
| Color | invert () const |
| | Invert a color.
|
| |
| Color | grayscale () const |
| | Convert a color to grayscale.
|
| |
| Color | with_alpha (uint8_t alpha) const |
| | Adjust the alpha of a color.
|
| |
|
| uint8_t | r |
| |
| uint8_t | g |
| |
| uint8_t | b |
| |
| uint8_t | a |
| |
RGBA color struct with 8-bit channels.
Definition at line 11 of file color.h.
◆ Color() [1/2]
Construct a default Color (black, fully opaque).
Definition at line 18 of file color.h.
◆ Color() [2/2]
| asw::Color::Color |
( |
uint8_t | r, |
|
|
uint8_t | g, |
|
|
uint8_t | b, |
|
|
uint8_t | a = 255 ) |
|
inline |
Construct a Color from RGBA values.
- Parameters
-
| r | Red channel (0-255). |
| g | Green channel (0-255). |
| b | Blue channel (0-255). |
| a | Alpha channel (0-255, default 255). |
Definition at line 33 of file color.h.
◆ blend()
| Color asw::Color::blend |
( |
const Color & | color | ) |
const |
|
inline |
Blend two colors together using alpha blending.
- Parameters
-
| color | The color to blend with. |
- Returns
- The blended color.
Definition at line 104 of file color.h.
◆ darken()
| Color asw::Color::darken |
( |
float | percentage | ) |
const |
|
inline |
Darken a color by a given percentage.
- Parameters
-
| percentage | The percentage to darken (0.0-1.0). |
- Returns
- The darkened color.
Definition at line 93 of file color.h.
◆ from_float()
| static Color asw::Color::from_float |
( |
float | r, |
|
|
float | g, |
|
|
float | b, |
|
|
float | a = 1.0F ) |
|
inlinestatic |
From float RGBA values (0.0-1.0) to Color.
- Parameters
-
| r | Red channel (0.0-1.0). |
| g | Green channel (0.0-1.0). |
| b | Blue channel (0.0-1.0). |
| a | Alpha channel (0.0-1.0, default 1.0). |
- Returns
- The equivalent Color.
Definition at line 49 of file color.h.
◆ from_hex()
| static Color asw::Color::from_hex |
( |
const std::string & | hex | ) |
|
|
inlinestatic |
From a hex string (e.g. "#RRGGBBAA") to a Color.
- Parameters
-
| hex | The hex string to convert. |
- Returns
- The equivalent Color.
Definition at line 60 of file color.h.
◆ grayscale()
| Color asw::Color::grayscale |
( |
| ) |
const |
|
inline |
Convert a color to grayscale.
- Parameters
-
| color | The color to convert. |
Definition at line 124 of file color.h.
◆ invert()
| Color asw::Color::invert |
( |
| ) |
const |
|
inline |
Invert a color.
- Returns
- The inverted color.
Definition at line 115 of file color.h.
◆ lighten()
| Color asw::Color::lighten |
( |
float | percentage | ) |
const |
|
inline |
Lighten a color by a given percentage.
- Parameters
-
| percentage | The percentage to lighten (0.0-1.0). |
- Returns
- The lightened color.
Definition at line 82 of file color.h.
◆ with_alpha()
| Color asw::Color::with_alpha |
( |
uint8_t | alpha | ) |
const |
|
inline |
Adjust the alpha of a color.
- Parameters
-
| color | The color to adjust. |
| alpha | The new alpha value (0-255). |
- Returns
- The color with the adjusted alpha.
Definition at line 135 of file color.h.
The documentation for this struct was generated from the following file: