An OpenFrameworks wrapper for lib2geom, the vector engine used in Inkscape.
It provides a set of algoritms for computing 2D vector data.
Warning! Requires C++17 (lower lib2geom versions provide down to C++11 compatibility, but there have been API changes)
Note about lib2geom : While many features are implemented, lib2geom
is moving away from their previous geometry lib Livarot
, some features of Inkscape remain in that library until they are moved. Also, Inkscape still has some code parts left in its own code base, only partly using lib2geom
. Path offsetting and boolean operations are sadly in that case.
I was looking for boolean operations and path offsetting, which are not well integrated into this lib yet. I'm leaving this addon as is, as it provides a lot of other useful algebra.
Only tested on Linux
+ C++17
+ OF0.11.2
, using makefiles or qt-creator, should not be hard to compile on Mac + Win as long as you're using C++17.
Check the lib2geom dependencies, you can find them in their readme.
apt install libdouble-conversion-dev
apt-get install libgtest-dev
Alternative: Install with package manager apt install lib2geom-dev
(installs old v1.1, on 01-2024)
Note : currently needed on Linux to link, but could be build within the OF project too.
cd /path/to/lib2geom
mkdir build && cd build
cmake .. -D2GEOM_TESTING=OFF
make
or make dist
If you're using OF 0.11.2 or below; configure your project to use C++17 or 20.
In your project's config.make
: PROJECT_CFLAGS = -std=c++17
Their doxygen docs are a bit old and need to be compile manually, but there's a nice manual that explains some base principles and a wiki FAQ with some tips.
There's no glue yet so you'll have to find out how to use lib2geom. Good luck ! The example shows how to setup a Path
, apply an offset and display the result.
Here are some tips :
Geom::Coord
: a double, a 1D coordinate.Geom::Point
: a 2D coordinate. X and Y are mostly accessible troughpnt[0]
.Geom::Path
: A polyline structure, like OF'sofPolyLine
.Geom::Linear
: An abstraction to wrap a segment into a "time" accessible manner.Geom::D2<SBasis>
: An abstraction of a shape, used to perform advanced algorithmic operations. Warning: lib2geom is moving away from this type, to be obsoleted.Geom::Piecewise<D2<SBasis>>
: A cleaned and rewinded shape abstraction.
ofxLib2Geom is MIT.
lib2geom is LGPL 2.1 + MPL 1.1.
Made by Daan de Lange.
Powered by lib2Geom from the Inkscape team.
.