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

Function nsvg__parseRect

rEFIt_UEFI/libeg/nanosvg.cpp:2581–2631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2579}
2580
2581static void nsvg__parseRect(NSVGparser* p, const char** attr)
2582{
2583 float x = 0.0f;
2584 float y = 0.0f;
2585 float w = 0.0f;
2586 float h = 0.0f;
2587 float rx = -1.0f; // marks not set
2588 float ry = -1.0f;
2589 int i;
2590
2591 for (i = 0; attr[i]; i += 2) {
2592 if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
2593 else if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
2594 else if (strcmp(attr[i], "width") == 0) w = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p));
2595 else if (strcmp(attr[i], "height") == 0) h = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p));
2596 else if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
2597 else if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
2598 else nsvg__parseAttr(p, attr[i], attr[i + 1]);
2599 }
2600
2601 if (rx < 0.0f && ry > 0.0f) rx = ry;
2602 if (ry < 0.0f && rx > 0.0f) ry = rx;
2603 if (rx < 0.0f) rx = 0.0f;
2604 if (ry < 0.0f) ry = 0.0f;
2605 if (rx > w/2.0f) rx = w/2.0f;
2606 if (ry > h/2.0f) ry = h/2.0f;
2607
2608 if (w != 0.0f && h != 0.0f) {
2609 nsvg__resetPath(p);
2610
2611 if (rx < 0.00001f || ry < 0.0001f) {
2612 nsvg__moveTo(p, x, y);
2613 nsvg__lineTo(p, x+w, y);
2614 nsvg__lineTo(p, x+w, y+h);
2615 nsvg__lineTo(p, x, y+h);
2616 } else {
2617 // Rounded rectangle
2618 nsvg__moveTo(p, x+rx, y);
2619 nsvg__lineTo(p, x+w-rx, y);
2620 nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry);
2621 nsvg__lineTo(p, x+w, y+h-ry);
2622 nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h);
2623 nsvg__lineTo(p, x+rx, y+h);
2624 nsvg__cubicBezTo(p, x+rx*(1-NSVG_KAPPA90), y+h, x, y+h-ry*(1-NSVG_KAPPA90), x, y+h-ry);
2625 nsvg__lineTo(p, x, y+ry);
2626 nsvg__cubicBezTo(p, x, y+ry*(1-NSVG_KAPPA90), x+rx*(1-NSVG_KAPPA90), y, x+rx, y);
2627 }
2628 nsvg__addPath(p, 1);
2629 nsvg__addShape(p);
2630 }
2631}
2632
2633static void nsvg__parseUse(NSVGparser* p, const char** dict)
2634{

Callers 1

nsvg__startElementFunction · 0.85

Calls 14

nsvg__parseCoordinateFunction · 0.85
nsvg__actualOrigXFunction · 0.85
nsvg__actualWidthFunction · 0.85
nsvg__actualOrigYFunction · 0.85
nsvg__actualHeightFunction · 0.85
fabsfFunction · 0.85
nsvg__parseAttrFunction · 0.85
nsvg__resetPathFunction · 0.85
nsvg__moveToFunction · 0.85
nsvg__lineToFunction · 0.85
nsvg__cubicBezToFunction · 0.85
nsvg__addPathFunction · 0.85

Tested by

no test coverage detected