Skip to content

loop614/pvoronoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

  • 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
circle_with_square_inside_and_outside
  • 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

time_without_fill_by_circles
pvoronoi git:(main) make time
docker compose run pvoronoi time python3 main.py
real	0m 5.32s
user	0m 5.49s
sys	0m 0.27s

fill_by_circles + fill_by_calculating_distance

time_with_fill_by_circles
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

Requirements

  • python3, python3-venv and requirements.txt
  • or with docker

Status

  • poc done

Quick Start

$ python3 -m venv venv/
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python3 main.py
$ deactivate

Quick Start using Docker:

$ docker compose run --rm pvoronoi python3 main.py

Method fill_by_circles

fill_by_circles

Output

output

About

Voronoi diagram with distinct color generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published