MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / nsvg__parseColorRGB

Function nsvg__parseColorRGB

rEFIt_UEFI/libeg/nanosvg.cpp:1303–1339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1301}
1302
1303static unsigned int nsvg__parseColorRGB(const char* str)
1304{
1305 int r = -1, g = -1, b = -1;
1306 float fr, fg, fb;
1307 char *s1 = NULL;
1308 AsciiStrToFloat(str+4, &s1, &fr);
1309 if (*s1 == '%') {
1310 r = (int)(fr * 2.55f);
1311 str = s1 + 2;
1312 } else if (*s1 == ',') {
1313 r = (int)fr;
1314 str = s1 + 1;
1315 } else {
1316 //error
1317 DBG("StrFloat error:%s\n", str);
1318 return NSVG_RGB(0,0,0);
1319 }
1320 AsciiStrToFloat(str, &s1, &fg);
1321 if (*s1 == '%') {
1322 g = (int)(fg * 2.55f);
1323 str = s1 + 2;
1324 } else if (*s1 == ',') {
1325 g = (int)fg;
1326 str = s1 + 1;
1327 } else {
1328 //error
1329 DBG("StrFloat error:%s\n", str);
1330 return NSVG_RGB(0,0,0);
1331 }
1332 AsciiStrToFloat(str, &s1, &fb);
1333 if (*s1 == '%') {
1334 b = (int)(fb * 2.55f);
1335 } else {
1336 b = (int)fb;
1337 }
1338 return NSVG_RGB(r,g,b);
1339}
1340
1341typedef struct NSVGNamedColor {
1342 const char* name;

Callers 1

nsvg__parseColorFunction · 0.85

Calls 1

AsciiStrToFloatFunction · 0.85

Tested by

no test coverage detected