本文介绍了如何填充两个UIBezierPath之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在绘制应用程序,它提供了具有可变线宽的绘制线,这取决于绘制速度。这种行为受到Paper app的启发。
I'm working on drawing application which provides drawing lines with variable line width which depends on drawing speed. This behavior inspired by Paper app.
我正在尝试实现的算法 - 绘制两条bezier路径,它们之间的距离可变。 中描述的解决方案。然后平滑路径并填充它们之间的距离。
Algorithm which I'm trying to implement -- draw two bezier path with variable distance between them. The solution which described in sosborn's answer. Then smooth paths and fill the distance between them.
实际上我并没有弄清楚如何填充路径之间的空间。
Actually I don't figured out how to fill space between paths.
推荐答案
您从2条贝塞尔曲线创建一条路径并填充它,如下所示:
You create a single path from the 2 bezier curves and fill it, like this:
NSBezierPath* path = [NSBezierPath bezierPath];
// Move to the start point
[path moveToPoint:startPt];
// Make the lower part of the curve
[path curveToPoint:endPt controlPoint1:cp1 controlPoint2:cp2];
// Make the upper part of the curve as part of the same path:
[path curveToPoint:startPt contorPoint1:cp3 controlPoint2:cp4];
// Now fill it
[path fill];
这篇关于如何填充两个UIBezierPath之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!