- Creating Voronoi diagram png image with distinct colors generator
- Colors are generated by alternating beetween r, g, b and 'binary-search' values of range(0, 256) ex. 0, 256, 128, 64, 192 etc.
- Canvas is filled with two methods. fill_by_circles and fill_by_calculating_distance
- fill_by_calculating_distance calculates the distance for all the seeds per pixel, to find the closest, and colors it to seeds color
- fill_by_circles calculates a two rectangles, one in circle, one outside the circle
- Rectangle inside is 'safe' to paint to seed color
- Painting the rectangle outside needs one calculation of distance to the seed center to check if it is in the circle radius
- Most expensive method is distance calculation, fill_by_circles should help lower the computing time
- fill_by_circles improvement is not huge, 10-20% time, depending on the random seed locations
fill_by_calculating_distance
➜ pvoronoi git:(main) make time
docker compose run pvoronoi time python3 main.py
real 0m 5.32s
user 0m 5.49s
sys 0m 0.27sfill_by_circles + fill_by_calculating_distance
➜ pvoronoi git:(main) ✗ make time
docker compose run pvoronoi time python3 main.py
real 0m 3.57s
user 0m 3.68s
sys 0m 0.33s- python3, python3-venv and requirements.txt
- or with docker
- poc done
$ python3 -m venv venv/
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python3 main.py
$ deactivate$ docker compose run --rm pvoronoi python3 main.py



