/* remapping functions */
v1=rnd();v2=rnd();
for(i=[-0:1/160:1])translate([i,0])square([1/160, (( comp(i,v1,v2)))]);
function comp(i,c=0.5,s=0.75)=i<c? ramp(i,0,c,0,s) :ramp(i,c,1,s,1) ;
function ramp(v,bi1=1/3,bi2=2/3,start=1/3, end=2/3) =
let(b1=min(bi1,bi2),b2=max(bi1,bi2))
v<=b1?start:v<=b2?lerp(start,end,(v-b1)/(b2-b1)) :end;
function lerp(start, end, bias) = (end * bias + start * (1 - bias));
function rnd(a = 1, b = 0, s = []) =
s == [] ?
(rands(min(a, b), max( a, b), 1)[0])
:
(rands(min(a, b), max(a, b), 1, s)[0])
;
No comments:
Post a Comment