File: graphf.etc

package info (click to toggle)
lout 3.25-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 9,252 kB
  • ctags: 3,152
  • sloc: ansic: 31,182; makefile: 254; awk: 83
file content (295 lines) | stat: -rw-r--r-- 3,901 bytes parent folder | download | duplicates (7)
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295

###############################################################################
#                                                                             #
#  Lout @GraphMath package for @Graph (Version 1.1)                           #
#                                                                             #
#  Version 1.0 by Jeffrey H. Kingston, December 1993.                         #
#  Version 1.1 by Jeffrey H. Kingston, October 1996.                          #
#                                                                             #
#  This package provides mathematics for the @Graph graph drawing package.    #
#                                                                             #
###############################################################################

export

    "-0" "-1" "-2" "-3" "-4" "-5" "-6" "-7" "-8" "-9" "-."
    pi e sqrt abs ceiling floor truncate round cos sin atan
    exp log rand "*" "/" idiv mod "+" "-"
    "=" "!=" "<" "<=" ">" ">=" not and xor or
    if xloop yloop zloop

def @GraphMath
{
    def "-0" { "-0" }
    def "-1" { "-1" }
    def "-2" { "-2" }
    def "-3" { "-3" }
    def "-4" { "-4" }
    def "-5" { "-5" }
    def "-6" { "-6" }
    def "-7" { "-7" }
    def "-8" { "-8" }
    def "-9" { "-9" }
    def "-." { "-." }

    def pi { "3.14159" }

    def e  { "2.71828" }

    def sqrt
	precedence 40
	right y
    {
	y "sqrt"
    }

    def abs
	precedence 40
	right y
    {
	y "abs"
    }

    def ceiling
	precedence 40
	right y
    {
	y "ceiling"
    }

    def floor
	precedence 40
	right y
    {
	y "floor"
    }

    def truncate
	precedence 40
	right y
    {
	y "truncate"
    }

    def round
	precedence 40
	right y
    {
	y "round"
    }

    def cos
	precedence 40
	right y
    {
	y "cos"
    }

    def sin
	precedence 40
	right y
    {
	y "sin"
    }

    def atan
	precedence 39
	left x
	right y
    {
	x y "atan"
    }

    def exp
	precedence 38
	left x
	right y
    {
	x y "exp"
    }

    def log
	precedence 37
	left x
	right y
    {
	x y "dolog"
    }

    def rand
	precedence 36
	left x
	right y
    {
	x y "dorand"
    }

    def "*"
	precedence 35
	left x
	right y
    {
	x y "mul"
    }

    def "/"
	precedence 35
	left x
	right y
    {
	x y "div"
    }

    def "idiv"
	precedence 34
	left x
	right y
    {
	x y "idiv"
    }

    def "mod"
	precedence 34
	left x
	right y
    {
	x y "mod"
    }

    def "-"
	precedence 33
	left x
	right y
    {
	x @Case {
	    ""   @Yield { y "neg" }
	    else @Yield { x y "sub" }
	}
    }

    def "+"
	precedence 32
	left x
	right y
    {
	x @Case {
	    ""   @Yield { y }
	    else @Yield { x y "add" }
	}
    }

    def "="
	precedence 30
	left x
	right y
    {
	x y "eq"
    }

    def "!="
	precedence 30
	left x
	right y
    {
	x y "ne"
    }

    def "<"
	precedence 30
	left x
	right y
    {
	x y "lt"
    }

    def "<="
	precedence 30
	left x
	right y
    {
	x y "le"
    }

    def ">"
	precedence 30
	left x
	right y
    {
	x y "gt"
    }

    def ">="
	precedence 30
	left x
	right y
    {
	x y "ge"
    }

    def "not"
	precedence 25
	right y
    {
	y "not"
    }

    def "and"
	precedence 24
	left x
	right y
    {
	x y "and"
    }

    def "xor"
	precedence 23
	left x
	right y
    {
	x y "xor"
    }

    def "or"
	precedence 22
	left x
	right y
    {
	x y "or"
    }

    def if
	named cond { true }
	named then {}
	named else {}
    {
	cond "{" then "} {" else "} ifelse"
    }

    def xloop
	named from { 0 }
	named to { 0 }
	named by { 1 }
	named do named x { "xval" } {}
    {
	from by to "{ /xval exch def" do "} for"
    }

    def yloop
	named from { 0 }
	named to { 0 }
	named by { 1 }
	named do named y { "yval" } {}
    {
	from by to "{ /yval exch def" do "} for"
    }

    def zloop
	named from { 0 }
	named to { 0 }
	named by { 1 }
	named do named z { "zval" } {}
    {
	from by to "{ /zval exch def" do "} for"
    }

}