Skip to content

Instantly share code, notes, and snippets.

@doxas
Created July 19, 2016 07:16
Show Gist options
  • Save doxas/e0c842996f1ea83b7c19dc7f30fc949a to your computer and use it in GitHub Desktop.
Save doxas/e0c842996f1ea83b7c19dc7f30fc949a to your computer and use it in GitHub Desktop.
function bezier(t, p0, p1, p2, p3){
var x = (1 - t) * (1 - t) * (1 - t) * p0[0] +
3 * (1 - t) * (1 - t) * t * p1[0] +
3 * (1 - t) * t * t * p2[0] +
t * t * t * p3[0];
var y = (1 - t) * (1 - t) * (1 - t) * p0[1] +
3 * (1 - t) * (1 - t) * t * p1[1] +
3 * (1 - t) * t * t * p2[1] +
t * t * t * p3[1];
return [x, y];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment