as3 - Fixed the problem of empty spaces between points in the class brush

0

Can you add code to this class to draw lines continuously?

This is a package for a simple brush on the Swf output. When the mouse moves fast, there are gaps between points. That is, it becomes a point. Can you add code to this class to draw lines continuously?

package tools {
import flash.display.*;
import flash.geom.*;

public class BrushTool implements ITool {
    private var _bitmap:Bitmap;
    private var _bmd:BitmapData;
    private var _brushStroke:Shape;
    public function BrushTool() {
        _bmd = new BitmapData(680, 580, true, 0x00000000);
        _bitmap = new Bitmap(_bmd);
    }
    public function mouseDown(x:Number, y:Number, fillColor:uint):void {
        _brushStroke = new Shape();
        var gradBox:Matrix = new Matrix();
        gradBox.createGradientBox(10, 10, 0, 0, 0);
        _brushStroke.graphics.beginGradientFill(GradientType.RADIAL, [fillColor, fillColor], [1, 0], [127,255], gradBox)
        _brushStroke.graphics.drawCircle(10, 10, 10);
    }
    public function mouseMove(x:Number, y:Number):void {
        var m:Matrix = new Matrix();
        m.translate(x-10, y-10)
        _bmd.draw(_brushStroke, m);
    }
    public function mouseUp(x:Number, y:Number):void {
    }
    public function get art():DisplayObject {
        return _bitmap;
    }
}

}

brush
asked on Stack Overflow Jan 22, 2021 by ali abedinifar

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0