Skip to content

Instantly share code, notes, and snippets.

View edgarberm's full-sized avatar
:octocat:
NaN

Edgar Bermejo edgarberm

:octocat:
NaN
View GitHub Profile
@edgarberm
edgarberm / Vector3.js
Created October 9, 2013 11:39
Basic Vector3 class
function Vector3( x, y, z )
{
this.x = x;
this.y = y;
this.z = z;
this.tx = 0;
this.ty = 0;
this.tz = 0;
this.sinRX = 0;
@edgarberm
edgarberm / Clock.js
Last active December 14, 2015 06:59
OOP Javascript Clock
////////////////////////////////////////////////////////////////////////////////
//
// BUILT BY EDGAR
//
// Clock.js
//
// http://builtbyedgar.com/
// https://twitter.com/BuiltByEdgar
// https://github.com/BuiltByEdgar
//
@edgarberm
edgarberm / RotatingBitmapData.as
Created January 11, 2013 23:14
Rotating BitmapData
var bmd:BitmapData = new BitmapData(myBitmap.height, myBitmap.width, false, 0x000000);
var matrix:Matrix = new Matrix();
matrix.translate(-myBitmap.width / 2, -myBitmap.height / 2);
matrix.rotate(90 * (Math.PI / 180));
matrix.translate(myBitmap.height / 2, myBitmap.width / 2);
bmd.draw(myBitmap, matrix);
var bm:Bitmap = new Bitmap(bmd);
var sp:Sprite = new Sprite();
sp.addChild(bm);
addChild(sp);
@edgarberm
edgarberm / bringToFront.as
Created December 18, 2012 17:43
Bring to front any DisplayObject AS3
function bringToFront(obj:DisplayObject):void
{
var pos:Number = this.getChildIndex(obj);
while(pos < this.numChildren - 1)
{
var next:DisplayObject = this.getChildAt(pos + 1) as DisplayObject;
this.swapChildren(obj, next);
pos = this.getChildIndex(obj);
}
@edgarberm
edgarberm / setRegistration.as
Created December 18, 2012 17:14
Change registration point on the fly AS3
private function setRegistration(obj:DisplayObject):void
{
obj.x = -obj.width >> 1;
obj.y = -obj.width >> 1;
}