I heard through the grapevine that there are some improvements to the BitmapData class coming up in future versions of Flash, that will allow for larger sized bitmaps to be created. Currently, the largest BitmapData instance you can make is 2880 x 2880. This is fine for most uses, but every once in a while you just need something bigger.
I’ve been doing some generative art lately, and taking a page from the books of Josh Davis, Jared Tarbell, and Erik Natzke, I’ve been thinking of considering looking at maybe possibly getting some prints done. To make a decent quality, decent sized print, I believe you need more pixels than what BitmapData offers. The obvious solution is to use more bitmaps, but that can be a major pain stitching them together and so forth. So, I created a class that takes care of most of that for me.
Introducing the BigAssCanvas class.
Basically, BigAssCanvas mimics BitmapData, except that it is a display object (actually a display object container). You create a BigAssCanvas the same way you would a BitmapData, but you have virtually unlimited size:
[as]var myBigAssCanvas:BigAssCanvas = new BigAssCanvas(10000, 10000, true, 0xff000000);
Note also that unlike a BitmapData, you add it directly to the display list.
Essentially what it’s doing is: If the width you specify is greater than 2880, it makes multiple columns of bitmaps. If the height is more than 2880, it makes multiple rows. That, in itself, is not such a big deal. The cooler part is that is abstracts several of the more common BitmapData methods so that you can use them without worrying about the fact that the method is actually being applied to several Bitmaps. Here’s what I have so far:
- draw – works exactly like BitmapData.draw, including the matrix, colorTransform, blendMode, clipRect and smoothing. You’ll never know you aren’t just drawing to a BitmapData.
- dispose – removes all bitmaps from display list and disposes of all bitmapdatas.
- fillRect – rect, color.
- getPixel, setPixel, getPixel32, setPixel32 – all just like in BitmapData.
- noise – yup.
- perlinNoise – everything except for stitch, which I don’t know if it can ever be made to work, and offsets, which could be made to work with some effort, I believe. (This one can be pretty slow for a large canvas, by the way.)
- lock, and unlock, minus the changeRect stuff in unlock, which I never knew existed til tonite.
There are definitely more methods that could be added to this, but I think I covered the vast majority of use cases. If you want to dive in and contribute a method, go for it. It’s also totally untested apart from running the method a couple of times and seeing that it looked generally right. It’s completely undocumented, but you are smart kids, you’ll figure it out. Anyway, I made it tonite, it’s almost 2 a.m., I think it’s cool, and I’m blogging it.
Get it, use it, tell me what it breaks, fix it for me: