Doly C++ SDK v1.00
Loading...
Searching...
No Matches
Color Struct Reference

Simple 8-bit RGB color container and conversion helpers. More...

#include <Color.h>

Public Member Functions

std::string toString ()
 Convert this color to a human-readable string.

Static Public Member Functions

static Color getColor (uint8_t r, uint8_t g, uint8_t b)
 Construct a Color from explicit RGB values.
static Color hexToRgb (std::string hex)
 Convert a hex color string to RGB.
static Color getColor (ColorCode code)
 Convert a predefined ColorCode to an RGB Color.
static Color getLEDColor (ColorCode code)
 Convert a ColorCode to the closest LED-safe color tone.
static std::string getColorName (ColorCode code)
 Get a human-readable name for a color code.

Public Attributes

uint8_t r = 0
 Red channel (0..255).
uint8_t g = 0
 Green channel (0..255).
uint8_t b = 0
 Blue channel (0..255).

Detailed Description

Simple 8-bit RGB color container and conversion helpers.

Values are stored in 8-bit channels (0..255).

Member Function Documentation

◆ getColor() [1/2]

Color Color::getColor ( ColorCode code)
static

Convert a predefined ColorCode to an RGB Color.

Parameters
codePredefined color identifier.
Returns
RGB Color corresponding to the code.

◆ getColor() [2/2]

Color Color::getColor ( uint8_t r,
uint8_t g,
uint8_t b )
static

Construct a Color from explicit RGB values.

Parameters
rRed channel (0..255).
gGreen channel (0..255).
bBlue channel (0..255).
Returns
Color instance with the given channels.
Examples
LedControl/main.cpp.

◆ getColorName()

std::string Color::getColorName ( ColorCode code)
static

Get a human-readable name for a color code.

Parameters
codePredefined color identifier.
Returns
Color name (e.g., "COLOR_BLACK").

◆ getLEDColor()

Color Color::getLEDColor ( ColorCode code)
static

Convert a ColorCode to the closest LED-safe color tone.

Some LED hardware has limited color gamut and brightness curves. This function returns a color tone tuned for the LEDs.

Parameters
codePredefined color identifier.
Returns
RGB Color best suited for LED output.

◆ hexToRgb()

Color Color::hexToRgb ( std::string hex)
static

Convert a hex color string to RGB.

Typical supported formats are implementation-defined, but commonly include:

  • "#RRGGBB"
  • "RRGGBB"
Parameters
hexHex string.
Returns
Parsed Color.
Note
Behavior on invalid input is implementation-defined.

◆ toString()

std::string Color::toString ( )
inline

Convert this color to a human-readable string.

Example output: r[10] g[20] b[30]

Returns
String representation of the color.

Member Data Documentation

◆ b

uint8_t Color::b = 0

Blue channel (0..255).

◆ g

uint8_t Color::g = 0

Green channel (0..255).

◆ r

uint8_t Color::r = 0

Red channel (0..255).


The documentation for this struct was generated from the following file: