Actionscript 3 中重叠圆形对象的过滤器

发布于 2024-11-25 09:28:14 字数 376 浏览 2 评论 0原文

基本上我有x个圆圈表示为MovieClips。 它们都分配有相同的基色(例如红色)。 它们都应该具有从 0 到 1 的亮度属性(0 表示全白,1 表示全红)。

我想要以下属性来在舞台上表示这些圆圈:

  1. 当圆圈不重叠时,它们的表示方式如上所述。
  2. 当圆圈重叠时,重叠区域应具有与原始圆圈相同的基色,但该区域的亮度应为定义重叠的所有圆圈的亮度之和。
  3. 亮度在 1 处饱和。因此,亮度为 0.8 的 2 个圆的重叠是 1(最大值),而不是 1.6。

我想知道是否可以在圆圈上使用某种 BitmapFilter 来实现这些属性?或者我找错地方了?

我对 Actionscript 比较陌生,所以欢迎任何指点!

Basically i have x circles represented as MovieClips.
They are all assigned the same base color (for example red).
They should all have a brightness property ranging from 0 to 1 (0 would be completely white and 1 completely red).

I would like the following properties for representing these circles on stage:

  1. When the circles dont overlap they are represented as stated above.
  2. When the circles overlap the overlapping region should have the same base color as the original circles but the brightness of that area should be the sum of the brightnesses of all the circles that define the overlap.
  3. The brightness saturates at 1. So the overlap of 2 circles with brightness 0.8 is 1 (the maximum value) instead of 1.6.

I am wondering if there is some kind of BitmapFilter i could use on the circles to achieve these properties? Or am I looking in the wrong place?

I am relatively new to Actionscript so any pointers are welcome!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

从来不烧饼 2024-12-02 09:28:14

您好,欢迎来到 SO 和 AS3!

我将分别讨论每一点:

1) 非常简单,您可能已经发现“addChild()”会将 MovieClip 对象添加到显示列表中,这意味着 Flash 将在每一帧中渲染它们。

2) 最简单的方法是通过“混合模式”,这是 Adob​​e 处理重叠显示对象的方法。

http://help.adobe.com /en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#blendMode

尝试将每个圆圈的 .blendMode 属性设置为 BlendMode.ADD:

var circle:MovieClip = new MovieClip();
circle.blendMode = BlendMode.ADD;

3) 如果BlendMode.ADD 无法提供您想要的结果,请尝试创建自定义着色器来完成这项工作。

http://help.adobe.com/en_US/as3/dev/WSB19E965E-CCD2-4174-8077-8E5D0141A4A8.html

恕我直言,混合模式是实现所需效果的最简单方法,并且BlendShader 如果你想要精确的定制。如果还有其他问题请评论!

一些教程和示例:

http://www.learningactionscript3.com /2007/11/03/more-properties-blendmodes-filters/

http://active.tutsplus.com/tutorials/games/introducing- Blend-Modes-in-flash/

干杯,

J

Hi and welcome to SO and AS3!

I'll take each point separately:

1) Quite simple, you've probably already figured out that "addChild()" will add MovieClip objects to the Display List, meaning Flash will render them every frame.

2) The easiest way to do this is through "Blend Modes", which is Adobe's way of handling overlapping display objects.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#blendMode

Try setting the .blendMode property of each circle to BlendMode.ADD:

var circle:MovieClip = new MovieClip();
circle.blendMode = BlendMode.ADD;

3) If BlendMode.ADD doesn't give you the results you want, try creating a custom shader to do the job.

http://help.adobe.com/en_US/as3/dev/WSB19E965E-CCD2-4174-8077-8E5D0141A4A8.html

IMHO Blendmode is the easiest way of achieving the desired effect, and blendShader if you want precise customization. Please comment if you have further questions!

Some tutorials and examples:

http://www.learningactionscript3.com/2007/11/03/more-properties-blendmodes-filters/

http://active.tutsplus.com/tutorials/games/introducing-blend-modes-in-flash/

Cheers,

J

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文