Actionscript 3 中重叠圆形对象的过滤器
基本上我有x个圆圈表示为MovieClips。 它们都分配有相同的基色(例如红色)。 它们都应该具有从 0 到 1 的亮度属性(0 表示全白,1 表示全红)。
我想要以下属性来在舞台上表示这些圆圈:
- 当圆圈不重叠时,它们的表示方式如上所述。
- 当圆圈重叠时,重叠区域应具有与原始圆圈相同的基色,但该区域的亮度应为定义重叠的所有圆圈的亮度之和。
- 亮度在 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:
- When the circles dont overlap they are represented as stated above.
- 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.
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您好,欢迎来到 SO 和 AS3!
我将分别讨论每一点:
1) 非常简单,您可能已经发现“addChild()”会将 MovieClip 对象添加到显示列表中,这意味着 Flash 将在每一帧中渲染它们。
2) 最简单的方法是通过“混合模式”,这是 Adobe 处理重叠显示对象的方法。
http://help.adobe.com /en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#blendMode
尝试将每个圆圈的 .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:
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