← Back

ofxPathFitter

github.com/acmyu/ofxPathFitter · @acmyu
OF 0.10 Algorithms Geometry

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

9 2 Last commit 8y ago Created 9y ago

README

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.

<img src="img/edit.png" width="400">

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);

Get this addon

HTTPS
SSH