Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/memononen/nanosvg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Tyberg <mark@maptext.com>2017-03-11 07:14:10 +0300
committerMark Tyberg <mark@maptext.com>2017-03-11 07:14:10 +0300
commit2f132b7ad8b520576fda4c75cc13200b3433bef4 (patch)
tree77ce83fad6c26d349237304ad50484b47fde2059 /src
parentdc12d90586a8ab99da0c575aafff999666aa5d55 (diff)
addded support for stroke-miterlimit
Diffstat (limited to 'src')
-rw-r--r--src/nanosvg.h14
-rw-r--r--src/nanosvgrast.h2
2 files changed, 15 insertions, 1 deletions
diff --git a/src/nanosvg.h b/src/nanosvg.h
index a6c6015..109c2bf 100644
--- a/src/nanosvg.h
+++ b/src/nanosvg.h
@@ -145,6 +145,7 @@ typedef struct NSVGshape
char strokeDashCount; // Number of dash values in dash array.
char strokeLineJoin; // Stroke join type.
char strokeLineCap; // Stroke cap type.
+ float miterLimit; // Miter limit
char fillRule; // Fill rule, see NSVGfillRule.
unsigned char flags; // Logical or of NSVG_FLAGS_* flags
float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy].
@@ -413,6 +414,7 @@ typedef struct NSVGattrib
int strokeDashCount;
char strokeLineJoin;
char strokeLineCap;
+ float miterLimit;
char fillRule;
float fontSize;
unsigned int stopColor;
@@ -620,6 +622,7 @@ static NSVGparser* nsvg__createParser()
p->attr[0].strokeWidth = 1;
p->attr[0].strokeLineJoin = NSVG_JOIN_MITER;
p->attr[0].strokeLineCap = NSVG_CAP_BUTT;
+ p->attr[0].miterLimit = 4;
p->attr[0].fillRule = NSVG_FILLRULE_NONZERO;
p->attr[0].hasFill = 1;
p->attr[0].visible = 1;
@@ -938,6 +941,7 @@ static void nsvg__addShape(NSVGparser* p)
shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
shape->strokeLineJoin = attr->strokeLineJoin;
shape->strokeLineCap = attr->strokeLineCap;
+ shape->miterLimit = attr->miterLimit;
shape->fillRule = attr->fillRule;
shape->opacity = attr->opacity;
@@ -1353,6 +1357,14 @@ static float nsvg__parseOpacity(const char* str)
return val;
}
+static float nsvg__parseMiterLimit(const char* str)
+{
+ float val = 0;
+ sscanf(str, "%f", &val);
+ if (val < 0.0f) val = 0.0f;
+ return val;
+}
+
static int nsvg__parseUnits(const char* units)
{
if (units[0] == 'p' && units[1] == 'x')
@@ -1679,6 +1691,8 @@ static int nsvg__parseAttr(NSVGparser* p, const char* name, const char* value)
attr->strokeLineCap = nsvg__parseLineCap(value);
} else if (strcmp(name, "stroke-linejoin") == 0) {
attr->strokeLineJoin = nsvg__parseLineJoin(value);
+ } else if (strcmp(name, "stroke-miterlimit") == 0) {
+ attr->miterLimit = nsvg__parseMiterLimit(value);
} else if (strcmp(name, "fill-rule") == 0) {
attr->fillRule = nsvg__parseFillRule(value);
} else if (strcmp(name, "font-size") == 0) {
diff --git a/src/nanosvgrast.h b/src/nanosvgrast.h
index c71d7b4..08db3d9 100644
--- a/src/nanosvgrast.h
+++ b/src/nanosvgrast.h
@@ -732,7 +732,7 @@ static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float
int i, j, closed;
NSVGpath* path;
NSVGpoint* p0, *p1;
- float miterLimit = 4;
+ float miterLimit = shape->miterLimit;
int lineJoin = shape->strokeLineJoin;
int lineCap = shape->strokeLineCap;
float lineWidth = shape->strokeWidth * scale;