MCPcopy Create free account
hub / github.com/MapServer/MapServer / parse_color

Function parse_color

renderers/agg/src/agg_svg_parser.cpp:420–450  ·  view source on GitHub ↗

-------------------------------------------------------------

Source from the content-addressed store, hash-verified

418
419 //-------------------------------------------------------------
420 rgba8 parse_color(const char* str)
421 {
422 while(*str == ' ') ++str;
423 unsigned c = 0;
424 if(*str == '#')
425 {
426 sscanf(str + 1, "%x", &c);
427 return rgb8_packed(c);
428 }
429 else
430 {
431 named_color c;
432 unsigned len = strlen(str);
433 if(len > sizeof(c.name) - 1)
434 {
435 throw exception("parse_color: Invalid color name '%s'", str);
436 }
437 strcpy(c.name, str);
438 const void* p = bsearch(&c,
439 colors,
440 sizeof(colors) / sizeof(colors[0]),
441 sizeof(colors[0]),
442 cmp_color);
443 if(p == 0)
444 {
445 throw exception("parse_color: Invalid color name '%s'", str);
446 }
447 const named_color* pc = (const named_color*)p;
448 return rgba8(pc->r, pc->g, pc->b, pc->a);
449 }
450 }
451
452 double parse_double(const char* str)
453 {

Callers 1

parse_attrMethod · 0.85

Calls 3

rgb8_packedFunction · 0.85
exceptionClass · 0.85
rgba8Class · 0.85

Tested by

no test coverage detected