Fix relative strokeWidth and relativeOnOther usage.

This commit is contained in:
Mikael Sand
2017-08-25 14:34:00 +03:00
parent c6028e825d
commit 6cc3f76b24
2 changed files with 4 additions and 17 deletions
+2 -1
View File
@@ -213,7 +213,8 @@
}
if (self.stroke) {
CGContextSetLineWidth(context, [self.strokeWidth floatValue]);
CGFloat width = [self relativeOnOther:self.strokeWidth];
CGContextSetLineWidth(context, width);
CGContextSetLineCap(context, self.strokeLinecap);
CGContextSetLineJoin(context, self.strokeLinejoin);
RNSVGCGFloatArray dash = self.strokeDasharrayData;
+2 -16
View File
@@ -43,22 +43,8 @@
CGMutablePathRef path = CGPathCreateMutable();
CGFloat cx = [self relativeOnWidth:self.cx];
CGFloat cy = [self relativeOnHeight:self.cy];
CGFloat r;
// radius percentage calculate formula:
// radius = sqrt(pow((width*percent), 2) + pow((height*percent), 2)) / sqrt(2)
if ([RNSVGPercentageConverter isPercentage:self.r]) {
CGFloat radiusPercent = [RNSVGPercentageConverter percentageToFloat:self.r relative:1 offset:0];
r = sqrt(
pow([self getContextWidth] * radiusPercent, 2) +
pow([self getContextHeight] * radiusPercent, 2)
) / sqrt(2);
} else {
r = [self.r floatValue];
}
CGPathAddArc(path, nil, cx, cy, r, 0, 2*M_PI, NO);
CGFloat r = [self relativeOnOther:self.r];
CGPathAddArc(path, nil, cx, cy, r, 0, 2 * M_PI, NO);
return (CGPathRef)CFAutorelease(path);
}