I guess there is no method of BitmapData class or another ActionScript
solution for your problem.
I think about a solution that will be faster than loop xy and test all
pixels with getPixel. (but it will be hard for me to explain in english,
just try)
So, it's something with recursive method:
You choose a factor, for exemple 10. You cut your test area in 10 parts. For
exemple, the global area you want to test is 500x500. So you cut your area
in parts of 50x50. Test all this areas. You will define which are empty.
Then don't care again about this areas. Take again the filled areas and cut
them also in 10 parts. Define which of this small parts are empty, etc...
etc..
With a method like this, your test will be faster.
The question is how to test the area... I don't know, you have to test some
solutions... for exemple:
1. Draw the part of the area into a small BitmapData (1x1 or 2x2) with a
reduce matrix and a smooth value. This could do a kind of average, then test
only this single pixel with getPixel
2. Use the collision test. Draw a rectangle clip of your sub-area and test
the collision. Collision false mean the area is empty. Collision true mean
there is something inside and you have to test inside it.
3.... just imagine other solutions...
Good luck
David Buff
----- Original Message -----
From: "Josh Santangelo" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <[email protected]>
Sent: Monday, October 23, 2006 11:07 PM
Subject: [Flashcoders] determining how much of one clip intersects another
I'm working on a little component which is sort of like the fill-in
bubbles on standardized tests. The user will use the mouse to scribble
within a region. I'll draw into a clip which is on top of the region to
fill it up. This is pretty easy.
What I want to do is every time I draw into the region, figure out how
much of the region is full by getting a percentage of pixels which are
filled vs the amount that aren't.
I imagine there's some slick BitmapData trick which could be used to make
this happen, but I'm new to that class and my first guess involves about
a million calls to getPixel to find out which are filled and which
aren't. That's probably very slow -- surely someone's got a more
efficient way to do this sort of thing.
Gskinner's sprites.CollisionDetection class seems like a place to start,
but it only returns the bounds of a collision, not the percentage of the
target which is covered.
Any ideas?
-josh
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com