| 1498 | }; |
| 1499 | |
| 1500 | static unsigned int nsvg__parseColorName(const char* str) |
| 1501 | { |
| 1502 | int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor); |
| 1503 | // DBG("namedcolor=%d\n", sizeof(NSVGNamedColor)); |
| 1504 | #if 0 |
| 1505 | for (i = 0; i < ncolors; i++) { |
| 1506 | if (strcmp(nsvg__colors[i].name, str) == 0) { |
| 1507 | return nsvg__colors[i].color; |
| 1508 | } |
| 1509 | } |
| 1510 | #else |
| 1511 | int low, high, med; |
| 1512 | INTN res; |
| 1513 | low = 10; |
| 1514 | high = ncolors - 1; |
| 1515 | for (i = 0; i < 10; i++) { |
| 1516 | if (strcmp(nsvg__colors[i].name, str) == 0) { |
| 1517 | return nsvg__colors[i].color; |
| 1518 | } |
| 1519 | } |
| 1520 | |
| 1521 | while (low <= high) |
| 1522 | { |
| 1523 | med = (low + high) / 2; |
| 1524 | res = strcmp(nsvg__colors[med].name, str); |
| 1525 | if(res < 0) |
| 1526 | low = med + 1; |
| 1527 | else if (res > 0) |
| 1528 | high = med - 1; |
| 1529 | else |
| 1530 | return nsvg__colors[med].color; |
| 1531 | } |
| 1532 | #endif |
| 1533 | |
| 1534 | return NSVG_RGB(128, 128, 128); //if not found then Grey50% |
| 1535 | } |
| 1536 | |
| 1537 | static unsigned int nsvg__parseColor(const char* str) |
| 1538 | { |
no test coverage detected