PoPo
PoPo offers fast (Po)isson Disc Sampling for arbitrary (Po)lygons.
Usage
Note: The exposed API may change in future releases. Expect breaking changes until the v1.0.0 release.
Filling a padded polygon with samples
use sample;
use Vec2;
let polygon = vec!;
let samples: = sample.collect;
assert!;
println!;
for point in samples
Generating a limited number of samples
The returned value is an iterator, so you can limit the number of samples generated by using .take(n).
...
let samples: = sample.take.collect;
...
Padding
| Positive (Inwards) padding | No padding | Negative (Outwards) padding |
|---|---|---|
![]() |
![]() |
![]() |
How fast is it?
Currently, the library can generate around 100,000 samples in under 0.25 seconds,
- on a concave polygon the one from the sample application,
- on a 2023 MacBook Pro (16GB) with an M2 Pro chip,
- in release mode,
Took: 246ms to generate 102889 samples
Took: 242ms to generate 102804 samples
Took: 235ms to generate 102714 samples
Took: 243ms to generate 102947 samples
Took: 241ms to generate 102873 samples
Took: 236ms to generate 102740 samples
Took: 234ms to generate 102960 samples
Took: 231ms to generate 102945 samples
Took: 236ms to generate 102771 samples
Took: 237ms to generate 102951 samples
As another example, it can generate around ~5000 samples on a simple square polygon in 10ms.
Note: In future, I would really like to make it use all available CPU cores to speed up the sampling process, but currently it is single-threaded.
License
This project is dual-licensed under the MIT and Apache-2.0 licenses. You can choose either license for your use.


