diff --git a/README.rst b/README.rst index 1b87037..f7516f5 100644 --- a/README.rst +++ b/README.rst @@ -135,6 +135,31 @@ Custom pipe, for example: ``-t cMAYFORCEBWITHYOU``. .. figure:: doc/pipes.tc.png +``-c [0-7]`` +------------ + +Color of pipes, can be used more than once (D=1 2 3 4 5 6 7 0). + +Numbers are terminal color numbers. Traditionally typical values are: + ++---+------------+ +| 0 | background | ++---+------------+ +| 1 | red | ++---+------------+ +| 2 | green | ++---+------------+ +| 3 | yellow | ++---+------------+ +| 4 | blue | ++---+------------+ +| 5 | magenta | ++---+------------+ +| 6 | cyan | ++---+------------+ +| 7 | foreground | ++---+------------+ + ``-f [20-100]`` --------------- diff --git a/pipes.sh b/pipes.sh index 58bbb80..7d56e7a 100755 --- a/pipes.sh +++ b/pipes.sh @@ -39,7 +39,7 @@ NOCOLOR=0 NOEDGECHANGE=0 OPTIND=1 -while getopts "p:t:f:s:r:RBCEhv" arg; do +while getopts "p:t:c:f:s:r:RBCEhv" arg; do case $arg in p) ((p=(OPTARG>0)?OPTARG:p));; t) @@ -50,6 +50,7 @@ case $arg in ((OPTARG>=0 && OPTARG<${#sets[@]})) && V+=($OPTARG) fi ;; + c) [[ $OPTARG =~ ^[0-7]$ ]] && C+=($OPTARG);; f) ((f=(OPTARG>19 && OPTARG<101)?OPTARG:f));; s) ((s=(OPTARG>4 && OPTARG<16 )?OPTARG:s));; r) ((r=(OPTARG>=0)?OPTARG:r));; @@ -61,6 +62,7 @@ case $arg in echo -e "Animated pipes terminal screensaver.\n" echo -e " -p [1-]\tnumber of pipes (D=1)." echo -e " -t [0-$((${#sets[@]} - 1))]\ttype of pipes, can be used more than once (D=0)." + echo -e " -c [0-7]\tcolor of pipes, can be used more than once (D=1 2 3 4 5 6 7 0)." echo -e " -t c[16 chars]\tcustom type of pipes." echo -e " -f [20-100]\tframerate (D=75)." echo -e " -s [5-15]\tprobability of a straight fitting (D=13)." @@ -79,6 +81,7 @@ done # set default values if not by options ((${#V[@]})) || V=(0) +((${#C[@]})) || C=(1 2 3 4 5 6 7 0) cleanup() { # clear up standard input @@ -100,7 +103,9 @@ trap 'break 2' INT resize for (( i=1; i<=p; i++ )); do - c[i]=$((i%8)) n[i]=0 l[i]=0 + c[i]=${C[$(((i-1)%${#C[@]}))]} + n[i]=0 + l[i]=0 ((x[i]=RNDSTART==1?RANDOM*w/32768:w/2)) ((y[i]=RNDSTART==1?RANDOM*h/32768:h/2)) v[i]=${V[$(((i-1)%${#V[@]}))]} @@ -117,7 +122,7 @@ while REPLY=; read -t 0.0$((1000/f)) -n 1 2>/dev/null; [[ -z $REPLY ]] ; do ((${l[i]}%2)) && ((x[i]+=-${l[i]}+2,1)) || ((y[i]+=${l[i]}-1)) # Loop on edges (change color on loop): - ((!NOEDGECHANGE&&(${x[i]}>=w||${x[i]}<0||${y[i]}>=h||${y[i]}<0))) && ((c[i]=RANDOM%8, v[i]=V[${#V[@]}*RANDOM/M])) + ((!NOEDGECHANGE&&(${x[i]}>=w||${x[i]}<0||${y[i]}>=h||${y[i]}<0))) && ((c[i]=${C[$((RANDOM%${#C[@]}))]}, v[i]=V[${#V[@]}*RANDOM/M])) ((x[i]=(x[i]+w)%w)) ((y[i]=(y[i]+h)%h))