Skip to content

Examples

Seth Hillbrand edited this page Oct 29, 2026 · 2 revisions

Home › Examples

Examples

Sample 1:

#include "clipper2/clipper.h"
...
using namespace Clipper2Lib;
int main()
{
  Paths64 subject, clip, solution;
  subject.push_back(MakePath({100, 50, 10, 79, 65, 2, 65, 98, 10, 21}));
  clip.push_back(MakePath({98, 63, 4, 68, 77, 8, 52, 100, 19, 12}));
  solution = Intersect(subject, clip, FillRule::NonZero);    
}

Sample 2:

#include "clipper2/clipper.h"
...
using namespace Clipper2Lib;

int main()
{
  //set up the subject and clip polygons ...
  Paths64 subject;
  subject.push_back(Ellipse(Rect64(100,100,300,300)));
  subject.push_back(Ellipse(Rect64(125,130,275,180)));
  subject.push_back(Ellipse(Rect64(125,220,275,270)));

  Paths64 clip;
  clip.push_back(Ellipse(Rect64(140,70,220,320));

  //get the intersection
  Paths64 solution = Intersect(subject, clip, FillRule::EvenOdd);

  //DrawPolygons    
}

Clone this wiki locally