V2 of the famous Clipper lib of Angus Johnson
README
ofxClipper2
An openFrameworks addon wrapping Clipper2, a library for polygon clipping, offsetting, and triangulation.
Installation
Clone this addon into your
addons folder with submodules:git clone --recursive https://github.com/YOUR_USER/ofxClipper2.gitIf you already cloned without submodules:
cd ofxClipper2
git submodule update --init --recursiveRequirements
- openFrameworks 0.12+ (C++17)
- Clipper2 is vendored as a git submodule under
libs/Clipper2
Usage
Include the wrapper header to get both Clipper2 and openFrameworks conversion helpers:
#include "ofxClipper2.h"
using namespace ofxClipper2;
PathsD subject, clip;
subject.push_back(MakePathD({ 100, 100, 200, 100, 200, 200, 100, 200 }));
clip.push_back(MakePathD({ 150, 50, 250, 150, 150, 250, 50, 150 }));
PathsD result = booleanOp(ClipBooleanOp::Intersection, subject, clip);
drawPathsD(result);You can also use the Clipper2 API directly via Clipper2Lib types and functions. License
- Clipper2: Boost Software License 1.0
ofxAddons