Skip to content
FutureBlitz

    Install

    Import std.algo.delaunay

    Voronoi

    std.algo.delaunay

    function

    @PanicsAtCaller Public Function Voronoi(points: Vec2[], bounds: Rect): Vec2[][]

    Each point's Voronoi cell inside bounds: the polygon, counterclockwise, with no corner twice in a row, of where in bounds is no nearer another point, and empty for a point whose cell is outside bounds or only touches them, at a corner or along an edge. Points that are equal share a cell, and fewer than two points have bounds' whole rectangle for theirs. A coordinate that's infinite or NaN, or bounds that aren't finite or have a negative size, panic.

    Examples

    // Two points split the square between them, down the middle.
    Local cells = Voronoi([Vec2(25, 50), Vec2(75, 50)], Rect(0, 0, 100, 100))
    Expect(cells.Count == 2)
    For corner In cells[0]
        Expect(corner.x <= 50)
    End For

    std/algo/delaunay.fb, line 511

    Report an issue with this page or with FutureBlitz on GitHub.