Union UIBezierPaths而不是Apend路径 [英] Union UIBezierPaths rather than apend path
问题描述
我有一个应用程序,我在其中使用UIBezierPath并通过一系列appendPath:调用将其用作画笔。在经历了几次并且具有非常复杂的刷子形状之后,内存耗尽并且应用程序停止运行。我真正想做的是完全一样的联合,就像Paint Code一样,但我找不到任何方法这样做。
I have an app where I take a UIBezierPath and use it as a brush by a series of appendPath: calls. After a few goes and with really complex brush shapes the memory runs out and the app grinds to a halt. What I really want to do is a full on union exactly like Paint Code does but I can't find any way of doing this.
我如何组合两个或更多UIBezierPaths?
How would I go about unioning two or more UIBezierPaths?
编辑:
以下是我想要动态实现的视觉效果。
Here is a visual of what I want to achieve dynamically.
在Paint Code中,您将采用两条路径并将它们重叠如下:
In Paint Code you take two paths and overlap them like this:
但是我想要将它们合并/合并为一个新的单一路径,如:
BUT I want to merge / union them into one new single path like:
请注意,在Paint Code的底部面板中,现在有一个单一形状的代码,这就是我想要的以编程方式获得1000条原始路径。
Note that in the bottom panel of Paint Code there is code for now one single shape and this is what I want to be able to get to programatically with maybe 1000 original paths.
推荐答案
最后解决方案!!
使用 https://github.com/adamwulf/ClippingBezier ,您可以找到交叉点点。然后你可以走过这条路,顺时针方向向左转,反之亦然,留在外面。然后,您可以使用点序列生成新路径。
Using https://github.com/adamwulf/ClippingBezier you can find the intersecting points. Then you can walk through the path, turning left if clockwise or vice-versa to stay on the outside. Then you can generate a new path using the sequence of points.
这篇关于Union UIBezierPaths而不是Apend路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!