This content has been marked as final. Show 4 replies
use the floodFill method of bitmaps if you're not testing pixels against a threshold and use the threshold method if you are testing pixels against a threshold.
Interesting... I'll give this a try and let you know how I go.. Not a bad idea. And probably much easier and faster than trying to get actionscript to do that manually.
yes, the native flash methods are much faster the compiled actionscript.
Ok. I think we are on the right track here but I have a problem.
The threshold method will colour the entire image at a certian tolerance. However this is not what I want. This is more of a contiguous fill. I want a fill that flows from one point.
By using a combination of threshold to draw the fillable pixels, then using the floodfill method on that result I am able to get somethign close. HOWEVER... I do not really fully understand how the threshold method is working.
I want to fill based on color difference. e.g. when you click ona blue I want it to fill colours close to that blue (up to a certain tolerance).
Do you know how I could achieve this? So far I am doing this.. it is currently based on greyscale.. But I am really not 100% sure how the threshold is working. I'd rather have one based on coloru closeness but when I try to do this is all goes haywire on me.
var low:int = toolFill_greyLevel-toolFill_tolerance;
var high:int = toolFill_greyLevel+toolFill_tolerance;
low = 0;
//clear bitmap data
toolFill_bd.fillRect(rect, 0x00000000); //clear image
toolFill_bd.threshold(loadedImageGreyScaleBitmapData, rect, new flash.geom.Point() , ">", low << 16 ^ low << 8 ^ low , 0x01BBBBBB, 0x00FFFFFF, false);
toolFill_bd.threshold(loadedImageGreyScaleBitmapData, rect, new flash.geom.Point() , ">", high << 16 ^ high << 8 ^ high , fillCol, 0x00FFFFFF, false);
toolFill_bd.setPixel32(toolFill_downPixX, toolFill_downPixY, fillCol);