Thanks to TheComet for helping me remember what this technique was called. I first came across it when looking up random terrain generation. The basic idea is having certain spots fixed on map, and the neighboring tiles will match whichever fixed point is closest.

On a 500x500 map and 20 fixed points, I get about 10fps so clearly this isn't something you'd want to do in real time.

// Project:
// Created:
// show all errors
SetErrorMode(2)
// set window properties
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
SetWindowTitle("Voronoi Tessellation")
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 )
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
Type Point2D
x as integer
y as integer
color as integer
EndType
global points as Point2D[20]
for i = 1 to points.length
points[i].x = random(1, 500)
points[i].y = random(1, 500)
points[i].color = makeColor(random(0,255), random(0,255), random(0,255))
next i
pc = makeColor(255,255,255)
do
for x = 1 to 500
for y = 1 to 500
i = getClosestVoronoi(x, y)
drawBox(x, y, x+1, y+1, points[i].color,points[i].color,points[i].color,points[i].color, 1)
next y
next x
for i = 1 to points.length
drawEllipse(points[i].x, points[i].y, 5, 5, pc, pc, 1)
next i
Print( ScreenFPS())
Sync()
loop
function getClosestVoronoi(x as integer, y as integer)
dist = 10000000
for i = 1 to points.length
d = (points[i].x - x)^2 + (points[i].y - y)^2
if d < dist
dist = d
index = i
endif
next i
endfunction index