Delphifunction RectClip(const rect: TRect64; const subjects: TPaths64): TPathsD;

Delphifunction RectClip(const rect: TRectD; const subjects: TPathsD): TPathsD;

C++Paths64 RectClip(const Rect64 rect, const Paths64& subjects);

C++PathsD RectClip(const RectD rect, const PathsD& subjects);

C# public static Paths64 RectClip(Rect64 rect, Paths64 subjects);

C# public static PathsD RectClip(RectD rect, PathsD subjects);

RectClip intersects subject polygons with the specified rectangular clipping region. Polygons may be simple or complex (self-intersecting).

This function is extremely fast when compared to the Library's general purpose Intersect clipper. Where Intersect has roughly O(n³) performance, RectClip has O(n) performance.

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

int main()
  const int width = 1600, height = 1200, margin = 200;
  Rect64 rect = Rect64(margin, margin, width - margin, height - margin);
  Paths64 subject;
  for (int i = 0; i < 500; ++i)
    subject.push_back(MakeRandomEllipse(10, 10, 150, 150, width, height));
  Paths64 solution = RectClip(rect, subject);

See Also

Intersect, RectClipLines, Paths64, PathsD, Rect64, RectD