【发布时间】:2012-04-19 06:03:54
【问题描述】:
我正在使用 Spark:Path 在 Flex 中绘制路径。
我想从这条路径中减去一个圆形,如下图所示:
(路径是黑色和宽的)
有什么想法吗?
我尝试使用 Shape 对象创建蒙版,但无法创建具有圆形孔的蒙版。
【问题讨论】:
标签: actionscript-3 flash apache-flex graphics
我正在使用 Spark:Path 在 Flex 中绘制路径。
我想从这条路径中减去一个圆形,如下图所示:
(路径是黑色和宽的)
有什么想法吗?
我尝试使用 Shape 对象创建蒙版,但无法创建具有圆形孔的蒙版。
【问题讨论】:
标签: actionscript-3 flash apache-flex graphics
找到了。
不涉及面具。
我拿了Path 并在它周围包裹了一个Group:
<s:Group blendMode="layer">
<s:Path id="connector" ... />
<s:Ellipse id="hole" blendMode="erase">
我将blendMode 设置为“图层”,并在路径之后添加了一个椭圆 使用混合模式erase
【讨论】:
您不需要为此使用掩码,只需使用 Graphics 类的 curveTo() 方法即可:
var shape1:Shape = new Shape();
shape1.graphics.beginFill(0x000000);
shape1.graphics.moveTo(0,0);
shape1.graphics.lineTo(80,0);
shape1.graphics.curveTo(110,30,140,0);
shape1.graphics.lineTo(300,0);
shape1.graphics.lineTo(300,20);
shape1.graphics.lineTo(0,20);
shape1.graphics.lineTo(0,0);
shape1.graphics.endFill();
这给了你:
这显然不是使用您的确切尺寸,而是展示了原理。
【讨论】: