Github Repo

Options & stats

Information

BezierPaths is a library for generating bezier-curve paths and calculating movement over them. Path can be traversed either by specifying distance travelled along the path or by time; paths support changing speeds, acceleration and deceleration which makes travelling by time more versatile.

Installation: npm i bezier-paths

Usage

var curvedPoints = [];

curvedPoints.push(BezierPaths.createBezierPoint(
	x, y,
	speedTo, speedFrom,
	controlBackX, controlBackY,
	controlFrontX, controlFrontY
));
curvedPoints.push(BezierPaths.createBezierPoint(...));
curvedPoints.push(BezierPaths.createBezierPoint(...));
curvedPoints.push(BezierPaths.createBezierPoint(...));

var path = BezierPaths.compilePath(precision, points);
path.getPointAtTime(time);
// OR
path.getPointAtDistance(distance);