Actionscript 3 - 路径重叠

时间:2012-07-03 02:11:32

标签: actionscript-3 vector-graphics

我对Actionscript 3有点新。我在flash中构建一个svg导出/导入,需要使预览的行为与svg相同。在闪存中,如果路径重叠,则将其删除。如何让它填满整个区域?

使用以下方法创建路径:

object.graphics.moveTo(xpos[i], ypos[i]);
object.graphics.lineTo(px, py);

结果为enter image description here

1 个答案:

答案 0 :(得分:3)

这是由图形路径缠绕引起的。

graphics-path-winding

Defining winding rules
flash.diplay.GraphicsPathWinding

在Flash中,默认的缠绕规则甚至是奇数。

对于使用drawPath生成的图形,请将GraphicsPathWinding.NON_ZERO缠绕添加到drawPath:

import flash.display.GraphicsPathWinding;

graphics.drawPath(new <int>[], new <Number>[], GraphicsPathWinding.NON_ZERO);

对于使用lineTo()drawCircle()drawRect()等便捷方法绘制的图形,您可以绘制每个形状beginFill()endFill(),如下所示:

enter image description here

var g:Graphics = graphics;

g.beginFill(0x123456)
g.drawRect(100, 100, 50, 50);
g.endFill();

g.beginFill(0x123456)
g.drawRect(125, 125, 50, 50);
g.endFill();

而不是:

even-odd

var g:Graphics = graphics;

g.beginFill(0x123456)
g.drawRect(100, 100, 50, 50);
g.drawRect(125, 125, 50, 50);
g.endFill();