Author Archives: Zevan

Global Illumination Links

Recently saw some great links making use of Global Illumination/Ambient Occlusion… these ones are from wonderfl posted by keim at Si :
This first example is based on something called AO bench.
one
two
three
and there is something called MiniLight which has been ported to Flex.

Posted in BitmapData, graphics algorithms, misc, pixel manipulation, setPixel | Tagged , | Leave a comment

drawPath() Boxes

CLICK HERE TO COPY
Actionscript:

const TWO_PI:Number = Math.PI * 2;

var boxNum:int = 3000;

var pointNum:int = boxNum * 10;

var rot:Vector.<Number> = new Vector.<Number>();

var posX:Vector.<Number> = new Vector.<Number>();

var posY:Vector.<Number> = new Vector.<Number>();

var velX:Vector.<Number> = new Vector.<Number>();

var velY:Vector.<Number> = new Vector.<Number>();

var scale:Vector.<Number> = new Vector.<Number>();

var rotSpeed:Vector.<Number> = new Vector.<Number>();

var geometry:Vector.<Number> = new Vector.<Number>();

var cmds:Vector.<int> = new Vector.<int>();

 

var stageWidth:Number = [...]

Posted in Graphics, motion | Tagged , | Leave a comment

Bounds 3 Ways

CLICK HERE TO COPY
Actionscript:

// make a complex poly and position it randomly

var poly:Sprite = Sprite(addChild(new Sprite()));

poly.graphics.lineStyle(3, 0xFF0000);

poly.graphics.beginFill(0x00FF00);

for (var i:int = 0; i<10; i++) {

    poly.graphics.lineTo(Math.random()*100 - 50, Math.random()*100 - 50);

}

poly.x=Math.random()*stage.stageWidth;

poly.y=Math.random()*stage.stageHeight;

 

// get bound information:

 

// is in pixels (whole numbers)

trace("pixelBounds: ", poly.transform.pixelBounds);

// doesn't include stroke width

trace("getBounds: ", poly.getBounds(this));

// includes stroke width

trace("getRect: ", poly.getRect(this));

Three different ways to [...]

Posted in DisplayObject | Tagged , | 1 Comment

More Messy Code

CLICK HERE TO COPY
Actionscript:

var size:Number = 800;

var canvas:BitmapData = new BitmapData(size,size,false, 0x000000);

addChild(new Bitmap(canvas, "auto", true));

 

scaleX = scaleY = .5;

var pix:Number = size * size;

var scale:Number = 1/(size/3);

 

for (var i:Number = 0; i<pix; i++){

       var xp:Number = (i % size);

       var yp:Number = int(i / size);

       var xt:Number = xp [...]

Posted in BitmapData, misc, pixel manipulation, setPixel | Tagged , | Leave a comment