2012-04-05 124 views
2

我在使用Spark:Path在Flex中绘制路径。减去(遮罩?)一个圆形的路径

我想从这个路径减去一个圆形,如下图所示:

enter image description here

(路径为黑色和宽)

任何想法?

我尝试使用Shape对象创建一个遮罩,但无法完全设法创建一个具有圆孔的遮罩。

回答

8

找到它。

不涉及任何口罩。

我把Path和包裹Group周围:

<s:Group blendMode="layer"> 
    <s:Path id="connector" ... /> 
    <s:Ellipse id="hole" blendMode="erase"> 

我设置blendMode为“层”和后添加一个椭圆用的BlendMode路径erase

+1

不错的flex-y解决方案。 – shanethehat 2012-04-05 14:26:34

+0

今天我学到了一些新东西。不知道这些混合模式。 – RIAstar 2012-04-05 14:35:13

2

你并不需要使用这种面膜,只需使用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(); 

它给你:

enter image description here

这显然不是使用你的确切尺寸,但是展示了原理。

+0

我不画与形状 - 我只是想掩盖它。我的路径对象是一个Spark:Path,它需要是一个Spark:Path,因为我要为它添加过滤器等等。所以我有了这个Path对象,我想在这个对象中以圆形形状“咬” 。希望现在更清楚。 – 2012-04-05 14:01:37

+0

@gigantt - 我不太确定任何有关Flex的细节,但更笼统地说,您仍然可以使用上面的代码,使用Path的尺寸来设置形状的尺寸。然后将此形状作为蒙版应用于您的路径。希望这也适用于Spark:Path。 – shanethehat 2012-04-05 14:12:01