如何计算形状闪光/动作脚本之间的交集? (获得形状的线段和节点?)形状、线段、节点、脚本

2023-09-08 11:57:44 作者:我调教的男人你用的可习惯

我需要计算在闪光/动作脚本两个形状之间的交叉点。 问题是我无法访问形状的节点和片段,以及它们的坐标,所以没有办法,我可以计算出这一点。 你知道的方式?

I need to calculate the intersection between two shapes in flash / action script. The problem is I can't access the shape's nodes and segments, and their coordinates, so there's no way I can calculate this. Do you know a way?

编辑:进一步的解释: 我进口的不规则多边形的EPS文件与形状中有一个影片剪辑。 数学解决问题的方法是微不足道的,但要做到这一点,我需要访问由AS code到节点构成的多边形,我试过没有成功的坐标。 这就是我想要完成的任务。

edit: further explanation: I imported irregular polygons from an EPS file to a movieclip with shapes in it. The mathematical solution to the problem is trivial, but to do that, I need to access by AS code to the coordinates of the nodes that make up the polygons, which I tried with no success. That is what I'm trying to accomplish.

EDIT2:驳回这个问题。 这是不可能的。我申请的解决方法是保存多边形的SVG和分析它们得到节点的列表。然后将反馈该列表闪烁来计算运行时间的交集和地区。

edit2: dismiss this question. It's not possible. The workaround I'm applying is to save the polygons in SVG and parse them to get a list of nodes. then will feed that list to flash to calculate the intersection and areas on runtime.

推荐答案

AFAIK,有没有办法获取的闪光灯任何给定的形状数据。这件事情内部可惜。但是,你还是应该能够通过使用Pixel Bender的内核来计算你的两个形状之间的区域有足够的逼近。使用ShaderJob,您可以运行计算异步,因此不会锁定用户界面。

AFAIK, there's no way of retrieving the data for any given shape in flash. It's something internal unfortunately. However, you should still be able to calculate a sufficient approximation of the area between your two shapes by using a Pixel Bender kernel. Using a ShaderJob, you can run the calculation asynchronously and thus not locking the UI.

我们的想法是这样:

第一形状的捕获位图 第二形状的捕获位图 在使用你的Pixel Bender内核,采用了两个位图作为输入创建的ShaderJob。对于每个像素,内核将计算阉形状相交与否,以及可能有多大。使用的输出信道的计算的结果之一。 承担由此产生的输出,并总括起来作最后的alpha值。

我不知道,如果这是不太麻烦你不是用你的SVG方法,但它是一个替代最少。它的可能的意义来计算两个形状的边界的交点,并只捕获在形状相交矩形的位图。这是一个额外的步骤,但最起码​​它可能更多的内存使用效率,可能更有效的CPU时间方面也是如此。

I'm not sure if this is less of a hassle to you than using your SVG approach, but it's an alternative at least. It might make sense to calculate the intersection of the two shape's bounds and only capture a bitmap of the intersecting rectangles in the shapes. It is an extra step, but at the very least it's likely more memory efficient, possibly more efficient in terms of cpu time as well.