Skip to content

Instantly share code, notes, and snippets.

@mattlundstrom
Created June 15, 2012 19:25
Show Gist options
  • Save mattlundstrom/2938310 to your computer and use it in GitHub Desktop.
Save mattlundstrom/2938310 to your computer and use it in GitHub Desktop.
Flash Bezier Curve
var bmd:BitmapData = new BitmapData(800,600,false, 0x000000);
addChild(new Bitmap(bmd));
bmd.fillRect(bmd.rect, 0x000000);
for (var i:Number = 0; i<=1; i+= 0.01) {
var xp:Number = b(i, 100, 300, 500);
var yp:Number = b(i, 300, 100, 300);
bmd.setPixel(xp, yp, 0xFFFFFF);
}
function b(t:Number, p0:Number, p1:Number, p2:Number):Number {
return (1 - t) * (1 - t) * p0 + 2 * (1 - t) * t * p1 + t * t * p2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment