Optimize a Worley Noise Program
OneLetterShor 14 May 2020 18:54
I would like to have this optimized as much as possible. Speed is more important than size in my opinion.
ClrHome:ClrDraw
38→A:24→B:8→N:1→M
randInt(0,A-1,N)→⸤SEEDX
randInt(0,B-1,N)→⸤SEEDY
{11,15,19,14,10,13,23,22,21,20}→⸤COLOR
0→R
"√((⸤SEEDX(I)-K)²+(⸤SEEDY(I)-L)²"→u
For(K,0,A)
For(L,0,B)
N→dim(⸤DISTS)
For(I,1,N)
u→⸤DISTS(I)
End
SortA(⸤DISTS)
If ⸤DISTS(M)>R
⸤DISTS(M)→R
End:End
For(K,0,A)
For(L,0,B)
For(I,1,N)
u→⸤DISTS(I)
End
SortA(⸤DISTS)
⸤COLOR(max(1,(min,23,int(round(10*⸤DISTS(M)/R,0)))))→C
Pt-On(K,L,C)
Pt-On(K,L,2,C)
End:End
For(I,1,N)
Pt-On(⸤SEEDX(I),⸤SEEDY(I),BLACK)
Pt-On(⸤SEEDX(I),⸤SEEDY(I),2,BLACK)
End