gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
color.hpp File Reference

Go to the source code of this file.

Typedefs

typedef uint16_t ui::color_t
 An RGB565 color value. 5 bits red, 6 bits green, 5 bits blue.
 

Enumerations

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...
 

Functions

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.
 

Enumeration Type Documentation

◆ anonymous enum

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 

Function Documentation

◆ blend()

color_t ui::blend ( color_t  color1,
color_t  color2,
float  ratio = 0.5f 
)

Blend two colors, preserving apparent brightness.

Parameters
color1The first color.
color2The second color.
ratioThe 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
colorThe 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
redThe normalized red component.
greenThe normalized green component.
blueThe 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
colorThe RGB565 color to split.
redThe normalized red component to output.
greenThe normalized green component to output.
blueThe 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
hueThe hue component, assumed to be in the range 0-359 inclusive.
saturationThe saturation component, assumed to be within 0.0-1.0 inclusive.
valueThe 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
colorThe RGB565 color to split.
hueThe hue component to output.
saturationThe saturation component to output.
valueThe 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
redThe red component.
greenThe green component.
blueThe blue component.
Returns
The equivalent RGB565 color value.