ABANDONED: this project is abandoned in favor of paper.js boolean operations. This does necessitate some bloat of canvas-related rendering code as per this issue.
Exposes lib2geom boolean path algorithms used in the Inkscape project to a node.js project
WARNING: this library is experimental and not recommended for production use. It is proving difficult to build on Windows. Explored wasm compilation in the wasm branch without success yet.
npm i lib2geom-path-boolean-addon@n-api
npm i -g cmake-js
sudo apt-get install g++ cmake libdouble-conversion-dev libgsl-dev libcairo2-dev
Windows (not recommended, see See lib2geom issue)
- https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/ (use to install base and g++)
- https://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.zip/download
- https://nodejs.org/en/download/
- https://github.com/wingtk/gvsbuild (dependency: extras installed with nodejs)
- https://sourceforge.net/projects/gnu-scientific-library-windows/
npm i lib2geom-path-boolean-addon
Given 2 strings which are svg d-attributes, returns the d-attribute for the intersection of the two paths
Given 2 strings which are svg d-attributes, returns the d-attribute for the difference of the two paths
Given 2 strings which are svg d-attributes, returns the d-attribute for the union of the two paths
const { intersectPathData, subtractPathData, unifyPathData } = require('lib2geom-path-boolean-addon');
const intersection = intersectPathData('M0,0 L10,0 L10,10 L0,10 Z', 'M5,5 L15,5, L15,15 L5,15 Z');
const subtraction = subtractPathData('M0,0 L10,0 L10,10 L0,10 Z', 'M5,5 L15,5, L15,15 L5,15 Z');
const union = unifyPathData('M0,0 L10,0 L10,10 L0,10 Z', 'M5,5 L15,5, L15,15 L5,15 Z');