Joined lines at certain angles have pointed vertexes instead of rounded

烈酒焚心 提交于 2019-12-10 19:19:18

问题


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:

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.


回答1:


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).



来源:https://stackoverflow.com/questions/20307817/joined-lines-at-certain-angles-have-pointed-vertexes-instead-of-rounded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!