パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.2.0

dart_earcut

https://github.com/mapbox/earcut を基にした高性能の三角化アルゴリズム

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
114万
いいね数
10
Pub ポイント
150

パッケージをインストール

flutter pub add dart_earcut

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

dart_earcut は、Mapbox によって元々開発された Earcut アルゴリズムを実装した、Dart 向けの高性能な三角分割ライブラリです。多角形の形状を効率的に三角形に変換でき、2D グラフィックスや可視化アプリケーションにおける複雑な幾何学形状のレンダリングに最適です。このパッケージは、Android、iOS、Web、macOS、Windows、Linux など複数のプラットフォームをサポートしており、クロスプラットフォームでの一貫性を確保しています。高速かつ正確さを重視して設計されており、穴のある単純および複雑なポリゴンに対応し、計算幾何学のタスクにおいて信頼できる結果を提供します。

用途

  • 2D ゲーム開発
  • ウェブベースの地図レンダリング
  • ベクトルグラフィックス処理
  • インタラクティブなデータ可視化
  • UI コンポーネント用のメッシュ生成

主な機能

  • 高速の三角形分割パフォーマンス
  • 穴のある多角形をサポートします
  • クロスプラットフォーム互換性
  • ポリゴン入力用のシンプルな API
  • 複雑な形状に対する正確な結果

適している対象

  • グラフィックス開発者
  • GISアプリケーション作成者
  • カスタムシェイプを使用するUI/UXデザイナー
  • ゲームエンジン統合者
  • データ可視化エンジニア

注意事項

  • 有効なポリゴン入力が必要(交差しない辺)
  • リアルタイムの動的更新に最適化されていません
  • 2Dの三角化に制限
  • 自己交叉ポリゴンを直接処理しない
  • 不規則な入力に対して事前処理が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

dart_earcut

Ear-clipping (earcutting) triangulation algorithm, ported (with minor API differences) from earcut4j/earcut4j and mapbox/earcut. Also includes the fix from mapbox/earcut#91.

Usage

  • 2D (x/y) coordinates, without holes

    • triangulateRaw: expects points in the format [x0, y0, x1, y1, x2, y2, ...]
    • triangulateFromPoints: expects 'dart:math's Point objects
    final triangles = Earcut.triangulateRaw([10,0, 0,50, 60,60, 70,10]);
    final triangles = Earcut.triangulateFromPoints([Point(10, 0), Point(0,50), Point(60,60), Point(70,10)]);
    // Both return [1,0,3, 3,2,1]
    
  • Holes
    A list of hole indicies, if any. For example, [5, 8] for a 12-vertice input would mean one hole with vertices 5-7 and another with 8-11. If you pass a single vertice as a hole, Earcut treats it as a Steiner point.

    final List<int> triangles = Earcut.triangulateRaw([0, 0, 100, 0, 100, 100, 0, 100, 20, 20, 80, 20, 80, 80, 20, 80], holeIndices: [4]);
    // Returns [3,0,4, 5,4,0, 3,4,7, 5,0,1, 2,3,7, 6,5,1, 2,7,6, 6,1,2]
    
    • triangulateFromPointsAndHolePoints performs the logic to generate holeIndices when the outline of a polygon and the outline of its holes are available as points seperately.
  • More dimensions
    Expected to be in the format [x0, y0, z0, x1, y1, z1, x2, y2, z2, ...]

    final List<int> triangles = Earcut.triangulateRaw([10, 0, 1, 0, 50, 2, 60, 60, 3, 70, 10, 4], dimensions: 3);
    // Returns [1,0,3, 3,2,1]
    

The Algorithm

The library implements a modified ear slicing algorithm, optimized by z-order curve hashing and extended to handle holes, twisted polygons, degeneracies and self-intersections in a way that doesn't guarantee correctness of triangulation, but attempts to always produce acceptable results for practical data.

It's based on ideas from FIST: Fast Industrial-Strength Triangulation of Polygons by Martin Held andTriangulation by Ear Clipping by David Eberly.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト