AS3 PrintCanvas update: Loupe and Display
Check out the demo. But don’t just click on the swf when it comes up. A click saves an A2, 300dpi PNG. Just be warned that this could crash your browser, depending on memory. Don’t say I didn’t warn you.
Got some nice new features into PrintCanvas. It’s all very well having a massive BitmapData for print, but it’d be nice to see what it’s doing on-screen without actually shoving the whole thing into the display list. Particularly when doing time-based generative stuff, I want to watch it happen!
I’ve built this into PrintCanvas using a matrix to pull out a scaled version for display. You can easily return this display Bitmap with
1 | createDisplayBitmap($width:Number):Bitmap |
Stick that on your stage, then in a Timer, EnterFrame or whenever you need it, call
1 | updateDisplayBitmap(); |
to refresh the BitmapData linked to the Bitmap. Simple.
Then I thought well, this is nice and quick, but really I want to see what’s going on at pixel level. So I built in a loupe that returns a 100% window on the big BitmapData. Just pass a width and a point on the display Bitmap – usually the local mouse position – into
1 | createLoupeBitmap($centre:Point, $width:Number):Bitmap |
to get another Bitmap back. Then refresh it as above by calling
1 | updateLoupeBitmap($centre:Point); |
In the demo above, I’ve stuck the loupe Bitmap to the mouse and masked it with a circle because it looks nice. So there. And the blue squares aren’t intended as anything pretty – they’re just there to show it updating and give you something to look at with the loupe. I’ll get something nice going soon, I promise.
I’m pretty impressed with the performance on this, even on my 4 year old MacBook Pro! If you consider in the demo it’s getting both sets of data from an unseen A2 canvas at 300dpi, every frame, that’s not bad. Seems a good deal faster still in the standalone FP10 player/IDE for some strange reason.
So here, have the code if you must.
February 4th, 2010 by Addy P.
It's all about the experiments / r 'n' d, flash | No Comments »



Say your piece...