2012-09-11 59 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];