Revert "Revert "change circle radius percentage calculation""

This reverts commit f717d8bd93.
This commit is contained in:
Horcrux
2016-04-27 16:49:23 +08:00
parent f717d8bd93
commit 6ad74e3287
8 changed files with 49 additions and 21 deletions
+14 -1
View File
@@ -30,7 +30,20 @@
// draw circle
CGFloat cx = [self getActualProp:@"cx" relative:width];
CGFloat cy = [self getActualProp:@"cy" relative:height];
CGFloat r = [self getActualProp:@"r" relative:height];
CGFloat r;
// radius in percentage calculate formula:
// radius = sqrt(pow((width*percent), 2) + pow((height*percent), 2)) / sqrt(2)
NSDictionary *prop = [self.shape objectForKey:@"r"];
CGFloat value = [[prop objectForKey:@"value"] floatValue];
if ([[prop objectForKey:@"percentage"] integerValue] == 1) {
r = sqrt(pow((width * value), 2) + pow((height * value), 2)) / sqrt(2);
} else {
r = value;
}
CGPathAddArc(path, nil, cx, cy, r, -M_PI, M_PI, YES);
break;
}