Skip to content

An OpenFrameworks addon for obtaining a Bezier curve through a set of points, based on Paper.js path simplification

License

Notifications You must be signed in to change notification settings

acmyu/ofxPathFitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ofxPathFitter

Introduction

An OpenFrameworks addon for obtaining a Bezier curve through a set of points

Based on Paper.js path simplification

Installation

Just drop the folder into the openFrameworks/addons/ folder.

Example

See SimpleVectorEditor, which uses this addon to simplify the lines that are drawn.

Usage

ofPolyline line = ...
vector<ofPoint> vertices = line.getVertices(); // the set of points
bool closed = false;
double tolerance = 10;
vector<BezPoint> bezier = ofxPathFitter::simplify(vertices, closed, tolerance); // creates the Bezier curve through the points

or

bezier = ofxPathFitter::simplify(line, tolerance);

BezPoint contains 3 fields:

ofPoint point; // the point
ofPoint handleIn; // the first control point
ofPoint handleOut // the second control point

Note: the control points contain the coordinates relative to the point. To get the absolute coordinates:

BezPoint s = ofxPathFitter::handlesAbsolute(bezier[i]);

or

vector<BezPoint> bezierAbs = ofxPathFitter::handlesAbsolute(bezier);

About

An OpenFrameworks addon for obtaining a Bezier curve through a set of points, based on Paper.js path simplification

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages