voronoi

module
v0.0.0-...-2b51b8d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2023 License: MIT

README

VORONOI

Package for generating Voronoi diagrams.

Documentation

Configuration options:

  • Width and height
  • Distance method : Euclidean or Manhattan
  • Number of seed points
  • Seed point radius and color
  • Render seed point or not
  • Color scheme : Random or grey scale

Usage

func main() {
    v := voronoi.NewVoronoi(
        voronoi.WithSize(800, 600),
        voronoi.WithSeed(100, 5, BLACK, true),
        voronoi.WithScheme(voronoi.ColorSchemeRandom),
        voronoi.WithMethod(voronoi.DistanceMethodManhattan),
    )
	v := voronoi.NewVoronoi(c)
	v.Generate()
	err := v.SaveToPng("/home/per/temp/voronoi.png", voronoi.ImageFormatPNG)
	if err != nil {
		_, _ = fmt.Fprintf(os.Stderr, "Failed to save to file : %v", err)
	}
}

Todo

Screenshots

Euclidean distance: screenshot Manhattan distance: screenshot

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL