Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generate an animation that draws the Hilbert curve.
- anim_hilbert :
- # Precompute Hilbert curve.
- 0 eval "
- const n = 3 + 1;
- const N = 1<<n;
- repeat (N^2,d,
- for (x = y = 0; t = d; s = 1, s<N, s<<=1,
- rx = 1&(t>>1); ry = 1&xor(t,rx);
- !ry?(rx==1?(x = s - 1 - x; y = s - 1 - y); swap(x,y));
- x+=s*rx; y+=s*ry; t>>=2;
- );
- da_push([x,y]);
- ); da_freeze()" => pts
- r. 1,{h*5},1,2,5 b. y,0.1% n. -0.5,0.5
- # Generate frames for curve generation.
- repeat {pts,h} {
- +rows[pts] 0,$> 600,600
- eval.. "
- begin(
- const zoom = lerp(15,0.7,$%^0.15);
- const fact = 0.95*w#-1*zoom;
- angle = lerp(0,360*4,$%)°;
- R = rot(angle);
- Pc = I[-1,2];
- );
- pP = J[-1,1]; P = I;
- pP = Pc + R*(pP - Pc); P = Pc + R*(P - Pc);
- Off = lerp(Pc,0,$%^10); pP-=Off; P-=Off;
- polygon(#-1,2,round(w#-1/2 + pP*fact),round(w#-1/2 + P*fact),1,1)"
- dilate_circ. {lerp(60,5,$%^0.25)}
- +b. {lerp(8,0.5,$%^0.25)}%,3 *. 600 c. 0,255
- *.. 255 to_rgb.. map. hot
- max[-2,-1]
- r. 500,500,1,3,0,0,0.5,0.5
- w. wait 10
- rs. 50% on. frame.jpg,$>
- rm[-2,-1]
- }
Advertisement