Actionscript:
-
var canvas:BitmapData = new BitmapData(500,500,false, 0x000000);
-
addChild(new Bitmap(canvas));
-
-
var pix:Vector.<uint> = new Vector.<uint>(canvas.width * canvas.height, true);
-
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
function onLoop(evt:Event):void {
-
canvas.lock();
-
var i:int = pix.length;
-
while(--i> -1){
-
var c:uint = uint(Math.random() * 255);
-
pix[i] = c <<16 | c <<8 | c;
-
}
-
canvas.setVector(canvas.rect, pix);
-
canvas.unlock();
-
}
This is an easy way to fill a BitmapData Object up with a bunch of TV-style static....
This post is meant to serve as filler while I work to get a good solid SIMPLE fp10, drawing api z-sorting example going... There seem to be 3 main ways of doing z-sorting all of which don't seem right to me for some reason... they all work... but I have a gut feeling there is a faster way... The winner so far (unexpectedly) is using Array.sortOn
5 Comments
…and the other methods are?
1) Vector.sort (very slow for some reason)
2) CustomVector sort (Quicksort, flashSort etc…) - can almost get it as fast as Array.sortOn, but a few ms behind
3) Custom vector sortOn (faster than Vector.sort, but still slow - slower than QuickSort, flashSort etc…)
There are more methods, those are the ones I was trying…. basically I’m going to make sure I can’t get any faster than Array.sortOn… once I do that I’ll create a demo using Array.sortOn…. then I’ll look into using Haxe, Alchemy and or PixelBender (although pretty sure PixelBender is NOT the way to go)…
and what’s wrong with noise () method…
nothing… and since it’s built in the BitmapData.noise() method will probably be faster than this. Like I said, this is just a filler post.
That doesn’t surprise me. if i remember correctly the Array.sortOn method combines quicksort and mergesort, which i’m pretty sure are quick sorting algs.
One Trackback
[...] BitmapData Static [...]