Issue #20: fixed stroke scaling handling
- better handling of getting stroke scaling from matrix
This commit is contained in:
parent
205d5197d2
commit
4101587c9a
@ -767,6 +767,13 @@ static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const f
|
||||
return grad;
|
||||
}
|
||||
|
||||
static float nsvg__getAverageScale(float* t)
|
||||
{
|
||||
float sx = sqrtf(t[0]*t[0] + t[2]*t[2]);
|
||||
float sy = sqrtf(t[1]*t[1] + t[3]*t[3]);
|
||||
return (sx + sy) * 0.5f;
|
||||
}
|
||||
|
||||
static void nsvg__addShape(NSVGparser* p)
|
||||
{
|
||||
NSVGattrib* attr = nsvg__getAttr(p);
|
||||
@ -781,7 +788,7 @@ static void nsvg__addShape(NSVGparser* p)
|
||||
if (shape == NULL) goto error;
|
||||
memset(shape, 0, sizeof(NSVGshape));
|
||||
|
||||
scale = nsvg__maxf(fabsf(attr->xform[0]), fabsf(attr->xform[3]));
|
||||
scale = nsvg__getAverageScale(attr->xform);
|
||||
shape->strokeWidth = attr->strokeWidth * scale;
|
||||
shape->strokeLineJoin = attr->strokeLineJoin;
|
||||
shape->strokeLineCap = attr->strokeLineCap;
|
||||
|
Loading…
Reference in New Issue
Block a user