Консольный скринсервер:
function cascade_colors()
{
_I=1
_J=0
_K=0
_WIDTH=$COLUMNS
_MARGIN=0
while true; do
_A=$(($RANDOM % 3))
_B=$(($RANDOM % 2))
_C=$(($RANDOM % 3))
case $_A in
0)
case $_B in
0)
[ $_I -gt 1 ] && _I=$(($_I - 1))
;;
1)
[ $_I -lt 6 ] && _I=$(($_I + 1))
;;
esac
;;
1)
case $_B in
0)
[ $_J -gt 0 ] && _J=$(($_J - 1))
;;
1)
[ $_J -lt 5 ] && _J=$(($_J + 1))
;;
esac
;;
2)
case $_B in
0)
[ $_K -gt 0 ] && _K=$(($_K - 1))
;;
1)
[ $_K -lt 5 ] && _K=$(($_K + 1))
;;
esac
;;
esac
case $1 in
1)
_DELTA=$2
case $_C in
0)
[ $_WIDTH -lt $(($COLUMNS - 2*$_DELTA)) ] && _WIDTH=$(($_WIDTH + 2*$_DELTA))
;;
1)
[ $_WIDTH -gt $((1 + 2*$_DELTA)) ] && _WIDTH=$(($_WIDTH - 2*$_DELTA))
;;
esac
_MARGIN=$((($COLUMNS-$_WIDTH)/2))
;;
2)
_WIDTH=$2
_DELTA=$3
case $_C in
0)
[ $_MARGIN -le $(($COLUMNS - $_WIDTH - $_DELTA)) ] && _MARGIN=$(($_MARGIN + $_DELTA))
;;
1)
[ $_MARGIN -ge $_DELTA ] && _MARGIN=$(($_MARGIN - $_DELTA))
;;
esac
;;
*)
_WIDTH=$COLUMNS
_MARGIN=0
;;
esac
_NUMBER=$((15 + $_I + 6*$_J + 36*$_K))
printf "\e[0;49m"
if [ $_MARGIN -gt 0 ]; then
for _FOO in $(seq $_MARGIN); do
printf " "
done
fi
printf "\e[0;48;5;${_NUMBER}m"
for _FOO in $(seq $_WIDTH); do
printf " "
done
printf "\e[0;49m"
echo ""
done
}
потом
cascade_colors
или:
cascade_colors 1 x
или:
cascade_colors 2 x y
x и y -- числа.