28 #define MAX_HTML_COLOR_NAME_LEN 21
32 #define pgm_read_ptr(addr) (*reinterpret_cast<const void* const *>(addr))
51 static uint8_t
Count();
61 static uint8_t
Count();
86 Color =
static_cast<uint32_t
>(color.
R) << 16 |
static_cast<uint32_t
>(color.
G) << 8 |
static_cast<uint32_t
>(color.
B);
107 return !(*
this == other);
137 template <
typename T_HTMLCOLORNAMES>
size_t Parse(
const char* name,
size_t nameSize)
146 uint8_t tempSize = 0;
148 for (uint8_t indexChar = 1; indexChar < nameSize && indexChar < 8; ++indexChar)
150 char c = name[indexChar];
151 if (c >=
'0' && c <=
'9')
160 if (c >=
'a' && c <=
'f')
176 if (tempSize != 3 && tempSize != 6)
184 for (uint8_t indexChar = 0; indexChar < tempSize; ++indexChar)
186 color = color * 16 + temp[indexChar];
191 color = color * 16 + temp[indexChar];
205 for (uint8_t indexName = 0; indexName < T_HTMLCOLORNAMES::Count(); ++indexName)
207 const HtmlColorPair* colorPair = T_HTMLCOLORNAMES::Pair(indexName);
208 PGM_P searchName =
reinterpret_cast<PGM_P
>(
pgm_read_ptr(&(colorPair->
Name)));
209 size_t str1Size = nameSize;
210 const char* str1 = name;
211 const char* str2P = searchName;
217 char ch1 = tolower(*str1++);
218 char ch2 = tolower(pgm_read_byte(str2P++));
220 if (result != 0 || ch2 ==
'\0')
222 if (ch2 ==
'\0' && !isalnum(ch1))
238 return nameSize - str1Size;
247 template <
typename T_HTMLCOLORNAMES>
size_t Parse(
const char* name)
252 template <
typename T_HTMLCOLORNAMES>
size_t Parse(String
const &name)
254 return Parse<T_HTMLCOLORNAMES>(name.c_str(), name.length() + 1);
273 template <
typename T_HTMLCOLORNAMES>
size_t ToString(
char* buf,
size_t bufSize)
const
276 for (uint8_t indexName = 0; indexName < T_HTMLCOLORNAMES::Count(); ++indexName)
278 const HtmlColorPair* colorPair = T_HTMLCOLORNAMES::Pair(indexName);
279 if (pgm_read_dword(&colorPair->
Color) ==
Color)
282 strncpy_P(buf, name, bufSize);
283 return strlen_P(name);
#define pgm_read_ptr(addr)
Definition: HtmlColor.h:32
#define MAX_HTML_COLOR_NAME_LEN
Definition: HtmlColor.h:28
Definition: HtmlColor.h:58
static uint8_t Count()
Definition: HtmlColorNames.cpp:191
static const HtmlColorPair * Pair(uint8_t index)
Definition: HtmlColorNames.cpp:186
Definition: HtmlColor.h:48
static uint8_t Count()
Definition: HtmlColorShortNames.cpp:62
static const HtmlColorPair * Pair(uint8_t index)
Definition: HtmlColorShortNames.cpp:57
Definition: HtmlColor.h:39
uint32_t Color
Definition: HtmlColor.h:41
PGM_P Name
Definition: HtmlColor.h:40
Definition: HtmlColor.h:70
size_t ToString(char *buf, size_t bufSize) const
Definition: HtmlColor.h:273
bool operator!=(const HtmlColor &other) const
Definition: HtmlColor.h:105
size_t ToNumericalString(char *buf, size_t bufSize) const
Definition: HtmlColor.cpp:39
size_t Parse(const char *name, size_t nameSize)
Definition: HtmlColor.h:137
uint32_t Color
Definition: HtmlColor.h:331
bool operator==(const HtmlColor &other) const
Definition: HtmlColor.h:100
HtmlColor(const RgbColor &color)
Definition: HtmlColor.h:84
size_t Parse(String const &name)
Definition: HtmlColor.h:252
HtmlColor()
Definition: HtmlColor.h:93
size_t Parse(const char *name)
Definition: HtmlColor.h:247
static HtmlColor BilinearBlend(const HtmlColor &c00, const HtmlColor &c01, const HtmlColor &c10, const HtmlColor &c11, float x, float y)
Definition: HtmlColor.h:315
HtmlColor(uint32_t color)
Definition: HtmlColor.h:76
Definition: RgbColor.h:36
uint8_t G
Definition: RgbColor.h:247
uint8_t B
Definition: RgbColor.h:248
uint8_t R
Definition: RgbColor.h:246
static RgbColor BilinearBlend(const RgbColor &c00, const RgbColor &c01, const RgbColor &c10, const RgbColor &c11, float x, float y)
Definition: RgbColor.cpp:181