voronoi_diagram

Creator: coderz1093

Last updated:

0 purchases

voronoi_diagram Image
voronoi_diagram Images
Add to Cart

Description:

voronoi diagram

voronoi_diagram #

This repository is used to draw voronoi diagrams. You just have to pass sites point and the size of your diagram.
getVoronoiDiagram(sites: sites, diagramBound: diagramBound)
copied to clipboard
This return a Future<List<List<Offset>>>, each List<Offset> represent a voronoi cell. Then you can draw your voronoi diagram easily with a CustomPainter, e.g
for (final voronoiCell in voronoiDiagram) {
canvas.drawPoints(
PointMode.polygon,
voronoiCell,
Paint()
..color = Colors.red
..strokeWidth = 2,
);
}
copied to clipboard
There is also a default VoronoiDiagramPainter to display the diagram on the screen. You can use it like this inside a CustomPaint widget :
CustomPaint(
size: benchmarkData.diagramSize,
painter: VoronoiDiagramPainter(
generatorPoints: benchmarkData.generatorPoints,
voronoiDiagram: data,
),
)
copied to clipboard
Benchmark #
It get the drawable voronoi diagram representation in ~115ms, with 10000 sites and a diagram size of 400x400
It's calculated in "real life" context, i.e in a flutter app
you can run the benchmark with the benchmark.sh script, in the example folder.
How does it works ? #
Dart code take inputs, then it use dart:ffi to calculate the voronoi diagram with the rust language, then the result is pass back to the dart side.
The rust side is using an implementation of the Fortune's algorithm. If you want to know more about this amazing topic, I recommand to read this amazing article
Contribution #
To start working on the project, you must check the following.
To begin, ensure that you have a working installation of the following items:

Flutter SDK
Rust language
Appropriate Rust targets for cross-compiling to your device
For Android targets:

Install cargo-ndk
Install Android NDK 22, then put its path in one of the gradle.properties, e.g.:



echo "ANDROID_NDK=.." >> ~/.gradle/gradle.properties
copied to clipboard
If you are struggling during the set up, please check the flutter_rust_bridge documenation

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.