TL;DR: This short algorithm can produce many kinds of distinctive, detailed textures, and will produce patterns of increasing complexity as the number of points to be searched for closeness increases.
Abstract: This short algorithm can produce many kinds o f distinctive, detailed textures. It started as a way of findin g which one of a set of points was closest to a given point. If a plane is mapped so that its color at any place represents whic h of the set of points was closest, the pattern resulting looks lik e the walls of joined soap bubbles. If one modifies the part o f the algorithm which determines which point is chosen a s closest, different and more interesting patterns appear. The algorithm can run in integer math as well as floatin g point, and will produce patterns of increasing complexity a s the number of points to be searched for closeness increases. In the following examples, max is the number of points in thi s set. To begin, try values for max from about three to ten. xsize is the horizontal screen size, and ysize is th e vertical screen size. random returns values from 0 up to its parameter, and highest is the largest value that the variabl e distance can hold, or any number larger than distance i s likely ever to hold. For example, if distance is a 16-bi t datatype, then a good value for highest is 65535. global array h, v procedure points() for i =0 to max-1 h(i) = random(xsize) v(i) = random(ysize) endloo p retur n function texture(x,y) least = highes t for i =0 to max-1 d o if x>h(i) then da = x-h(i) else da = h(i)-x endi f if y>v(i) then db = y-v(i) else db = v(i)-y endi f da=da-12 8 da = da AND 255 db=db-128 db = db AND 25 5 if distance