link graphics, randomiz, gauss global threads,thread global allcolors,bgcolor global W, H procedure main() local R,r,x,y W:=300 H:=300 bgcolor:="very dark weak blue" randomize() WOpen("size="||W||","||H,"bg=black") | stop("can't open window") allcolors:=[ #"white", "blue","red","yellow", "green","cyan","magenta" ] threads:=[] thread:=create every |(x:=?W,y:=?H) do { R:=10+?20 cluster(x,y,R,?allcolors) } put(threads,thread) thread := ^thread put(threads,thread) every 1 to 3 & put(threads,^thread) thread := create repeat { darkcluster(?W,?H,20+?20) @&source} #put(threads, thread) thread := create repeat { Fg(bgcolor) every DrawPoint(1 to W,?H) @&source } every 1 to 3 & put(threads, thread) every !threads :=: ?threads every 1 to 500 do { thread := get(threads) if @thread then put(threads, thread) ?threads :=: ?threads } Fg(bgcolor) every 1 to W/5 & DrawPoint(1 to W,?H) #WriteImage("cluster.bmp") WriteImage("cluster.gif") WClose() end procedure cluster(x,y,sigma,color) local dx,dy local light,sat local all local c local s all:=?0 > 0.8 s:=sigma every 1 to 12 do { c := if ?0 < 0.8 then color else ?allcolors Fg("very dark "||c) every 1 to ?500 do { dx:=gauss(0)*sigma dy:=gauss(0)*sigma drawPoint(x+dx,y+dy) } if /all then @&source sigma *:= 1.06 #just for an experiment } put(threads,create darkcluster(x,y,s*1.5)) return end procedure darkcluster(x,y,sigma) local dx,dy every 1 to 12 do { Fg(bgcolor) every 1 to 300 do { dx:=gauss(0)*sigma dy:=gauss(0)*sigma drawPoint(x+dx,y+dy) } @&source } return end procedure drawPoint(x,y) x<0 & x +:= W x>W & x -:= W y<0 & y +:= H y>H & y -:= H DrawPoint(x,y) return end