No description
Find a file
2023-06-12 15:36:18 -07:00
.github/workflows Add github doc action. 2023-06-07 17:26:22 -07:00
images Add example image. 2023-06-10 00:51:59 -07:00
src Cleanup imports, export. 2023-06-12 15:36:18 -07:00
LICENSE Initial commit 2023-06-07 12:01:09 -07:00
pixienator.nimble Bump version. 2023-06-10 11:53:17 -07:00
README.md Update README.md 2023-06-10 00:47:33 -07:00

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.