/*
* I wanted to try some vector manipulation using Amazing Maze for clues. * * This looks a bit like eukaryotic cells in a confocal laser microscope. * * Taken from: https://www.contextfreeart.org/gallery/view.php?id=4240 * * Originally created by flembobs, on 29.07.2021. */
startshape V []
gridSize=512
// Initialize vector64 - from thijs Amazing Maze O1=0,0,0,0,0,0,0,0 O64=O1,O1,O1,O1,O1,O1,O1,O1
//push one item onto the vector vector64 push64(vector64 v64,val)=v64[ 1, 63 ], val
//push 64 random vals 0..1 onto vector vector64 rand64_(n,vector64 v64)=if(n<=0,
v64, rand64_(n-1, push64(v64,rand())))
vector64 rand64()=rand64_(64,O64)
//2d distance calc d2(i,j)=(i-j)^2 dist(vector2 v1, vector2 v2)=sqrt(d2(v1,v2)+d2(v1,v2))
//find smallest dist between pos and any X,Y pair
mindist_(vector2 pos, vector64 vX, vector64 vY, n, m)=
if ( n < 0, m, let( q=(vX[n], vY[n]); d=dist(pos,q); o=min(m,d); mindist_(pos, vX, vY, n-2, o )))
mindist(vector2 pos, vector64 vX, vector64 vY)=
min(mindist_(pos,vX,vY,63,∞),mindist_(pos,vX,vY,62,∞)) //hack: split the list in two to avoid running out of stack
shape V {
vX = rand64() vY = rand64() //draw the vX/vY for debugging //loop i=64 [] // SQUARE [ x (gridSize*vX[i]) y (gridSize*vY[i]) s 2 b 1 sat 1 z 10 ] loop i=gridSize [ x 1 ] loop j=gridSize [ y 1 ] { v1= i/gridSize, j/gridSize d=mindist( v1, vX, vY ) B=1-(d*8) SAT=1 H=mod(d*60,6)*60 SQUARE [ b B sat SAT h H ] }
}