2012-09-11 52 views
0

我正在绘制应用程序,该应用程序根据绘制速度提供可变线宽的绘制线。这种行为受Paper应用程序的启发。如何填充两个UIBezierPath之间的空间

算法,我试图实现 - 绘制两个贝塞尔路径之间的可变距离。在sosborn's answer中描述的解决方案。然后平滑路径并填充它们之间的距离。

其实我不知道如何填充路径之间的空间。

回答

1

创建从2条贝塞尔曲线的单一路径和填充它,像这样:

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];