請參閱圖片。我怎樣才能得到兩條線的交點(即綠色圓點)?我想剪裁圖像的內部部分。關閉路徑是行中的任何地方。如何在iPhone SDK中找到閉合路徑(雙線交叉點)?
context = UIGraphicsGetCurrentContext();
CGContextBeginPath(context);
CGContextSetLineWidth(context, 1.0 * self.scale);
CGContextSetLineCap(context, kCGLineCapRound);
[[UIColor redColor] setStroke];
CGPoint firstPoint = CGPointFromString([self.touchPoints objectAtIndex:0]);
CGContextMoveToPoint(context, firstPoint.x, firstPoint.y);
for (NSString *pointString in self.touchPoints) {
CGPoint point = CGPointFromString(pointString);
CGContextAddLineToPoint(context, point.x, point.y);
}
CGContextStrokePath(context);
此代碼用於繪製線條。線條圖工作正常,裁剪也工作正常......但交叉點是我的主要問題。請幫幫我。
喜摩尼已經找到了這個問題的解決方案,如果ü好心做幫我解決這個問題 – hari