Created
June 15, 2012 19:25
-
-
Save mattlundstrom/2938310 to your computer and use it in GitHub Desktop.
Flash Bezier Curve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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