|
|
|
|
|
by anyfoo
236 days ago
|
|
Maybe you'll get a kick out of this, I did it in a bored afternoon a while back: echo -ne '\e[8;32;90;t';n=20;t=524292;l=$((t-1));m=$((2**n-1));c=0;xs=(1);ys=(1);for ((i=0;i<n*m;i++));do b=$((l&1));l=$(((l>>1)^(b*t)));c=$(((c<<1|b)&m));[ $((i%n)) -eq 0 ] &&{xs=($c $xs[1,4]);y=$((((xs[4]-xs[0])<<30-0x3fffd60f*ys[2]+0x7d32617c*ys[1])>>30));ys=($y $ys[1]);yd=$((120+(y >> 24)));printf '\e[48;5;%um ' $yd};done
It is entirely self-contained (but needs zsh, not bash, for dumb reasons). Terminal at 90 columns works best.It is just a very simple integer LFSR as a random number source, followed by a hand-made integer IIR filter (manually placing poles on the z-plane). All of this entirely with trivial integer operations only (effectively using 32 bit fixed point arithmetic) So without any external input or tools at all, and not even using zsh's $RANDOM, it makes an "analog" weavy pattern. The LFSR is this part: b=$((l&1));l=$(((l>>1)^(b*t)));c=$(((c<<1|b)&m))
The hand-made filter is this part: xs=($c $xs[1,4]);y=$((((xs[4]-xs[0])<<30-0x3fffd60f*ys[2]+0x7d32617c*ys[1])>>30));ys=($y $ys[1])
I specifically tuned the filter peak just slightly away from being an integer divisor of 90 columns, to give the pattern a slight "rolling" effect.* |
|
The zsh dependency is super unfortunate, though :(