#!/bin/sh -u # $0 # Draw a parabola on the terminal screen using cursor control. # -Ian! D. Allen - idallen@idallen.ca - www.idallen.com PATH=/bin:/usr/bin ; export PATH LC_ALL=C ; export LC_ALL # no internationalization in this script LANG=C ; export LANG umask 022 tput clear width=80 num=20 y=$(( -num )) while [ $y -le $num ] ; do x=$(( y*y )) # Calculate the display values of X,Y from the program values. # The display values must be non-negative and fit on terminal screen. # dispy=$(( y+num )) dispx=$(( x*width/num/num )) # integer math: do multiplication before division # "tput cup" positions the terminal cursor on the terminal screen. # "tput cup" arguments have Y position first, followed by X... # tput cup $dispy $dispx ; echo -n '*' y=$(( y+1 )) sleep 0.1 done