The color sys module supports handling RGB and HSV color.
More...
The color sys module supports handling RGB and HSV color.
|
file | color.h |
| Headers for the color handling module.
|
|
|
void | color_rgb2hsv (color_rgb_t *rgb, color_hsv_t *hsv) |
| Convert RGB color to HSV color. More...
|
|
void | color_hsv2rgb (color_hsv_t *hsv, color_rgb_t *rgb) |
| Convert HSV color to RGB color. More...
|
|
void | color_hex2rgb (const uint32_t hex, color_rgb_t *rgb) |
| Convert a hex value of the form 0x00RRGGBB to an RGB color struct. More...
|
|
void | color_rgb2hex (const color_rgb_t *rgb, uint32_t *hex) |
| Convert a rgb struct to a hex value of the form 0x00RRGGBB. More...
|
|
void | color_str2rgb (const char *str, color_rgb_t *color) |
| Convert a hex color string of the form 'RRGGBB' to a color_rgb_t struct. More...
|
|
void | color_rgb2str (const color_rgb_t *rgb, char *str) |
| Convert a color_rgb_t struct to a hex color string of the form 'RRGGBB'. More...
|
|
static void | color_rgb_invert (const color_rgb_t *rgb, color_rgb_t *inv_rgb) |
| Invert a given rgb color. More...
|
|
static void | color_rgb_shift (const color_rgb_t *rgb, color_rgb_t *out, int8_t shift) |
| Shifts a given rgb color to change it's brightness. More...
|
|
static void | color_rgb_set_brightness (const color_rgb_t *rgb, color_rgb_t *out, uint8_t level) |
| Change the brightness of a RGB color by multiplying it with a set factor. More...
|
|
void | color_rgb_complementary (const color_rgb_t *rgb, color_rgb_t *comp_rgb) |
| Calculate the complementary color of a given rgb color. More...
|
|
◆ color_hex2rgb()
void color_hex2rgb |
( |
const uint32_t |
hex, |
|
|
color_rgb_t * |
rgb |
|
) |
| |
Convert a hex
value of the form 0x00RRGGBB to an RGB color struct.
- Note
- the two most significant bytes of
hex
will be ignored
- Parameters
-
[in] | hex | Input color encoded in hex |
[out] | rgb | Output color encoded in RGB space |
◆ color_hsv2rgb()
Convert HSV color to RGB color.
- Parameters
-
[in] | hsv | Input color encoded in HSV space |
[out] | rgb | Output color encoded in RGB space |
◆ color_rgb2hex()
void color_rgb2hex |
( |
const color_rgb_t * |
rgb, |
|
|
uint32_t * |
hex |
|
) |
| |
Convert a rgb
struct to a hex
value of the form 0x00RRGGBB.
- Note
- the two most significant bytes of
hex
will be 0
- Parameters
-
[in] | rgb | Input color encoded in RGB space |
[out] | hex | Output color encoded in hex |
◆ color_rgb2hsv()
Convert RGB color to HSV color.
- Parameters
-
[in] | rgb | Input color encoded in RGB space |
[out] | hsv | Output color encoded in HSV space |
◆ color_rgb2str()
void color_rgb2str |
( |
const color_rgb_t * |
rgb, |
|
|
char * |
str |
|
) |
| |
Convert a color_rgb_t struct to a hex color string of the form 'RRGGBB'.
- Note
str
MUST be big enough to hold 6 characters
- Parameters
-
[in] | rgb | Input color encoded in RGB space |
[out] | str | Output color encoded as string of the form 'RRGGBB' |
◆ color_rgb_complementary()
Calculate the complementary color of a given rgb color.
- Note
- Complementary color calculation according to adobe illustator calculations. See https://helpx.adobe.com/illustrator/using/adjusting-colors.html
- Precondition
- ((rgb != NULL) && (comp_rgb != NULL))
- Parameters
-
[in] | rgb | Input rgb color. Must be NOT NULL |
[out] | comp_rgb | Output rgb color, result of the complementary color calculation. Must be NOT NULL |
◆ color_rgb_invert()
Invert a given rgb color.
- Precondition
- ((rgb != NULL) && (inv_rgb != NULL))
- Parameters
-
[in] | rgb | Input rgb color, that should be converted. Must be NOT NULL |
[out] | inv_rgb | Output rgb color, result of the conversion. Must be NOT NULL |
Definition at line 123 of file color.h.
◆ color_rgb_set_brightness()
Change the brightness of a RGB color by multiplying it with a set factor.
- Precondition
- ((rgb != NULL) && (out != NULL))
- Parameters
-
[in] | rgb | Input rgb color, that should be multiplied. Must be NOT NULL |
[out] | out | Output rgb color. Must be NOT NULL |
[in] | level | New brightness level. 255 = Full Brightness, 0 = Off. |
Definition at line 162 of file color.h.
◆ color_rgb_shift()
Shifts a given rgb color to change it's brightness.
- Precondition
- ((rgb != NULL) && (out != NULL))
- Parameters
-
[in] | rgb | Input rgb color, that should be shifted. Must be NOT NULL |
[out] | out | Output rgb color, result of the shift. Must be NOT NULL |
[in] | shift | Amount by which the color components should be shifted. May be positive (shift to left) or negative (shift to right). |
Definition at line 140 of file color.h.
◆ color_str2rgb()
void color_str2rgb |
( |
const char * |
str, |
|
|
color_rgb_t * |
color |
|
) |
| |
Convert a hex color string of the form 'RRGGBB' to a color_rgb_t struct.
- Note
str
MUST contain only hexadecimal digits. Expect unexpected behaviour, otherwise.
- Parameters
-
[in] | str | Input color encoded as string of the form 'RRGGBB' |
[out] | color | Output color encoded in RGB space |