static Color colorFromName(const char *name) { for(size_t i=0; i < sizeof(colorNames)/sizeof(colorNames[0]); i++) { const ColorName &c=colorNames[i]; if (strcmp(c.name, name)==0) { return Color(c.r, c.g, c.b, 0xFF); } } return Color(255,255,255,255); }
Color colorFromString(const char *name_or_rgb) { if (name_or_rgb[0] == '#') { unsigned c; if (sscanf(name_or_rgb, "#%X", &c)!=1) return Color(255,255,255,255); return Color(c>>16, (c>>8)&0xFF, c&0xFF, 0xFF); } else if (strncmp(name_or_rgb, "rgb(", 4)==0) {