Skip to content

[DISCONTINUED: Changes have been pulled into https://github.com/soswow/fit-curves] JavaScript implementation of Philip J. Schneider's "Algorithm for Automatically Fitting Digitized Curves" from the book "Graphics Gems".

License

Notifications You must be signed in to change notification settings

Sphinxxxx/fit-curve

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fit one or more cubic Bezier curves to a polyline. JavaScript implementation of Philip J. Schneider's "Algorithm for Automatically Fitting Digitized Curves" from the book "Graphics Gems".

Ported from C via Python:

No dependencies.

Usage

var points = [[0, 0], [10, 10], [10, 0], [20, 0]];
var error = 50;  // Lower numbers give more accurate curves

var bezierCurves = fitCurve(points, error);
// bezierCurves[0] === [[0, 0], [20.27317402, 20.27317402], [-1.24665147, 0], [20, 0]]
// where each element is [x, y] and elements are [first-point, control-point-1, control-point-2, second-point] 

Demo

http://codepen.io/Sphinxxxx/pen/jALxvQ?editors=1011

About

[DISCONTINUED: Changes have been pulled into https://github.com/soswow/fit-curves] JavaScript implementation of Philip J. Schneider's "Algorithm for Automatically Fitting Digitized Curves" from the book "Graphics Gems".

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%