我对 Actionscript 3 有点陌生。我正在 Flash 中构建 svg 导出/导入,需要使预览的行为与 svg 相同。在 Flash 中,如果路径重叠,则将其删除。如何让它填满整个区域?
路径是这样创建的:
object.graphics.moveTo(xpos[i], ypos[i]);
object.graphics.lineTo(px, py);
结果是
我对 Actionscript 3 有点陌生。我正在 Flash 中构建 svg 导出/导入,需要使预览的行为与 svg 相同。在 Flash 中,如果路径重叠,则将其删除。如何让它填满整个区域?
路径是这样创建的:
object.graphics.moveTo(xpos[i], ypos[i]);
object.graphics.lineTo(px, py);
结果是
这是由图形路径缠绕引起的。
定义缠绕规则
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()
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();
代替:
var g:Graphics = graphics;
g.beginFill(0x123456)
g.drawRect(100, 100, 50, 50);
g.drawRect(125, 125, 50, 50);
g.endFill();