Skip to content
An openFrameworks wrapper for Clipper - "an open source freeware polygon clipping library".
C++ Other
  1. C++ 99.7%
  2. Other 0.3%
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Overhaul. Mar 8, 2019
libs Overhaul. Mar 8, 2019
src Overhaul. Mar 8, 2019
.gitignore Overhaul. Mar 8, 2019 Overhaul. Mar 8, 2019
ofxaddons_thumbnails.png Thumb. Aug 13, 2013




An openFrameworks wrapper for Clipper - "an open source freeware polygon clipping library".

From the author's website:

"The Clipper library primarily performs the boolean clipping operations - intersection, union, difference & xor - on 2D polygons. It also performs polygon offsetting.

The library handles complex (self-intersecting) polygons, polygons with holes and polygons with overlapping co-linear edges. Input polygons for clipping can use EvenOdd, NonZero, Positive and Negative filling modes. The clipping code is based on the Vatti clipping algorithm, and out performs other clipping libraries."



Clipper works internally with integers. If you do slow animated clipping operations, motion may not be smooth. One solution is to do supersampling. To get 0.1 pixel resolution (10x the default) multiply all ofPolyline vertex coordinates by 10, use the enlarged polyline with Clipper, and finally scale the result down with ofScale(0.1) when drawing the result.

Filled shapes

Clipper outputs a std::vector<ofPolyline>. ofPolyline can not be rendered as a filled shape (OF 0.10). One way to draw polylines as filled shapes is to use ofVertex():

for(auto& v: aPolyline)


To use ofxClipper, first you need to download and install Open Frameworks.

To get a copy of the repository you can download the source from or, alternatively, you can use git clone:

git clone git://

The addon should sit in openFrameworks/addons/ofxClipper/.

Which version to use?

ofxClipper has been tested with the latest development version of openFrameworks.


void ofApp::draw()
    ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);

    // Create two partially overlapping rotating pentagons

    ofPolyline pa, pb;

    for(int i = 0; i < 5; i++)
        float a = i * glm::two_pi<float>() / 5 + ofGetElapsedTimef();
        pa.addVertex(300 * std::cos(a) - 80, 300 * std::sin(a));
        pb.addVertex(300 * std::cos(-a) + 80, 300 * std::sin(-a));


    // Create and populate clipper
    ofx::Clipper clipper;
    clipper.addPolyline(pa, ClipperLib::ptSubject);
    clipper.addPolyline(pb, ClipperLib::ptClip);

    // Calculate intersection between the two pentagons
    auto intersection = clipper.getClipped(ClipperLib::ClipType::ctIntersection);

    // Draw result
    for (auto& line: intersection)

Note: this minimal example tries to be short, not fast. Avoid creating instances of ofPolyline and ofx::Clipper inside draw().

Build Status

No CI.


The stable branch of this repository is meant to be compatible with the openFrameworks stable branch, which corresponds to the latest official openFrameworks release.

The master branch of this repository is meant to be compatible with the openFrameworks master branch.

Some past openFrameworks releases are supported via tagged versions, but only stable and master branches are actively supported.


This project uses Semantic Versioning, although strict adherence will only come into effect at version 1.0.0.




Check out the Help Wanted tag in the issues section for specific ideas or propose your own new ideas.

Pull Requests are always welcome, so if you make any improvements please feel free to float them back upstream :)

  1. Fork this repository.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create new Pull Request.
You can’t perform that action at this time.