Color
Contains functionality for color conversion.
Public Functions
FORCE_INLINE_FUNCTION uint8_t | getBlueColor(colortype color) |
Gets the blue color part of a color. | |
colortype | getColorFrom24BitHSL(uint8_t hue, uint8_t saturation, uint8_t luminance) |
Convert a given color from HSV (Hue, Saturation, Value) to colortype. | |
colortype | getColorFrom24BitHSV(uint8_t hue, uint8_t saturation, uint8_t value) |
Convert a given color from HSV (Hue, Saturation, Value) to colortype. | |
colortype | getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) |
Generates a color representation to be used on the LCD, based on 24 bit RGB values. | |
FORCE_INLINE_FUNCTION uint8_t | getGreenColor(colortype color) |
Gets the green color part of a color. | |
void | getHSLFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t & hue, uint8_t & saturation, uint8_t & luminance) |
Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value). | |
void | getHSLFromColor(colortype color, uint8_t & hue, uint8_t & saturation, uint8_t & luminance) |
Convert a given colortype color to HSV (Hue, Saturation, Value). | |
void | getHSLFromHSV(uint8_t hue, uint8_t & saturation, uint8_t value, uint8_t & luminance) |
Convert HSV (Hue, Saturation, Value) to HSL (Hue, Saturation, Luminance). | |
void | getHSVFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t & hue, uint8_t & saturation, uint8_t & value) |
Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value). | |
void | getHSVFromColor(colortype color, uint8_t & hue, uint8_t & saturation, uint8_t & value) |
Convert a given colortype color to HSV (Hue, Saturation, Value). | |
void | getHSVFromHSL(uint8_t hue, uint8_t & saturation, uint8_t luminance, uint8_t & value) |
Convert HSL (Hue, Saturation, Luminance) to HSV (Hue, Saturation, Value). | |
FORCE_INLINE_FUNCTION uint8_t | getRedColor(colortype color) |
Gets the red color part of a color. | |
void | getRGBFrom24BitHSL(uint8_t hue, uint8_t saturation, uint8_t luminance, uint8_t & red, uint8_t & green, uint8_t & blue) |
Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue). | |
void | getRGBFrom24BitHSV(uint8_t hue, uint8_t saturation, uint8_t value, uint8_t & red, uint8_t & green, uint8_t & blue) |
Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue). | |
Public Functions Documentation
getBlueColor
static FORCE_INLINE_FUNCTION uint8_t getBlueColor | ( | colortype | color | ) | |
Gets the blue color part of a color.
As this function must work for all color depths, it can be somewhat slow if used in speed critical sections. Consider finding the color in another way, if possible. If the color depth of the display is known, consider using function getBlueFromColor() from the current LCD.
color | The color value. |
The blue part of the color.
getColorFrom24BitHSL
static colortype getColorFrom24BitHSL | ( | uint8_t | hue , | ||
uint8_t | saturation , | ||||
uint8_t | luminance | ||||
) |
Convert a given color from HSV (Hue, Saturation, Value) to colortype.
hue | The input Hue (0 to 255). |
saturation | The input Saturation (0 to 255). |
luminance | The input Value (0 to 255). |
The colortype color.
Note
The conversion is an approximation.
getColorFrom24BitHSV
static colortype getColorFrom24BitHSV | ( | uint8_t | hue , | ||
uint8_t | saturation , | ||||
uint8_t | value | ||||
) |
Convert a given color from HSV (Hue, Saturation, Value) to colortype.
hue | The input Hue (0 to 255). |
saturation | The input Saturation (0 to 255). |
value | The input Value (0 to 255). |
The colortype color.
Note
The conversion is an approximation.
getColorFrom24BitRGB
static colortype getColorFrom24BitRGB | ( | uint8_t | red , | ||
uint8_t | green , | ||||
uint8_t | blue | ||||
) |
Generates a color representation to be used on the LCD, based on 24 bit RGB values.
Depending on your display color bit depth, the color might be interpreted internally as fewer than 24 bits with a loss of color precision.
red | Value of the red part (0-255). |
green | Value of the green part (0-255). |
blue | Value of the blue part (0-255). |
The color representation depending on LCD color format.
Note
This function is not available to call before the LCD has been setup, because the color depth is required. Consider using the function getColorFromRGB for a specific class, e.g. LCD16::getColorFromRGB().
getGreenColor
static FORCE_INLINE_FUNCTION uint8_t getGreenColor | ( | colortype | color | ) | |
Gets the green color part of a color.
As this function must work for all color depths, it can be somewhat slow if used in speed critical sections. Consider finding the color in another way, if possible. If the color depth of the display is known, consider using function getGreenFromColor() from the current LCD.
color | The color value. |
The green part of the color.
getHSLFrom24BitRGB
static void getHSLFrom24BitRGB | ( | uint8_t | red , | ||
uint8_t | green , | ||||
uint8_t | blue , | ||||
uint8_t & | hue , | ||||
uint8_t & | saturation , | ||||
uint8_t & | luminance | ||||
) |
Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value).
red | The input Red (0 to 255). |
green | The input Green (0 to 255). |
blue | The input Blue (0 to 255). |
hue | The output Hue (0 to 255). |
saturation | The output Saturation (0 to 255). |
luminance | The output Value (0 to 255). |
Note
The conversion is an approximation.
getHSLFromColor
static void getHSLFromColor | ( | colortype | color , | ||
uint8_t & | hue , | ||||
uint8_t & | saturation , | ||||
uint8_t & | luminance | ||||
) |
Convert a given colortype color to HSV (Hue, Saturation, Value).
color | The input color. |
hue | The output Hue (0 to 255). |
saturation | The output Saturation (0 to 255). |
luminance | The output Value (0 to 255). |
Note
The conversion is an approximation.
getHSLFromHSV
static void getHSLFromHSV | ( | uint8_t | hue , | ||
uint8_t & | saturation , | ||||
uint8_t | value , | ||||
uint8_t & | luminance | ||||
) |
Convert HSV (Hue, Saturation, Value) to HSL (Hue, Saturation, Luminance).
The Hue is unaltered, the Saturation is changed and the Luminance is calculated.
hue | The hue (0 to 255). |
saturation | The saturation (0 to 255). |
value | The value (0 to 255). |
luminance | The luminance (0 to 255). |
getHSVFrom24BitRGB
static void getHSVFrom24BitRGB | ( | uint8_t | red , | ||
uint8_t | green , | ||||
uint8_t | blue , | ||||
uint8_t & | hue , | ||||
uint8_t & | saturation , | ||||
uint8_t & | value | ||||
) |
Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value).
red | The input Red. |
green | The input Green. |
blue | The input Blue. |
hue | The output Hue. |
saturation | The output Saturation. |
value | The output Value. |
Note
The conversion is an approximation.
getHSVFromColor
static void getHSVFromColor | ( | colortype | color , | ||
uint8_t & | hue , | ||||
uint8_t & | saturation , | ||||
uint8_t & | value | ||||
) |
Convert a given colortype color to HSV (Hue, Saturation, Value).
color | The input color. |
hue | The output Hue (0 to 255). |
saturation | The output Saturation (0 to 255). |
value | The output Value (0 to 255). |
Note
The conversion is an approximation.
getHSVFromHSL
static void getHSVFromHSL | ( | uint8_t | hue , | ||
uint8_t & | saturation , | ||||
uint8_t | luminance , | ||||
uint8_t & | value | ||||
) |
Convert HSL (Hue, Saturation, Luminance) to HSV (Hue, Saturation, Value).
The Hue is unaltered, the Saturation is changed and the Value is calculated.
hue | The hue (0 to 255). |
saturation | The saturation (0 to 255). |
luminance | The luminance (0 to 255). |
value | The value (0 to 255). |
getRedColor
static FORCE_INLINE_FUNCTION uint8_t getRedColor | ( | colortype | color | ) | |
Gets the red color part of a color.
As this function must work for all color depths, it can be somewhat slow if used in speed critical sections. Consider finding the color in another way, if possible. If the color depth of the display is known, consider using function getRedFromColor() from the current LCD.
color | The color value. |
The red part of the color.
getRGBFrom24BitHSL
static void getRGBFrom24BitHSL | ( | uint8_t | hue , | ||
uint8_t | saturation , | ||||
uint8_t | luminance , | ||||
uint8_t & | red , | ||||
uint8_t & | green , | ||||
uint8_t & | blue | ||||
) |
Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue).
hue | The input Hue (0 to 255). |
saturation | The input Saturation (0 to 255). |
luminance | The input Value (0 to 255). |
red | The output Red (0 to 255). |
green | The output Green (0 to 255). |
blue | The output Blue (0 to 255). |
Note
The conversion is an approximation.
getRGBFrom24BitHSV
static void getRGBFrom24BitHSV | ( | uint8_t | hue , | ||
uint8_t | saturation , | ||||
uint8_t | value , | ||||
uint8_t & | red , | ||||
uint8_t & | green , | ||||
uint8_t & | blue | ||||
) |
Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue).
hue | The input Hue (0 to 255). |
saturation | The input Saturation (0 to 255). |
value | The input Value (0 to 255). |
red | The output Red (0 to 255). |
green | The output Green (0 to 255). |
blue | The output Blue (0 to 255). |
Note
The conversion is an approximation.