pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post 8021b20a9 by Anonymous on Wed 27th Apr 2022 17:44
original post fa9e by Anonymous on Wed 27th Apr 2022 17:11
Download diff
Show old version | new version | both versions

    
11
#!/usr/bin/ksh93
22
33
compound c=(
44
	compound tty=(
55
		integer max_x
66
		integer max_y
77
	)
88
99
	compound data=(
1010
		float -a vals
1111
		float min=0
1212
		float max=0
1313
	)
1414
1515
)
1616
1717
(( c.tty.max_x=$(tput cols)-2 ))
1818
(( c.tty.max_y=$(tput lines)-2 ))
1919
2020
integer i
2121
integer max_i=${c.tty.max_x}
2222
2323
for ((i=0 ; i < max_i ; i++ )) ; do
2424
	(( c.data.vals[i]=sin(i/5.) ))
2525
done
2626
2727
for i in "${!c.data.vals[@]}" ; do
2828
	(( c.data.min=fmin(c.data.vals[i], c.data.min) ))
2929
	(( c.data.max=fmax(c.data.vals[i], c.data.max) ))
3030
done
3131
3232
clear
3333
34-
for ((i=0 ; i < max_i ; i++ )) ; do
34+
float c.min_data_shift
35-
	tput cup $(( int( (c.tty.max_y/2.)*((c.data.min*-1.0)+c.data.vals[i])) )) $i
35+
float c.max_data_shift
36+
float c.data_scale_to_tty_max_y
3837
39-
tput cup ${c.tty.max_y} ${c.tty.max_x} ; print
38+
(( c.min_data_shift=c.data.min*-1.0 ))
39+
(( c.max_data_shift=c.min_data_shift+c.data.max ))
4041
41-
#print -v c
42+
for i in "${!c.data.vals[@]}" ; do
43+
	tput cup $(( int( c.data_scale_to_tty_max_y * (c.min_data_shift+c.data.vals[i]) ) )) $i
4246
43-
# EOF.
47+
tput cup ${c.tty.max_y} ${c.tty.max_x} ; print
4448
45-
49+
#print -v c
4650
47-
51+
# EOF.
4852

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at