两个UIBezierPaths交集作为UIBezierPath [英] Two UIBezierPaths intersection as a UIBezierPath
问题描述
我有两个 UIBezierPath
s,一个代表图像部分的多边形,另一个是要在其上绘制的路径。
I have two UIBezierPath
s, one that represents the polygon of part of an image and the other is a path to be drawn on top of it.
我需要找到它们之间的交点,这样只有这个交叉区域内的点才会被着色。
I need to find the intersection between them so that only the point that are inside this intersection area will be colored.
UIBezierPath
中是否有方法可以在两条路径之间找到交叉点或新路径?
Is there a method in UIBezierPath
that can find intersection points - or a new path - between two paths ?
推荐答案
我写了一个UIBezierPath库,它允许你根据交叉路径将给定的闭合路径切割成子形状。它基本上完全符合您的要求: https://github.com/adamwulf/ClippingBezier
I wrote a UIBezierPath library that will let you cut a given closed path into sub shapes based on an intersecting path. It'll do essentially exactly what you're looking for: https://github.com/adamwulf/ClippingBezier
NSArray<UIBezierPath*>* componentShapes = [shapePath uniqueShapesCreatedFromSlicingWithUnclosedPath:scissorPath];
或者,您也可以找到交叉点:
Alternatively, you can also just find the intersection points:
NSArray* intersections = [scissorPath findIntersectionsWithClosedPath:shapePath andBeginsInside:nil];
这篇关于两个UIBezierPaths交集作为UIBezierPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!