dart_polylabel2 1.0.0 copy "dart_polylabel2: ^1.0.0" to clipboard
dart_polylabel2: ^1.0.0 copied to clipboard

A fast algorithm for finding polygon pole of inaccessibility. Useful for optimal placement of a text label on a polygon.

dart_polylabel2 #

A fast algorithm for finding polygon pole of inaccessibility. Useful for optimal placement of a text label on a polygon.

Dart port of mapbox's polylabel algorithm. Thanks to beroso's original port (polylabel) for inspiration.

This has a few changes from polylabel, which make it not backwards compatible:

  • No usage of 'dart:math's Point
    • It's been described as legacy since Feb 2024 in Dart/Flutter, and will be deprecated in future
    • This reduces internal & external casting and usage of generic types (which are inefficient), which has increased performance
    • It was overkill for the simple 2D Cartesian coordinate container needed
  • Uses newer Dart lanaguage features

Usage #

import 'package:dart_polylabel2/dart_polylabel2.dart';

final polygon = [[(x: 0, y: 0), (x: 1, y: 0), (x: 1, y: 1), (x: 0, y: 1), (x: 0, y: 0)]];
final (point: (:x, :y), :distance) = polylabel(polygon);
2
likes
150
points
81.9k
downloads

Publisher

verified publisherjaffaketchup.dev

Weekly Downloads

A fast algorithm for finding polygon pole of inaccessibility. Useful for optimal placement of a text label on a polygon.

Repository (GitHub)
View/report issues

Documentation

API reference

Funding

Consider supporting this project:

github.com

License

ISC, BSD-3-Clause (license)

Dependencies

collection, meta

More

Packages that depend on dart_polylabel2