As many of you may be aware, the flash package contains a geom.Matrix class which is useful for Linear Translations of DisplayObjects as well as BitmapData. The matrix class allows for a 3×3 array which is useful for 2D transformations such as shearing, rotation, and scaling. Of course with any[...]
Archive for the ‘Algorithms’ Category
Faster Pixel Loop Itteration
Using multiple loops, can always become a difficult way to manage and I wanted to share another way to accomplish a traverse of a full BitmapData more effeciently.[...]
Random Distribution
A few years ago, I remember learning from Keith Peters, who learned from Sean O’Shell, that you could get Math.random() to favor 1 through its square root. Math.sqrt(Math.random()) Recently, during a client project, I needed the values returned between 0-1 to be somewhat larger, while still re[...]
Wandering
vx+=Math.random()*2-1; vy+=Math.random()*2-1; clip.x+=vx clip.y+=vy vx*=.9 vy*=.9 }[...]
Barslund Repulsion
xDif = mouseX-this.x; yDif = mouseY-this.y; distance = Math.sqrt(xDif*xDif+yDif*yDif); tempX = this.x-(force/distance)*(xDif/distance); tempY = this.y-(force/distance)*(yDif/distance); this.x=(this.homeX-this.x)/2+tempX; this.y=(this.homeY-this.y[...]