Class Voronoi<P>

Voronoi regions

Type Parameters

  • P

Constructors

Methods

  • Returns the convex, closed polygon [[x0, y0], [x1, y1], ..., [x0, y0]] representing the cell for the specified point i.

    Parameters

    • i: number

    Returns Delaunay.Polygon

  • Returns an iterable over the non-empty polygons for each cell, with the cell index as property.

    Returns IterableIterator<Delaunay.Polygon & {
        index: number;
    }>

  • Returns true if the cell with the specified index i contains the specified point ⟨x, y⟩. (This method is not affected by the associated Voronoi diagram’s viewport bounds.)

    Parameters

    • i: number
    • x: number
    • y: number

    Returns boolean

  • Returns an iterable over the indexes of the cells that share a common edge with the specified cell i. Voronoi neighbors are always neighbors on the Delaunay graph, but the converse is false when the common edge has been clipped out by the Voronoi diagram’s viewport.

    Parameters

    • i: number

    Returns Iterable<number>

  • Renders the mesh of Voronoi cells to an SVG path string.

    Returns string

  • Renders the mesh of Voronoi cells to the specified context. The specified context must implement the context.moveTo and context.lineTo methods from the CanvasPathMethods API.

    Parameters

    Returns void

  • Renders the viewport extent to an SVG path string.

    Returns string

  • Renders the viewport extent to the specified context. The specified context must implement the context.rect method from the CanvasPathMethods API. Equivalent to context.rect(voronoi.xmin, voronoi.ymin, voronoi.xmax - voronoi.xmin, voronoi.ymax - voronoi.ymin).

    Parameters

    Returns void

  • Renders the cell with the specified index i to an SVG path string.

    Parameters

    • i: number

    Returns string

  • Renders the cell with the specified index i to the specified context. The specified context must implement the context.moveTo, context.lineTo, and context.closePath methods from the CanvasPathMethods API.

    Parameters

    Returns void

  • Updates the Voronoi diagram and underlying triangulation after the points have been modified in-place — useful for Lloyd’s relaxation.

    Returns Voronoi<P>

Properties

circumcenters: Float64Array

The circumcenters of the Delaunay triangles [cx0, cy0, cx1, cy1, ...]. Each contiguous pair of coordinates cx, cy is the circumcenter for the corresponding triangle. These circumcenters form the coordinates of the Voronoi cell polygons.

delaunay: Delaunay<P>

The Voronoi diagram’s associated Delaunay triangulation.

vectors: Float64Array

An array [vx0, vy0, wx0, wy0, ...] where each non-zero quadruple describes an open (infinite) cell on the outer hull, giving the directions of two open half-lines.

xmax: number
xmin: number

The bounds of the viewport [xmin, ymin, xmax, ymax] for rendering the Voronoi diagram. These values only affect the rendering methods (voronoi.render, voronoi.renderBounds, cell.render).

ymax: number
ymin: number