# voronoi2d

Creats a Voronoi diagram. The initial region for each cell is calculated automatically from the given points by the following code:

``````xs = [for(p = points) p];
ys = [for(p = points) abs(p)];
region_size = max([(max(xs) -  min(xs) / 2), (max(ys) -  min(ys)) / 2]);
``````

Since: 1.3

## Parameters

• `points` : Points for each cell.
• `spacing` : Distance between cells. Default to 1.
• `r`, `delta`, `chamfer` : The outlines of each cell can be moved outward or inward. These parameters have the same effect as `offset`.
• `region_type` : The initial shape for each cell can be `"square"` or `"circle"`. Default to `"square"`.

## Examples

``````use <voronoi2d.scad>;

points = [for(i = [0:50]) rands(-20, 20, 2)];

voronoi2d(points);
translate([60, 0, 0])
voronoi2d(points, region_type = "circle");
`````` ``````use <voronoi2d.scad>;

xs = rands(0, 40, 50);
ys = rands(0, 20, 50);

points = [for(i = [0:len(xs) - 1]) [xs[i], ys[i]]];

difference() {
square([40, 20]);
voronoi2d(points);
}
hollow_out(shell_thickness = 1) square([40, 20]);
`````` 