Question

My app allows you to draw using a variety of tools. One of them lets you make an angle: you tap three times, then an angle is drawn for you. Unfortunately, it gets really pointy but then rounded again at certain angles for some reason. I'm using

CGContextSetLineCap(context, kCGLineCapRound);

Here is a picture to exemplify what I'm talking about:

enter image description here

Does anyone know what causes this or how to fix it so it is round all the time??

For the most part, all I do is:

CGContextMoveToPoint(context, first.x, first.y);
CGContextAddLineToPoint(context, second.x, second.y);
CGContextAddLineToPoint(context, third.x, third.y);

then stroke.

Was it helpful?

Solution

That's controlled by your line join style, not your line cap style.

CGContextSetLineJoin(context, kCGLineJoinRound);

The default line join style is miter, and it looks like you're hitting the miter limit, which is why it becomes round at some angle. (See CGContextSetMiterLimit).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top