开发者

ActionScript: Draw a border around a masked image?

开发者 https://www.devze.com 2022-12-17 09:09 出处:网络
I\'m trying to write some ActionScript which will accept a mask and an image, then mask the image and put a border around the result (assuming that the mask is always 100% opaque).

I'm trying to write some ActionScript which will accept a mask and an image, then mask the image and put a border around the result (assuming that the mask is always 100% opaque).

For example, if my mask is a poorly drawn star, and my image is 开发者_如何学运维a bunch of flowers, I want the result to be a poorly drawn star with flowers inside it and a border around it. Something like this:

masked flowers http://img.skitch.com/20100120-xghntrn5yumxst97gjky2qje1p.png

Is that possible? And, if so, how can I do it?


AFAIK that is not possible. I would think about using a GlowFilter on the masked image and setting its properties so that it looks like a border.


I'd use the Glow Filter idea TBH... But where is that mask coming from? Depending on that answer I have two ideas:

If it's coming from user input, as in, a user is drawing a shape WITHIN the flash app, then it's pretty easy:

  1. You would record an array of points while the user was "drawing" the shape.
  2. Then you create and draw two movie clips
    • One with a fill that would be the mask.
    • And another with an outline that would be the outline to go over the mask.

If it's coming from outside the flash app, it's possible, but it would be slower than dirt. You could:

  1. Take the mask movie (assuming it's all black) and convert it to a Bitmap object.
  2. Then step through the bitmask object, pixel by pixel, to determine the outer points of the object.
  3. Then the not so easy part (LOL): Then step through all of the points and reorganize them so the they're all next to the two closest points to them in the array.
  4. Then you could create a new movie and draw the points as lines on that movie, placing it in a layer above the mask.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号