Skip to content
pubscout

clipper2

0.0.3, released 2 years ago by natlink.fi

Performs polygon clipping, intersection, union, difference, XOR, and offsetting operations.

WASM-ready
$ flutter pub add clipper2
Source repository

What it does

The clipper2 library performs intersection, union, difference and xor boolean operations on both simple and complex polygons. It also performs polygon offsetting. This library is a Dart port of Angus Johnson's Clipper2 library.

AI-written summary of version 0.0.3, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to perform boolean operations (intersection, union, difference, XOR) on polygons
  • You need polygon offsetting capabilities in a Dart or Flutter application

Skip it when

  • You need high precision 64-bit integer operations on the web (precision is restricted)
  • You are looking for UI widgets or full UI kits

Strengths

  • Port of the well-tested and robust Clipper2 library
  • Works across all platforms including mobile, desktop, and web
  • Provides extensive HTML documentation from the original C++ library

Weaknesses

  • Precision is restricted when compiling for the web due to lack of 64-bit integers

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:clipper2/clipper2.dart';

final subject = Path64Ext.from([100, 50, 10, 79, 65, 2, 65, 98, 10, 21]);
final clip = Path64Ext.from[98, 63, 4, 68, 77, 8, 52, 100, 19, 12];
solution = Clipper.intersect(
  subject: subject, 
  clip: clip, 
  fillRule: FillRule.nonZero,
);

Alternatives

Packages that do the same job and could replace clipper2.

  • polybool

    Boolean operations on polygons (union, intersection, difference, xor).

  • complex

    A representation of a complex number with real and imaginary parts.