Actionscript:
-
var canvas:BitmapData=new BitmapData(400,400,false,0x000000);
-
addChild(new Bitmap(canvas));
-
var pix:Vector.<uint>=canvas.getVector(canvas.rect);
-
-
canvas.lock();
-
for (var i:int = 0; i<300; i++) {
-
var xp:int=50+i;
-
var yp:int=50+i/2;
-
// target x and y coords in 1D array
-
pix[xp+yp*400]=0xFFFFFF;
-
}
-
canvas.setVector(canvas.rect, pix);
-
canvas.unlock();
This snippet shows how to target x and y coordinates in a 1D Array / Vector. This can be useful sometimes when working with setVector().
This is sort of like re-inventing setPixel().... and for that reason is kind of pointless - that said, it's interesting to know. I first learned about this technique from using processing.