http://en.wikipedia.org/wiki/Voronoi_diagram
Basically, a number of points are chosen (1000, in my example, but you can change it at your will), and every pixel will get the color of the closest point.
The resulting effect may resemble a crystal, or a scaly skin, and could be useful for texture generation.
Code: Select all
const MaxAreas=1000
randomize timer
type voronoi
x as integer
y as integer
c as integer
end type
Screenres 800,600,32
dim areas(maxareas) as voronoi
for i as integer=0 to maxareas
areas(i).x=rnd(1)*800
areas(i).y=rnd(1)*600
areas(i).c=rgb(rnd(1)*256,rnd(1)*256,rnd(1)*256)
next
dim as unsigned integer ptr target=screenptr
screenlock
for y as integer=1 to 600
for x as integer=1 to 800
dim as integer dist=800*600,d,dx,dy
for i as integer=0 to maxareas
dx=areas(i).x-x
dy=areas(i).y-y
d=dx*dx+dy*dy
if d<dist then dist=d:*target=areas(i).c
next
target+=1
next
next
screenunlock
sleep