Go to the source code of this file.
|
|
typedef uint16_t | ui::color_t |
| | An RGB565 color value. 5 bits red, 6 bits green, 5 bits blue.
|
| |
|
| enum | {
ui::COLOR_WHITE = 0xffff
, ui::COLOR_BLACK = 0x0000
, ui::COLOR_GRAY = 0x7bef
, ui::COLOR_RED = 0xe000
,
ui::COLOR_ORANGE = 0xfbe0
, ui::COLOR_YELLOW = 0xffe0
, ui::COLOR_GREEN = 0x07e0
, ui::COLOR_CYAN = 0x07ff
,
ui::COLOR_BLUE = 0x001f
, ui::COLOR_PURPLE = 0x381f
, ui::COLOR_MAGENTA = 0xf81f
, ui::COLOR_LIGHT_GRAY = 0xd69a
,
ui::COLOR_LIGHT_RED = 0xe534
, ui::COLOR_LIGHT_ORANGE = 0xfe11
, ui::COLOR_LIGHT_YELLOW = 0xfff7
, ui::COLOR_LIGHT_GREEN = 0xa7f4
,
ui::COLOR_LIGHT_CYAN = 0xa7ff
, ui::COLOR_LIGHT_BLUE = 0x853f
, ui::COLOR_PINK = 0xfd3f
} |
| | A preset list of common colors. More...
|
| |
|
| constexpr float | ui::clampColor (const float color) |
| | Clamp a normalized color component inside 0 and 1, inclusive.
|
| |
| constexpr color_t | ui::color (const float red, const float green, const float blue) |
| | Convert normalized color components into an RGB565 value.
|
| |
| constexpr color_t | ui::rgb (const uint8_t red, const uint8_t green, const uint8_t blue) |
| | Convert single-byte color components into an RGB565 value.
|
| |
| color_t | ui::hsv (const int hue, const float saturation, const float value) |
| | Convert HSV color components into an RGB565 value.
|
| |
| void | ui::hsvComponents (color_t color, int &hue, float &saturation, float &value) |
| | Convert an RGB565 value into HSV color components.
|
| |
| void | ui::colorComponents (color_t color, float &red, float &green, float &blue) |
| | Split an RGB565 color value into normalized components.
|
| |
| color_t | ui::blend (color_t color1, color_t color2, float ratio=0.5f) |
| | Blend two colors, preserving apparent brightness.
|
| |
◆ anonymous enum
A preset list of common colors.
| Enumerator |
|---|
| COLOR_WHITE |
|
| COLOR_BLACK |
|
| COLOR_GRAY |
|
| COLOR_RED |
|
| COLOR_ORANGE |
|
| COLOR_YELLOW |
|
| COLOR_GREEN |
|
| COLOR_CYAN |
|
| COLOR_BLUE |
|
| COLOR_PURPLE |
|
| COLOR_MAGENTA |
|
| COLOR_LIGHT_GRAY |
|
| COLOR_LIGHT_RED |
|
| COLOR_LIGHT_ORANGE |
|
| COLOR_LIGHT_YELLOW |
|
| COLOR_LIGHT_GREEN |
|
| COLOR_LIGHT_CYAN |
|
| COLOR_LIGHT_BLUE |
|
| COLOR_PINK |
|
◆ blend()
| color_t ui::blend |
( |
color_t |
color1, |
|
|
color_t |
color2, |
|
|
float |
ratio = 0.5f |
|
) |
| |
Blend two colors, preserving apparent brightness.
- Parameters
-
| color1 | The first color. |
| color2 | The second color. |
| ratio | The ratio of the second color to blend into the first. E.g. 0.2 will use 20% of the second color and 80% of the first color. |
- Returns
- A color value between the two colors at the given ratio.
◆ clampColor()
| constexpr float ui::clampColor |
( |
const float |
color | ) |
|
|
constexpr |
Clamp a normalized color component inside 0 and 1, inclusive.
- Parameters
-
| color | The normalized color component, where 0 is fully dark and 1 is fully bright. |
- Returns
- The color component clamped to within 0 and 1.
◆ color()
| constexpr color_t ui::color |
( |
const float |
red, |
|
|
const float |
green, |
|
|
const float |
blue |
|
) |
| |
|
constexpr |
Convert normalized color components into an RGB565 value.
- Parameters
-
| red | The normalized red component. |
| green | The normalized green component. |
| blue | The normalized blue component. |
- Returns
- The equivalent RGB565 color value.
◆ colorComponents()
| void ui::colorComponents |
( |
color_t |
color, |
|
|
float & |
red, |
|
|
float & |
green, |
|
|
float & |
blue |
|
) |
| |
Split an RGB565 color value into normalized components.
- Parameters
-
| color | The RGB565 color to split. |
| red | The normalized red component to output. |
| green | The normalized green component to output. |
| blue | The normalized blue component to output. |
◆ hsv()
| color_t ui::hsv |
( |
const int |
hue, |
|
|
const float |
saturation, |
|
|
const float |
value |
|
) |
| |
Convert HSV color components into an RGB565 value.
- Parameters
-
| hue | The hue component, assumed to be in the range 0-359 inclusive. |
| saturation | The saturation component, assumed to be within 0.0-1.0 inclusive. |
| value | The value component, assumed to be within 0.0-1.0 inclusive. |
- Returns
- The equivalent RGB565 color value.
◆ hsvComponents()
| void ui::hsvComponents |
( |
color_t |
color, |
|
|
int & |
hue, |
|
|
float & |
saturation, |
|
|
float & |
value |
|
) |
| |
Convert an RGB565 value into HSV color components.
- Parameters
-
| color | The RGB565 color to split. |
| hue | The hue component to output. |
| saturation | The saturation component to output. |
| value | The value component to output. |
◆ rgb()
| constexpr color_t ui::rgb |
( |
const uint8_t |
red, |
|
|
const uint8_t |
green, |
|
|
const uint8_t |
blue |
|
) |
| |
|
constexpr |
Convert single-byte color components into an RGB565 value.
- Parameters
-
| red | The red component. |
| green | The green component. |
| blue | The blue component. |
- Returns
- The equivalent RGB565 color value.