Skip to content

rharel/js-bezier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Built with Grunt

What is this?

Yet another bezier-curve library! Please view the demo here.

Installation

Install via bower: bower install rharel/js-bezier

The dist/ directory contains both a normal (bezier.js) as well as a minified version of the library (bezier.min.js). Include in the browser using <script src="bezier.min.js"></script>

Usage

Create

var controlPoints = [{x: 0, y: 0}, {x: 1, y: 1}];
var c = new Bezier.Curve(controlPoints);
c.complexity;  // 2

Evaluate

var controlPoints = [{x: 0, y: 0}, {x: 1, y: 1}];
var c = new Bezier.Curve(controlPoints);
c.at(0);  // {x: 0, y: 0, t: 0}
c.at(1);  // {x: 1, y: 1, t: 1}
c.at(0.5);  // {x: 0.5, y: 0.5, t: 0.5}

Draw

var controlPoints = [{x: 0, y: 0}, {x: 1, y: 1}];
var c = new Bezier.Curve(controlPoints);
var s = c.outline(t0 = 0, t1 = 1, precision = 0.5);
/**
 * s === [
 * 	{x: 0, y: 0, t: 0},
 * 	{x: 0.5, y: 0.5, t: 0.5},
 * 	{x: 1, y: 1, t: 1}
 * ]
 */

License

This software is licensed under the MIT License. See the LICENSE file for more information.

About

Interactive bezier demo for the browser.

Resources

License

Stars

Watchers

Forks

Packages

No packages published