to median_figures [n 4] [f 1] [imax 10000] [rand? false] if n <= 0 [stop] if f+1 == 0 [stop] x=Array n mx=Array n c=Array n r=300 ifelse rand? [ repeat n [ phi=360*repCount/n x.repCount=(List 2*rnd-1 2*rnd-1)*r c.repCount=HSB 360*repCount/(n+1) 1 1 ] ][ repeat n [ phi=360*repCount/n x.repCount=(List Cos phi Sin phi)*r c.repCount=HSB 360*repCount/(n+1) 1 1 ] ] i=n+1 c0=HSB 0 1 1 setSC 0 setUpdateGraph false ; setSaveSize [400 300] (pr [Keys: enter=updateGraph c=clean z=zoom s=save esc=stop]) until [repcount > imax] [ line x c line (list x.n x.1) c0 x=(x*f + rotate x -1)/(f+1) if Key? [ dispatchMessages ch=readChar if ch==char 13 [updateGraph] if ch=="c [clean] if ch=="z [zoom] if ch=="s [ PU setXY -400 -300 bmp=BitCopy 800 600 saveImage bmp "median_figures.png ] if ch==char 27 [stop] ] if (mod repcount 1000) == 0 [updateGraph] ] updateGraph end to zoom maxx=-10000 maxy=-10000 minx= 10000 miny= 10000 repeat n [ i=repcount if (first x.i) > maxx [maxx=first x.i] if ( last x.i) > maxy [maxy= last x.i] if (first x.i) < minx [minx=first x.i] if ( last x.i) < miny [miny= last x.i] ] x0=list minx miny extend=list maxx-minx maxy-miny normextend=list 800 600 normx0=list -400 -300 if extend.1 != 0 and2 extend.2 != 0 [ repeat n [ i=repCount x.i=(x.i-x0)/extend*normextend+normx0 ] clean ] end