Lines Matching refs:attr
256 void (*startelCb)(void* ud, const char* el, const char** attr), in nsvg__parseElement() argument
260 const char* attr[NSVG_XML_MAX_ATTRIBS]; in nsvg__parseElement() local
315 attr[nattr++] = name; in nsvg__parseElement()
316 attr[nattr++] = value; in nsvg__parseElement()
321 attr[nattr++] = 0; in nsvg__parseElement()
322 attr[nattr++] = 0; in nsvg__parseElement()
326 (*startelCb)(ud, name, attr); in nsvg__parseElement()
332 void (*startelCb)(void* ud, const char* el, const char** attr), in nsvg__parseXML() argument
446 NSVGattrib attr[NSVG_MAX_ATTR]; member
631 nsvg__xformIdentity(p->attr[0].xform); in nsvg__createParser()
632 memset(p->attr[0].id, 0, sizeof p->attr[0].id); in nsvg__createParser()
633 p->attr[0].fillColor = NSVG_RGB(0,0,0); in nsvg__createParser()
634 p->attr[0].strokeColor = NSVG_RGB(0,0,0); in nsvg__createParser()
635 p->attr[0].opacity = 1; in nsvg__createParser()
636 p->attr[0].fillOpacity = 1; in nsvg__createParser()
637 p->attr[0].strokeOpacity = 1; in nsvg__createParser()
638 p->attr[0].stopOpacity = 1; in nsvg__createParser()
639 p->attr[0].strokeWidth = 1; in nsvg__createParser()
640 p->attr[0].strokeLineJoin = NSVG_JOIN_MITER; in nsvg__createParser()
641 p->attr[0].strokeLineCap = NSVG_CAP_BUTT; in nsvg__createParser()
642 p->attr[0].miterLimit = 4; in nsvg__createParser()
643 p->attr[0].fillRule = NSVG_FILLRULE_NONZERO; in nsvg__createParser()
644 p->attr[0].hasFill = 1; in nsvg__createParser()
645 p->attr[0].visible = 1; in nsvg__createParser()
746 return &p->attr[p->attrHead]; in nsvg__getAttr()
753 memcpy(&p->attr[p->attrHead], &p->attr[p->attrHead-1], sizeof(NSVGattrib)); in nsvg__pushAttr()
791 NSVGattrib* attr = nsvg__getAttr(p); in nsvg__convertToPixels() local
800 case NSVG_UNITS_EM: return c.value * attr->fontSize; in nsvg__convertToPixels()
801 case NSVG_UNITS_EX: return c.value * attr->fontSize * 0.52f; // x-height of Helvetica. in nsvg__convertToPixels()
821 NSVGattrib* attr = nsvg__getAttr(p); in nsvg__createGradient() local
889 nsvg__xformMultiply(grad->xform, attr->xform); in nsvg__createGradient()
939 NSVGattrib* attr = nsvg__getAttr(p); in nsvg__addShape() local
952 memcpy(shape->id, attr->id, sizeof shape->id); in nsvg__addShape()
953 scale = nsvg__getAverageScale(attr->xform); in nsvg__addShape()
954 shape->strokeWidth = attr->strokeWidth * scale; in nsvg__addShape()
955 shape->strokeDashOffset = attr->strokeDashOffset * scale; in nsvg__addShape()
956 shape->strokeDashCount = (char)attr->strokeDashCount; in nsvg__addShape()
957 for (i = 0; i < attr->strokeDashCount; i++) in nsvg__addShape()
958 shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale; in nsvg__addShape()
959 shape->strokeLineJoin = attr->strokeLineJoin; in nsvg__addShape()
960 shape->strokeLineCap = attr->strokeLineCap; in nsvg__addShape()
961 shape->miterLimit = attr->miterLimit; in nsvg__addShape()
962 shape->fillRule = attr->fillRule; in nsvg__addShape()
963 shape->opacity = attr->opacity; in nsvg__addShape()
981 if (attr->hasFill == 0) { in nsvg__addShape()
983 } else if (attr->hasFill == 1) { in nsvg__addShape()
985 shape->fill.color = attr->fillColor; in nsvg__addShape()
986 shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24; in nsvg__addShape()
987 } else if (attr->hasFill == 2) { in nsvg__addShape()
989 nsvg__xformInverse(inv, attr->xform); in nsvg__addShape()
991 …shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type); in nsvg__addShape()
998 if (attr->hasStroke == 0) { in nsvg__addShape()
1000 } else if (attr->hasStroke == 1) { in nsvg__addShape()
1002 shape->stroke.color = attr->strokeColor; in nsvg__addShape()
1003 shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24; in nsvg__addShape()
1004 } else if (attr->hasStroke == 2) { in nsvg__addShape()
1006 nsvg__xformInverse(inv, attr->xform); in nsvg__addShape()
1008 …shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke… in nsvg__addShape()
1014 shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00); in nsvg__addShape()
1031 NSVGattrib* attr = nsvg__getAttr(p); in nsvg__addPath() local
1054 nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform); in nsvg__addPath()
1718 NSVGattrib* attr = nsvg__getAttr(p); in nsvg__parseAttr() local
1719 if (!attr) return 0; in nsvg__parseAttr()
1725 attr->visible = 0; in nsvg__parseAttr()
1730 attr->hasFill = 0; in nsvg__parseAttr()
1732 attr->hasFill = 2; in nsvg__parseAttr()
1733 nsvg__parseUrl(attr->fillGradient, value); in nsvg__parseAttr()
1735 attr->hasFill = 1; in nsvg__parseAttr()
1736 attr->fillColor = nsvg__parseColor(value); in nsvg__parseAttr()
1739 attr->opacity = nsvg__parseOpacity(value); in nsvg__parseAttr()
1741 attr->fillOpacity = nsvg__parseOpacity(value); in nsvg__parseAttr()
1744 attr->hasStroke = 0; in nsvg__parseAttr()
1746 attr->hasStroke = 2; in nsvg__parseAttr()
1747 nsvg__parseUrl(attr->strokeGradient, value); in nsvg__parseAttr()
1749 attr->hasStroke = 1; in nsvg__parseAttr()
1750 attr->strokeColor = nsvg__parseColor(value); in nsvg__parseAttr()
1753 attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); in nsvg__parseAttr()
1755 attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray); in nsvg__parseAttr()
1757 attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); in nsvg__parseAttr()
1759 attr->strokeOpacity = nsvg__parseOpacity(value); in nsvg__parseAttr()
1761 attr->strokeLineCap = nsvg__parseLineCap(value); in nsvg__parseAttr()
1763 attr->strokeLineJoin = nsvg__parseLineJoin(value); in nsvg__parseAttr()
1765 attr->miterLimit = nsvg__parseMiterLimit(value); in nsvg__parseAttr()
1767 attr->fillRule = nsvg__parseFillRule(value); in nsvg__parseAttr()
1769 attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); in nsvg__parseAttr()
1772 nsvg__xformPremultiply(attr->xform, xform); in nsvg__parseAttr()
1774 attr->stopColor = nsvg__parseColor(value); in nsvg__parseAttr()
1776 attr->stopOpacity = nsvg__parseOpacity(value); in nsvg__parseAttr()
1778 attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f); in nsvg__parseAttr()
1780 strncpy(attr->id, value, 63); in nsvg__parseAttr()
1781 attr->id[63] = '\0'; in nsvg__parseAttr()
1841 static void nsvg__parseAttribs(NSVGparser* p, const char** attr) in nsvg__parseAttribs() argument
1844 for (i = 0; attr[i]; i += 2) in nsvg__parseAttribs()
1846 if (strcmp(attr[i], "style") == 0) in nsvg__parseAttribs()
1847 nsvg__parseStyle(p, attr[i + 1]); in nsvg__parseAttribs()
1849 nsvg__parseAttr(p, attr[i], attr[i + 1]); in nsvg__parseAttribs()
2183 static void nsvg__parsePath(NSVGparser* p, const char** attr) in nsvg__parsePath() argument
2196 for (i = 0; attr[i]; i += 2) { in nsvg__parsePath()
2197 if (strcmp(attr[i], "d") == 0) { in nsvg__parsePath()
2198 s = attr[i + 1]; in nsvg__parsePath()
2200 tmp[0] = attr[i]; in nsvg__parsePath()
2201 tmp[1] = attr[i + 1]; in nsvg__parsePath()
2315 static void nsvg__parseRect(NSVGparser* p, const char** attr) in nsvg__parseRect() argument
2325 for (i = 0; attr[i]; i += 2) { in nsvg__parseRect()
2326 if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { in nsvg__parseRect()
2327 …if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg_… in nsvg__parseRect()
2328 …if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg_… in nsvg__parseRect()
2329 …if (strcmp(attr[i], "width") == 0) w = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth… in nsvg__parseRect()
2330 …if (strcmp(attr[i], "height") == 0) h = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeig… in nsvg__parseRect()
2331 …if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualW… in nsvg__parseRect()
2332 …if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualH… in nsvg__parseRect()
2370 static void nsvg__parseCircle(NSVGparser* p, const char** attr) in nsvg__parseCircle() argument
2377 for (i = 0; attr[i]; i += 2) { in nsvg__parseCircle()
2378 if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { in nsvg__parseCircle()
2379 …if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsv… in nsvg__parseCircle()
2380 …if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsv… in nsvg__parseCircle()
2381 …if (strcmp(attr[i], "r") == 0) r = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualLen… in nsvg__parseCircle()
2400 static void nsvg__parseEllipse(NSVGparser* p, const char** attr) in nsvg__parseEllipse() argument
2408 for (i = 0; attr[i]; i += 2) { in nsvg__parseEllipse()
2409 if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { in nsvg__parseEllipse()
2410 …if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsv… in nsvg__parseEllipse()
2411 …if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsv… in nsvg__parseEllipse()
2412 …if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualW… in nsvg__parseEllipse()
2413 …if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualH… in nsvg__parseEllipse()
2433 static void nsvg__parseLine(NSVGparser* p, const char** attr) in nsvg__parseLine() argument
2441 for (i = 0; attr[i]; i += 2) { in nsvg__parseLine()
2442 if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { in nsvg__parseLine()
2443 …if (strcmp(attr[i], "x1") == 0) x1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), n… in nsvg__parseLine()
2444 …if (strcmp(attr[i], "y1") == 0) y1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), n… in nsvg__parseLine()
2445 …if (strcmp(attr[i], "x2") == 0) x2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), n… in nsvg__parseLine()
2446 …if (strcmp(attr[i], "y2") == 0) y2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), n… in nsvg__parseLine()
2460 static void nsvg__parsePoly(NSVGparser* p, const char** attr, int closeFlag) in nsvg__parsePoly() argument
2470 for (i = 0; attr[i]; i += 2) { in nsvg__parsePoly()
2471 if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { in nsvg__parsePoly()
2472 if (strcmp(attr[i], "points") == 0) { in nsvg__parsePoly()
2473 s = attr[i + 1]; in nsvg__parsePoly()
2496 static void nsvg__parseSVG(NSVGparser* p, const char** attr) in nsvg__parseSVG() argument
2499 for (i = 0; attr[i]; i += 2) { in nsvg__parseSVG()
2500 if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { in nsvg__parseSVG()
2501 if (strcmp(attr[i], "width") == 0) { in nsvg__parseSVG()
2502 p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); in nsvg__parseSVG()
2503 } else if (strcmp(attr[i], "height") == 0) { in nsvg__parseSVG()
2504 p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); in nsvg__parseSVG()
2505 } else if (strcmp(attr[i], "viewBox") == 0) { in nsvg__parseSVG()
2506 const char *s = attr[i + 1]; in nsvg__parseSVG()
2522 } else if (strcmp(attr[i], "preserveAspectRatio") == 0) { in nsvg__parseSVG()
2523 if (strstr(attr[i + 1], "none") != 0) { in nsvg__parseSVG()
2528 if (strstr(attr[i + 1], "xMin") != 0) in nsvg__parseSVG()
2530 else if (strstr(attr[i + 1], "xMid") != 0) in nsvg__parseSVG()
2532 else if (strstr(attr[i + 1], "xMax") != 0) in nsvg__parseSVG()
2535 if (strstr(attr[i + 1], "yMin") != 0) in nsvg__parseSVG()
2537 else if (strstr(attr[i + 1], "yMid") != 0) in nsvg__parseSVG()
2539 else if (strstr(attr[i + 1], "yMax") != 0) in nsvg__parseSVG()
2543 if (strstr(attr[i + 1], "slice") != 0) in nsvg__parseSVG()
2551 static void nsvg__parseGradient(NSVGparser* p, const char** attr, char type) in nsvg__parseGradient() argument
2572 for (i = 0; attr[i]; i += 2) { in nsvg__parseGradient()
2573 if (strcmp(attr[i], "id") == 0) { in nsvg__parseGradient()
2574 strncpy(grad->id, attr[i+1], 63); in nsvg__parseGradient()
2576 } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { in nsvg__parseGradient()
2577 if (strcmp(attr[i], "gradientUnits") == 0) { in nsvg__parseGradient()
2578 if (strcmp(attr[i+1], "objectBoundingBox") == 0) in nsvg__parseGradient()
2582 } else if (strcmp(attr[i], "gradientTransform") == 0) { in nsvg__parseGradient()
2583 nsvg__parseTransform(grad->xform, attr[i + 1]); in nsvg__parseGradient()
2584 } else if (strcmp(attr[i], "cx") == 0) { in nsvg__parseGradient()
2585 grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2586 } else if (strcmp(attr[i], "cy") == 0) { in nsvg__parseGradient()
2587 grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2588 } else if (strcmp(attr[i], "r") == 0) { in nsvg__parseGradient()
2589 grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2590 } else if (strcmp(attr[i], "fx") == 0) { in nsvg__parseGradient()
2591 grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2592 } else if (strcmp(attr[i], "fy") == 0) { in nsvg__parseGradient()
2593 grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2594 } else if (strcmp(attr[i], "x1") == 0) { in nsvg__parseGradient()
2595 grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2596 } else if (strcmp(attr[i], "y1") == 0) { in nsvg__parseGradient()
2597 grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2598 } else if (strcmp(attr[i], "x2") == 0) { in nsvg__parseGradient()
2599 grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2600 } else if (strcmp(attr[i], "y2") == 0) { in nsvg__parseGradient()
2601 grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]); in nsvg__parseGradient()
2602 } else if (strcmp(attr[i], "spreadMethod") == 0) { in nsvg__parseGradient()
2603 if (strcmp(attr[i+1], "pad") == 0) in nsvg__parseGradient()
2605 else if (strcmp(attr[i+1], "reflect") == 0) in nsvg__parseGradient()
2607 else if (strcmp(attr[i+1], "repeat") == 0) in nsvg__parseGradient()
2609 } else if (strcmp(attr[i], "xlink:href") == 0) { in nsvg__parseGradient()
2610 const char *href = attr[i+1]; in nsvg__parseGradient()
2621 static void nsvg__parseGradientStop(NSVGparser* p, const char** attr) in nsvg__parseGradientStop() argument
2632 for (i = 0; attr[i]; i += 2) { in nsvg__parseGradientStop()
2633 nsvg__parseAttr(p, attr[i], attr[i + 1]); in nsvg__parseGradientStop()
2663 static void nsvg__startElement(void* ud, const char* el, const char** attr) in nsvg__startElement() argument
2670 nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT); in nsvg__startElement()
2672 nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT); in nsvg__startElement()
2674 nsvg__parseGradientStop(p, attr); in nsvg__startElement()
2681 nsvg__parseAttribs(p, attr); in nsvg__startElement()
2686 nsvg__parsePath(p, attr); in nsvg__startElement()
2690 nsvg__parseRect(p, attr); in nsvg__startElement()
2694 nsvg__parseCircle(p, attr); in nsvg__startElement()
2698 nsvg__parseEllipse(p, attr); in nsvg__startElement()
2702 nsvg__parseLine(p, attr); in nsvg__startElement()
2706 nsvg__parsePoly(p, attr, 0); in nsvg__startElement()
2710 nsvg__parsePoly(p, attr, 1); in nsvg__startElement()
2713 nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT); in nsvg__startElement()
2715 nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT); in nsvg__startElement()
2717 nsvg__parseGradientStop(p, attr); in nsvg__startElement()
2721 nsvg__parseSVG(p, attr); in nsvg__startElement()