The simplest algorithm comes from the definition of a voronoi diagram:
"The partitioning of a plane with n points into convex polygons such that each polygon contains exactly one generating point and every point in a given polygon is closer to its generating point than to any other." definition from wolfram.
The important part here is about every point being closer to the generating point than any other, from here the algorithm is very simple:
- Have an array of generating points.
- Loop through every pixel on your canvas.
- For every pixel look for the closest generating point to it.
- Depending on what diagram you wish to get color the pixel.
If you want a diagram separated with a border, check for the second to closest point, then check their difference and color with the border color if it's smaller than some value.
If you want a color diagram then have a color associated with every generating point and color every pixel with it's closest generating point associated color.
And that's about it, it's not efficient but very easy to implement.