Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i add arc at CGPathGetCurrentPoint?
    text
    copied!<p>I am drawing Donut Chart.I am using <code>CGPath</code> to draw and after drawing adding it to <code>CAShapeLayer</code>. First I draw an outer arc and then draw line toward centre, now I want to add arc to my current point. </p> <p>Screenshot of this is below.</p> <p><img src="https://i.stack.imgur.com/XsFdF.png" alt="enter image description here"></p> <p>See smaller arc should be at the end of line. </p> <p>My code, </p> <pre><code>for (int j = 0; j &lt; numSubject; j++) { int valueForSubject = [datasource valueOfSubjectAtIndex:j andLevel:i inDonutChartView:self]; endAngle = [self angleInRadianFromSubjectValue:valueForSubject]; DLog(@"Angle - %f",RADIANS_TO_DEGREES(endAngle)) //path CGMutablePathRef path = CGPathCreateMutable(); CGPathAddArc(path, NULL, prevPoint.x, prevPoint.y, radius, startAngle, endAngle, NO); CGPoint currentPoint = CGPathGetCurrentPoint(path); //find angles from start point to center and end point to center CGFloat angle1 = [self angleFromFirstPoint:prevPoint secondPoint:centerPoint]; CGFloat angle2 = [self angleFromFirstPoint:CGPathGetCurrentPoint(path) secondPoint:centerPoint]; double endX1 = cos(angle1) * LEVEL_WIDTH + prevPoint.x; double endY1 = sin(angle1) * LEVEL_WIDTH + prevPoint.y; double endX2 = cos(angle2) * LEVEL_WIDTH + CGPathGetCurrentPoint(path).x; double endY2 = sin(angle2) * LEVEL_WIDTH + CGPathGetCurrentPoint(path).y; //first connect current point to end2 point then draw arc and then connect to end1 CGPathAddLineToPoint(path, NULL, endX2, endY2); //CGPathAddArcToPoint(path, NULL, CGPathGetCurrentPoint(path).x, CGPathGetCurrentPoint(path).y, endX2, endY2, radius - LEVEL_WIDTH); CGPathAddArc(path, NULL, CGPathGetCurrentPoint(path).x , CGPathGetCurrentPoint(path).y, radius - LEVEL_WIDTH, endAngle, startAngle, YES); //CGPathAddLineToPoint(path, NULL, endX1, endY1); //CGPathCloseSubpath(path); A3DonutChartShapeLayer* arcLayer = [[A3DonutChartShapeLayer alloc]init]; arcLayer.path = path; //arcLayer.frame = CGPathGetBoundingBox(path); arcLayer.lineWidth = BORDER_WIDTH; arcLayer.strokeColor = [UIColor blackColor].CGColor; arcLayer.fillColor = [UIColor clearColor].CGColor; [self.layer addSublayer:arcLayer]; </code></pre> <p>Any pointers?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload