1. Go to this page and download the library: Download benovermyer/voronoi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
benovermyer / voronoi example snippets
use Voronoi\Voronoi;
use Voronoi\Point;
// Create the bounding box
$bbox = new stdClass();
$bbox->xl = 0;
$bbox->xr = 400;
$bbox->yt = 0;
$bbox->yb = 400;
// Define generated points bounds
$xo = 0;
$dx = $width = 400;
$yo = 0;
$dy = $height = 400;
$n = 20;
// Generate random points
$sites = [];
for ($i=0; $i < $n; $i++) {
$point = new Point(rand($xo, $dx), rand($yo, $dy));
$sites[] = $point;
}
// Compute the diagram
$voronoi = new Voronoi();
$diagram = $voronoi->compute($sites, $bbox);