Doly C++ SDK v1.00
Loading...
Searching...
No Matches
Color.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <vector>
4#include <cstdint>
5
17
23
53
59struct Color
60{
62 uint8_t r = 0;
63
65 uint8_t g = 0;
66
68 uint8_t b = 0;
69
77 std::string toString()
78 {
79 return "r[" + std::to_string(r) + "] g[ " + std::to_string(g) + "] b[ " + std::to_string(b) + "]";
80 }
81
89 static Color getColor(uint8_t r, uint8_t g, uint8_t b);
90
103 static Color hexToRgb(std::string hex);
104
111
122
128 static std::string getColorName(ColorCode code);
129
130private:
140 static std::vector<std::string> splitWithCharacters(const std::string& str, int splitLength);
141};
142 // end of group doly_sdk_common
ColorCode
Predefined color identifiers.
Definition Color.h:31
@ SKY_BLUE
Definition Color.h:48
@ BLACK
Definition Color.h:32
@ DARK_BLUE
Definition Color.h:50
@ BLUE
Definition Color.h:49
@ PINK
Definition Color.h:38
@ GOLD
Definition Color.h:40
@ LIME
Definition Color.h:44
@ CYAN
Definition Color.h:47
@ DARK_RED
Definition Color.h:37
@ GRAY
Definition Color.h:34
@ BROWN
Definition Color.h:51
@ ORANGE
Definition Color.h:39
@ YELLOW
Definition Color.h:41
@ GREEN
Definition Color.h:45
@ RED
Definition Color.h:36
@ WHITE
Definition Color.h:33
@ DARK_GREEN
Definition Color.h:46
@ MAGENTA
Definition Color.h:43
@ SALMON
Definition Color.h:35
@ PURPLE
Definition Color.h:42
Simple 8-bit RGB color container and conversion helpers.
Definition Color.h:60
uint8_t g
Green channel (0..255).
Definition Color.h:65
uint8_t b
Blue channel (0..255).
Definition Color.h:68
static Color getColor(uint8_t r, uint8_t g, uint8_t b)
Construct a Color from explicit RGB values.
std::string toString()
Convert this color to a human-readable string.
Definition Color.h:77
static Color getLEDColor(ColorCode code)
Convert a ColorCode to the closest LED-safe color tone.
uint8_t r
Red channel (0..255).
Definition Color.h:62
static Color hexToRgb(std::string hex)
Convert a hex color string to RGB.
static std::string getColorName(ColorCode code)
Get a human-readable name for a color code.
static Color getColor(ColorCode code)
Convert a predefined ColorCode to an RGB Color.