Subtract (mask away?) a path by a circle shape

最后都变了- 提交于 2019-12-24 00:45:02

问题


I'm drawing a path in Flex using Spark:Path.

I want to subtract a circle shape from this path, as in the following image:

(The path is black and wide)

Any ideas?

I tried creating a mask using a Shape object but couldn't quite manage to create a mask that has a circular hole in it.


回答1:


Found it.

No masks involved.

I took the Path and wrapped a Group around it:

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

I set the blendMode to "layer" and added an ellipse after the path with blendMode erase




回答2:


You don't need to use a mask for this, just use the curveTo() method of the Graphics class:

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();

Which gives you:

This is obviously not using your exact dimensions, but demonstrates the principle.



来源:https://stackoverflow.com/questions/10029613/subtract-mask-away-a-path-by-a-circle-shape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!