aboutsummaryrefslogtreecommitdiff
path: root/tmac/tmac.gr
blob: 56bde3b075d85b28f0b2bb87c053c7d129473038 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
.\" A macro package for drawing simple charts and curves
.\"
.\" The main macros are as follows:
.\"
.\" .grbeg "xmin x1" "xmax x2" "ymin y1" "ymax y2" [opts]
.\"   Begin a graph; the arguments specify the minimum and maximum
.\"   x and y values.  The value of other variables may be specified
.\"   similarly.  For instance, adding "barwid 2" sets the width of
.\"   bars.
.\"
.\" .grend
.\"   End the current graph.
.\"
.\" .grbar pos height [opts]
.\"   Draw a bar at x=pos with the given height.  The width of
.\"   the bar can be specified as "barwid N".
.\"
.\" .grcurbeg [opts]
.\"   Begin a curve.
.\"
.\" .grcur x y
.\"   Specify the next point in the current curve.
.\"
.\" .grcurend
.\"   End and draw the current curve.
.\"
.\" .grnum x label
.\"   Specify x-axis label at x.
.\"
.\" .grval y label
.\"   Specify y-axis label at y.
.\"
.\" .grtxt x y "text"
.\"   Write "text" in the given position.
.\"
.\" .grclr line fill
.\"   Specify graph colours.
.\"
.\" .grlab.x "label" [pos]
.\"   Specify x-axis label.
.\"
.\" .grlab.y "label" [pos]
.\"   Specify y-axis label.
.\"
.nr grlnsz 24		\" Line point size
.nr grptsz 12		\" Text point size
.nr grbarwid 1		\" Bar width
.nr grratio 133		\" Aspect ratio (width / height * 100)
.ds grclr.ln "#725	\" Line colour
.ds grclr.fl "#fff	\" Fill colour
.de grbeg
.	br
.	nr grxmin 0
.	nr grxmax 0
.	nr grymin 0
.	nr grymax 0
.	gropt "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
.	nr grxwid 0\\n[grxmax]-\\n[grxmin]
.	nr grywid 0\\n[grymax]-\\n[grymin]
.	nr grwd \\n(.l-\\n(.i
.	nr grht \\n[grwd]*100/\\n[grratio]
.	nr grxoff \\n(.i
.	nr gryoff \\n(.d+\\n[grht]
.	ne \\n[grht]u
.	ev grenv
.	nf
..
.\" map graph positions to roff position
.ds grx \\n[grxoff]+((\\$1-\\n[grxmin])*\\n[grwd]/\\n[grxwid])
.ds gry \\n[gryoff]-((\\$1-\\n[grymin])*\\n[grht]/\\n[grywid])
.ds grwd ((\\$1)*\\n[grwd]/\\n[grxwid])
.ds grht ((\\$1)*\\n[grht]/\\n[grywid])
.\" read graph options
.de gropt
.	if \\n(.$>=1 .if !"\\$1"" .nr gr\\$1
.	if \\n(.$>=2 .if !"\\$2"" .nr gr\\$2
.	if \\n(.$>=3 .if !"\\$3"" .nr gr\\$3
.	if \\n(.$>=4 .if !"\\$4"" .nr gr\\$4
.	if \\n(.$>=5 .if !"\\$5"" .nr gr\\$5
.	if \\n(.$>=6 .if !"\\$6"" .nr gr\\$6
.	if \\n(.$>=7 .if !"\\$7"" .nr gr\\$7
..
.de grbar
.	gropt "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
.	nr grxdiff \\*[grwd \\n[grbarwid]]
.	nr grx1 \\*[grx \\$1]-(\\n[grxdiff]/2)
.	nr gry1 \\*[gry \\n[grymin]]
.	nr gry2 \\*[gry \\$2]
.	nr grydiff (\\n[gry2]-\\n[gry1])
.	ps \\n[grlnsz]
\m[\\*[grclr.fl]]\v'|\\n[gry1]u'\h'|\\n[grx1]u'\D'P \\n[grxdiff]u 0u 0u \\n[grydiff]u -\\n[grxdiff]u 0u'\m[]
\m[\\*[grclr.ln]]\v'|\\n[gry1]u'\h'|\\n[grx1]u'\D'p \\n[grxdiff]u 0u 0u \\n[grydiff]u -\\n[grxdiff]u 0u'\m[]
.	ps
.	sp -2
..
.de grnum
.	nr grx1 \\*[grx \\$1]
.	nr gry1 \\*[gry \\n[grymin]]
.	ps \\n[grptsz]
\v'|\\n[gry1]u+1v'\h'|\\n[grx1]u-(\\w'\\$2'u/2u)'\\$2
.	ps
.	sp -1
.	if \\n(.$>2&\\$3 \v'|\\n[gry1]u'\h'|\\n[grx1]u'\D'l 0 -\\n[grht]u'
.	if \\n(.$>2&\\$3 .sp -1
..
.de grval
.	nr grx1 \\*[grx \\n[grxmin]]
.	nr gry1 \\*[gry \\$1]
.	ps \\n[grptsz]
\v'|\\n[gry1]u'\h'|\\n[grx1]u-\\w'\\$2'u-1m'\\$2
.	ps
.	sp -1
.	if \\n(.$>2&\\$3 \v'|\\n[gry1]u'\h'|\\n[grx1]u'\D'l \\n[grwd]u 0'
.	if \\n(.$>2&\\$3 .sp -1
..
.de grlab.x
.	ps \\n[grptsz]
\v'|\\n[gryoff]u+2v\\$2'\h'|\\n[grxoff]u+(\\n[grwd]u/2u)-(\\w'\\$1'u/2u)'\\$1
.	ps
.	sp -1
..
.de grlab.y
.	ps \\n[grptsz]
\v'|\\n[gryoff]u-(\\n[grht]u/2u)'\h'|\\n[grxoff]u-2v\\$2'\
\X'rotate 90'\h'-(\\w'\\$1'u/2u)'\\$1\X'rotate 0'
.	ps
.	sp -1
..
.de grtxt
.	nr grx1 \\*[grx \\$1]
.	nr gry1 \\*[gry \\$2]
.	ps \\n[grptsz]
\v'|\\n[gry1]u'\h'|\\n[grx1]u'\h'-(\\w'\\$3'u/2u)'\\$3
.	ps
.	sp -1
..
.de grcurbeg
.	gropt "\\$1" "\\$2" "\\$3" "\\$4" "\\$5"
.	ds grcur.s "
.	nr grcur.x 0
.	nr grcur.y 0
.	nr grcur.beg 0
.	nr grcur.xbeg 0
.	nr grcur.ybeg 0
..
.de grcur
.	nr grx \\*[grx \\$1]
.	nr gry \\*[gry \\$2]
.	if !\\n[grcur.beg] .nr grcur.xbeg \\n[grx]
.	if !\\n[grcur.beg] .nr grcur.ybeg \\n[gry]
.	nr grxdiff \\n[grx]-\\n[grcur.x]
.	nr grydiff \\n[gry]-\\n[grcur.y]
.	if \\n[grcur.beg] .as grcur.s "\D'l \\n[grxdiff]u \\n[grydiff]u'
.	nr grcur.x \\n[grx]
.	nr grcur.y \\n[gry]
.	nr grcur.beg 1
..
.de grcurend
.	ps \\n[grlnsz]
\m[\\*[grclr.ln]]\v'|\\n[grcur.ybeg]u'\h'|\\n[grcur.xbeg]u'\\*[grcur.s]\m[]
.	ps
.	sp -1
..
.de grend
.	ps \\n[grlnsz]
\v'|\\n[gryoff]u'\h'|\\n[grxoff]u'\D'p \\n[grwd]u 0 0 -\\n[grht]u -\\n[grwd]u 0'
.	ps
.	sp |\\n[gryoff]u
.	ev
..
.de grclr
.	if \\n(.$>0 .if !'-'\\$1' .ds grclr.ln "\\$1
.	if \\n(.$>1 .if !'-'\\$2' .ds grclr.fl "\\$2
..
.de grloop
.	nr grnext \\$2+\\$4
.	\\$1 \\$2
.	if \\n[grnext]<\\$3 .grloop \\$1 \\n[grnext] \\$3 \\$4
..