PDA

View Full Version : linebitmapStyle



whomba
June 9th, 2009, 02:42 PM
Hello, long time reader, first time contributer here.
I am trying to mimic a paint brush in AS3. Right now I am simply checking for mouse down + mouse move then putting a copy of an image on the stage. This sucks because after a while it starts to get bogged down.

As a result I checked out graphics.lineBitmapStyle(), I was able to get that to work (technically) but not how I wanted to use it. Right now it just tiles it (yes, i know there is a switch to turn tiling off) acting like a 'scratch off' lottery ticket, as in, there is an image under neath (my bitmap) and my 'drawing' just makes it visible. Any help would be greatly appreciated... code is below:


var oldWay:Canvas = new Canvas()
//Create bmp data:
var bRect:BitmapData = new BitmapData(100, 100); //create bitmap
var c:Canvas = new Canvas(); //create spoof canvas
c.graphics.beginFill(oxFF0000);//start fill
c.graphics.drawRoundRect(0,0, 100, 100,10,10);//draw that ****!
c.graphics.endFill();//end fill
bRect.draw(c);//draw this out to the bmpdata
oldWay.graphics.lineStyle(bRect.height,0); //start a line style
oldWay.graphics.lineBitmapStyle(bRect,null,true,fa lse) //set bitmap style
oldWay.graphics.moveTo(nX1, nY1);//move this to my old location
oldWay.graphics.lineTo(nX2, nY2);//draw to new location
Image of results here:
http://content.screencast.com/users/andrewLuly/folders/Jing/media/5c576109-a580-43e2-b8dd-e171e0da1c6a/2009-06-09_1440.png

whomba
June 9th, 2009, 05:12 PM
I have also tried bitmapFill, but this appears to be the same out come... any suggestions?

whomba
June 10th, 2009, 09:44 AM
Also just regular color fill with a mask won't work for what i need

senocular
June 10th, 2009, 10:45 AM
Are you trying to duplicate an image over and over again as you draw on the screen? Like a photoshop bitmap brush?

If so, you'll want to make one big bitmap as your canvas and copy your image's pixels into the location in that bitmap where the mouse is when you're drawing.

whomba
June 12th, 2009, 12:32 PM
Are you trying to duplicate an image over and over again as you draw on the screen? Like a photoshop bitmap brush?

If so, you'll want to make one big bitmap as your canvas and copy your image's pixels into the location in that bitmap where the mouse is when you're drawing.

Yes that is what i am doing, however i ahve to create multiple sprites on various layers to 'maintain depth' After much review, i think tht what i currently have is the best I will get :/