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:
- You would record an array of points while the user was "drawing" the shape.
- 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:
- Take the mask movie (assuming it's all black) and convert it to a Bitmap object.
- Then step through the bitmask object, pixel by pixel, to determine the outer points of the object.
- 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.
- Then you could create a new movie and draw the points as lines on that movie, placing it in a layer above the mask.
精彩评论