justin-hackin / lib2geom-path-boolean-addon

N-API addon providing svg path boolean operations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

lib2geom path boolean N-API addon

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.

Installation

As N-API module (recommended)

npm i lib2geom-path-boolean-addon@n-api

With post-install build via cmake-js

npm i -g cmake-js

Debian-based, e.g. Ubuntu

sudo apt-get install g++ cmake libdouble-conversion-dev libgsl-dev libcairo2-dev

Windows (not recommended, see See lib2geom issue)

npm i lib2geom-path-boolean-addon

API

intersectPathData

Given 2 strings which are svg d-attributes, returns the d-attribute for the intersection of the two paths

subtractPathData

Given 2 strings which are svg d-attributes, returns the d-attribute for the difference of the two paths

unifyPathData

Given 2 strings which are svg d-attributes, returns the d-attribute for the union of the two paths

Usage

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

About

N-API addon providing svg path boolean operations


Languages

Language:C++ 74.1%Language:CMake 23.7%Language:JavaScript 2.2%