开发者

how do i create a bucket-fill tool in application?

how can i implement a bucket fill tool in paint application in flex?

case FILL:
        var b:BitmapData = new BitmapData(width, height);
        b.draw(this);
        b.lock();
        var开发者_StackOverflow中文版 from:uint = b.getPixel(x,y);

        var q:Array = [];

    var xx:int;
    var yy:int;
            var w:int = b.width;
        var h:int = b.height;
        q.push(y*w + x);
        while (q.length != 0) {
               var xy:int = q.shift();
        xx = xy % w;
            yy = (xy - xx) / w;
            if (b.getPixel(xx,yy) == from) { 
                b.setPixel(xx,yy,SolidColorStroke(stroke).color);
                if (xx != 0) q.push(xy-1);
                    if (xx != w-1) q.push(xy+1);
                if (yy != 0) q.push(xy-w);
                if (yy != h-1) q.push(xy+w);
                }
            }
            b.unlock(null);
            break;

Abdul Khaliq


Have you tried with Bitmapdata.floodFill?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜