I'm creating a drawing app in Flash with AS3. The "brushstroke" is created with a bitmap. This code seems to work fine when the brushstrokes are spread out. [SEE IMAGE 1]
But when the same stroke is clicked repeatedly in the same spot, it's evident the the brushstroke is not only adding alpha but deleting it as well. [SEE IMAGE 2] I want to eliminate the "box" shape surrounding the brushstroke.
The code snippet that I'm currently using is below. Is there such thing as an "alpha add" so that this alpha subtraction doesn't occur? The brushstroke blob is here for reference. [SEE IMAGE 3]
1 Drawing app http://theluv.is/downloading/drawImg1.png 2 Drawing app http://theluv.is/downloading/drawImg2.png 3 Drawing app http://theluv.is/downloading/brushBlob.png
function stampImage(){
var matrix:Matrix = new Matrix();
matrix.translate(mouseX + brushOffsetX, mouseY + brushOffsetY);
maskSprite.graphics.beginBitmapFill(blob, matrix, false, false);
maskSprite.graphics.drawRect(mouseX + brushOffsetX, mouseY + brushOffsetY, blob.width, blob.height);
maskSprite.graphics.endFill();
}
Use BitmapData.copyPixels method. You can specify alpha blending there. Of course you'll have to modify your code. First of all you'll have a canvas bitmapdata.
var bmpd:BitmapData;
And to draw it on screen you just create a Bitmap object.
var bmp:Bitmap = new Bitmap(...);
bmp.bitmapData = bmpd;
addChild(bmp);
When you want to draw something use
bmpd.copyPixels(blob, blob.rect, new Point(x,y), null, null, true);
Where blob is a BitmapData with your brush texture.
The problem will be if you want to rotate brush texture. In this case use BitmapData.draw.