Skip to content

Helpers for visualizing delaunator with pixie.

License

Notifications You must be signed in to change notification settings

patternspandemic/pixienator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pixienator

Helpers for visualizing Delaunator with Pixie.

nimble install pixienator

API Reference - A work in progress.

Features

  • Path generating templates for various parts of the Delaunator datastructure.

Example

import std/[random, sugar]
import delaunator, delaunator/helpers, pixie, pixienator

var
  width = 300
  height = 300
  image = newImage(width, height)

  # Generate a normal distribution of 20 points.
  siteCount = 20
  normalPoints = collect(newSeq):
    for i in 1 .. siteCount: [gauss(width.float64 / 2.0, width.float64 / 6.0), gauss(height.float64 / 2.0, height.float64 / 6.0)]

  # Create the dual graph.
  d = delaunator.fromPoints[array[2, float64], float64](normalPoints)


# Clip infinite regions to match our image size.
d.bounds = (0.0, 0.0, width.float64, height.float64)

let # Use some Pixienator helpers to generate Pixie Paths:
  triangulation = pathForTriangleEdges(d)
  voronoi = pathsForRegions(d)

# Color each region.
for i, region in voronoi.pairs:
  image.fillPath(region, spin(color(1.0, 0.0, 1.0), i.float64 * (360.float64 / voronoi.len.float64)))

# Draw the triangulation on top.
image.strokePath(triangulation, "black")

image.writeFile("example.png")

Image output from example code above.

About

Helpers for visualizing delaunator with pixie.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages