Mandelbrot set with Bourne Again Shell
Install instruction:
Download and install Termux from Google play.
Greater Than sign not allowed in description that is "". Replace them with the real greaterthan and lessthan sign.
Type command "cat m" and Enter.
Here is the code:
#! /bin/bash
vim: ts=4 :
https://rosettacode.org/wiki/Mandelbr...
scrx=${1:48}
scry=${2:22}
((xmin=8601)) # int(2.1*4096)
((xmax=2867)) # int( 0.7*4096)
((ymin=4915)) # int(1.2*4096)
((ymax=4915)) # int( 1.2*4096)
((maxiter=20))
((scrx=2))
((scry=2))
((dx=(xmaxxmin)/scrx))
((dy=(ymaxymin)/scry))
C='01234567'
(( lC=${#C} ))
for (( cy=ymax; cy=ymin; cy=dy ))
do
for (( cx=xmin; cx=xmax; cx+=dx ))
do
(( x=0, y=0, x2=0, y2=0 ))
for (( iter=0; itermaxiter && x2+y2=16384; iter++ ))
do
(( y=((x*y)11)+cy, x=x2y2+cx, x2=(x*x)12, y2=(y*y)12 ))
done
(( c=iter%lC ))
S=${C:$c:1}
echo en "\e[4${S}m "
done
echo e "\e[0m"
done
Make the program executable "chmod +x m" and Enter.
Run the program "./m" and Enter.