http://www.angusj.com/delphi/clipper.php
I’m trying to test out the ClipperLib in JUCE, in a vanilla GUI app.
I’ve included the clipper.cpp and clipper.hpp files in the project.
Has anyone used this lib, and can you explain how to go from one of their Paths objects to a juce::Path?
I’m looking at this code example from their website, which I have wrapped into a function.
void MainComponent::doClipTest()
{
Paths subj(2), clip(1), solution;
//define outer blue 'subject' polygon
subj[0] <<
IntPoint(180,200) << IntPoint(260,200) <<
IntPoint(260,150) << IntPoint(180,150);
//define subject's inner triangular 'hole' (with reverse orientation)
subj[1] <<
IntPoint(215,160) << IntPoint(230,190) << IntPoint(200,190);
//define orange 'clipping' polygon
clip[0] <<
IntPoint(190,210) << IntPoint(240,210) <<
IntPoint(240,130) << IntPoint(190,130);
//draw input polygons with user-defined routine ...
DrawPolygons(subj, 0x160000FF, 0x600000FF); //blue
DrawPolygons(clip, 0x20FFFF00, 0x30FF0000); //orange
//perform intersection ...
Clipper c;
c.AddPaths(subj, ptSubject, true);
c.AddPaths(clip, ptClip, true);
c.Execute(ctIntersection, solution, pftNonZero, pftNonZero);
//draw solution with user-defined routine ...
DrawPolygons(solution, 0x3000FF00, 0xFF006600); //solution shaded green
}
The idea is it calls a “user-defined function” (i.e. one that I have to supply) DrawPolygons
that draws the results of the operation. It seems to me that I should take their ClipperLib::Paths object and turn it into a juce::Path and then draw it, but I’m wondering if anyone has done this; before I try to reinvent the wheel.