Re: [from archive] fractal.c

Eli the Bearded <*@eli.users.panix.com> Fri, 1 Oct 2021 00:04:21 -0000 (UTC)
Newsgroups alt.ascii-art
Organization Some absurd concept
Message-ID <[email protected]>
In alt.ascii-art, Christian Garbs  <[email protected]> wrote:
> Colin Randall <[email protected]> wrote:
>> I once found a little program in a .sig that creates a fractal in ascii when
>> you run it. Here we go:
> I also have one lying around, but don't know the source.
> The output is not as pretty, but it is plain shell (no C, no floats).
>   - - - - - - - - - - - - - - - - 8< - - - - - - - - - - - - - - - -
> 
> sh -c 'set 2 1 0 / . - + ^ : , ! %;y=70;for a in $* $*;do x=54;while [ \
> ${#s} -lt 79 ];do r=0;i=0;for b in % $*;do [ $(((q=r*r)+(t=i*i))) -ge 9\
> 999 ]&&break;i=$((y+(r*i)/32));r=$((x+(q-t)/64));done;s=$b$s;x=$((x-2))\
> ;done;y=$((y-6));echo $s;s=;done;'
> 
>   - - - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - -

I'd suggest one change to help that be prettier: |tr % " "
Added right before $s is reset to empty:

sh -c 'set 2 1 0 / . - + ^ : , ! %;y=70;for a in $* $*;do x=54;while [ \
${#s} -lt 79 ];do r=0;i=0;for b in % $*;do [ $(((q=r*r)+(t=i*i))) -ge 9\
999 ]&&break;i=$((y+(r*i)/32));r=$((x+(q-t)/64));done;s=$b$s;x=$((x-2))\
;done;y=$((y-6));echo $s|tr % " ";s=;done;'

2222222222222222111111000000000000000000///.+,+..111111111111111111111111111111
2222222222222100000000000000000000///////...-^: :   /////1111111111111111111111
222222222220000000000000000000/////////....+:     ^+-..//////001111111111111111
222222222000000000000000000/////////...-+^:          +.....////0001111111111111
222222200000000000000000////////-+---+++::,         ,^^+-------//00000111111111
222222000000000000000/////...-+,                         !,  ,! :.0000001111111
222200000000000000........----^:!                               -..000000011111
22220000000000.........---+^:                                  :++-./0000000111
22200000--, !:++:  ::+++^^^,                                      :.//000000011
22......-++:             !!                                      !-///000000001
22.....^:,                                                       +..///00000001
22++::                                                         ^-...///00000000
22:                                                           :+-..////00000000
22.... ,:!                                                      :-.////00000001
22......+++!                                                      -.///00000001
222/....--^    :!     :::::,                                     ^+.//000000011
2220000000000---+.....--+++^,                                  !:::./0000000111
22220000000000000.........---:                                 :-../00000011111
22222000000000000000////....--+:!                               :./000000111111
22222220000000000000000///////-!,, ,^^! !,           ,: ,----+^:.00000111111111
22222222000000000000000000/////////.----+^^         ,+-.....////000111111111111
22222222220000000000000000000/////////....,       ,: .../////000111111111111111
22222222222200000000000000000000////////....+^:  ,+--//////11111111111111111111
22222222222222211110000000000000000000////..-,,--../111111111111111111111111111


And here it's reworked to be a nice bricktext:

sh -c 'c="2 1 0 / . - + ^ : , ! %";y=70;for a in $c $c; do x=54;
while [ ${#s} -lt 79 ];do r=0; i=0;for b in % $c;do [ $(((q=r*r)
+(t=i*i))) -ge 9999 ]&&break;i=$((y+(r*i)/32));r=$((x+(q-t)/64))
done;s=$b$s;x=$((x-2));done;y=$((y-6));echo $s|tr % " ";s=;done'

Elijah
------
probably not all /bin/sh will be happy with that