/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import flash.display.Bitmap; import flash.display.BitmapData; var bmpd:BitmapData = new LibraryBitmap(1,1); var bitmap:Bitmap = new Bitmap(); bitmap.bitmapData = bmpd; addChild(bitmap); var wide:int = bmpd.width; var tall:int = bmpd.height; var totalPixels:int = wide * tall; trace("wide: " + wide); trace("tall: " + tall); trace("totalPixels: " + totalPixels); var index:int = totalPixels + 1; var useIndex:int; var xPixel:int; var yPixel:int; while (--index > 0) { useIndex = index - 1; xPixel = useIndex % wide; yPixel = int(useIndex / wide); bmpd.setPixel(xPixel, yPixel, 0xff0000); }
URL: http://spilled-milk.com/blog/2010/06/30/faster-pixel-loop-itteration/