Provides two mathematical functions for drawing Bezier curves
Marks an array of 2D points as a base for a bezier curve. Example:
var points = [];
points.push([0,0]);
points.push([1,0]);
points.push([1,1]);
Bezier.setPointList(points);
Pre-computes factorials of 1..max for later execution. Call this function once, in the initialization part
of your script. This speeds up creation of bezier curves using
Bezier.create2()
function. Set the max argument to the number of points.
Returns a Bezier function f: [0,1] → R^2 which describes parametric Bezier curve, based on points set by
Bezier.setPointList()
. Uses slow but precise recursive de Casteljau algorithm.
Returns a Bezier function f: [0,1] → R^2 which describes parametric Bezier curve, based on points set by
Bezier.setPointList()
. Uses faster factorial algorithm based directly on Bernstein polynoms.
var points = [];
points.push([0,0]);
points.push([1,0]);
points.push([1,1]);
Bezier.setPointList(points);
var f = Bezier.create2();
alert(f(0.5)); // [x, y] where x in [0,1], y in [0,1]