Author Archives: Zevan

Shapevent Log (not a snippet)

Recently launched a new project over at shapevent.com. If your enjoy sketchbooks, drawings and interactive ugliness… have a look here:
Shapevent Log
Many of the techniques covered in the code on this website will be used in shapevent log entries… no rss feed yet, but I’ll have one up for it in the next few days….

Posted in misc | Leave a comment

sinh & cosh

CLICK HERE TO COPY
Actionscript:

function sinh(x:Number):Number{

    return (Math.pow(Math.E, x) - Math.pow(Math.E, -x)) * 0.5;

}

 

function cosh(x:Number):Number{

    return (Math.pow(Math.E, x) + Math.pow(Math.E, -x)) * 0.5;

}

Needed sinh and cosh today. Easy enough to create with existing math functions. If you needed more speed you could inline these and replace Math.E with 2.71828183.
Got the math over at wikipedia [...]

Posted in Math, misc | Tagged , | Leave a comment

Utils3D.projectVectors() & 100,000 pixels

CLICK HERE TO COPY
Actionscript:

var matrix:Matrix3D = new Matrix3D();

 

const PARTICLE_NUM:int = 100000;

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

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

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

 

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

    verts.push(Math.random()*250 - 125);

    verts.push(Math.random()*250 - 125);

    verts.push(Math.random()*250 - 125);

   

    pVerts.push(0), pVerts.push(0);

    uvts.push(0), uvts.push(0), uvts.push(0);

}

 

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

addChild(new [...]

Posted in 3D, BitmapData, Vector, matrix, setPixel | Tagged , | 3 Comments

Vector.sortOn()

CLICK HERE TO COPY
Actionscript:

var a:Vector.<Sprite> = new Vector.<Sprite>();

 

trace("unsorted");

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

    var s:Sprite = new Sprite();

    s.x = int(Math.random()*100);

    a.push(s);

    trace(s.x);

}

 

quickSortOn(a, "x", 0, a.length-1);

 

trace("sorted");

for (i= 0; i<10; i++){

    trace(a[i].x);

}

 

// modified code from kirupa.com

// http://www.kirupa.com/developer/actionscript/quickSort.htm

function quickSortOn(a:Vector.<Sprite>, prop:String, left:int, right:int):void {

    var i:int = 0, j:int = 0, [...]

Posted in Object, Vector, arrays, associative arrays, sortOn | Tagged , | 3 Comments