Created
August 19, 2010 17:02
-
-
Save seansullivan/538375 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
curvePath = []; | |
var step = 1 / 100; | |
var point1, point2, point3; | |
point1 = {'x': 0, 'y':0}; | |
point2 = {'x':250, 'y':200}; | |
point3 = {'x': 500, 'y':0}; | |
var posX, posY; | |
//This loops calculates each step of the curve | |
for (var u = 0; u <= 1; u += step) { | |
posX = (Math.pow((1-u),2)*point1.x) + (2*(1-u)*u*point2.x) + (Math.pow(u,2)*point3.x); | |
posY = (Math.pow((1-u),2)*point1.y) + (2*(1-u)*u*point2.y) + (Math.pow(u,2)*point3.y); | |
curvePath.push({'x':posX, 'y':posY}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment