-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgraph.psh
177 lines (174 loc) · 4.56 KB
/
graph.psh
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
/*
(c) 1993 Roger Binns
These tools were produced by Roger Binns for a fourth year project as part of
a computer science degree, for the Computer Science department, Brunel
University, Uxbridge, Middlesex UB8 3PH, United Kingdom.
This software is provided in good faith, having been developed by Brunel
University students as part of their normal course work. It should not be
assumed that Brunel has any rights of ownership, and the University cannot
accept any liability for its subsequent use. It is a condition of any such
use that the user idemnifies the University against any claim (including
third party claims) arising therefrom.
*/
"/node {" "\n"
"dup" "\n"
"xconst mul" "\n"
"/x exch def " "\n"
"numnodes 1 add exch sub" "\n"
"yconst mul" "\n"
"/y exch def" "\n"
"" "\n"
"% centre string" "\n"
"dup stringwidth pop" "\n"
"2 div " "\n"
"x exch sub /xx exch def" "\n"
"fontsize" "\n"
"3 div % why 3 I wonder?" "\n"
"y exch sub /yy exch def " "\n"
"xx yy moveto" "\n"
"show" "\n"
"" "\n"
"%draw circle" "\n"
"newpath % remove line to start of circle" "\n"
"currentlinewidth" "\n"
"bubble setlinewidth" "\n"
"x y radius 0 360 arc stroke" "\n"
"setlinewidth" "\n"
"} def" "\n"
"" "\n"
"/factor 2 sqrt def" "\n"
"" "\n"
"/top { % nodeno -top- xcoord ycoord" "\n"
"dup" "\n"
"xconst mul /x exch def" "\n"
"numnodes 1 add exch sub" "\n"
"yconst mul /y exch def" "\n"
"x radius factor div add y radius factor div add" "\n"
"} def" "\n"
"" "\n"
"/bottom { % nodeno -bottom- xcoord ycoord" "\n"
"dup" "\n"
"xconst mul /x exch def" "\n"
"numnodes 1 add exch sub" "\n"
"yconst mul /y exch def" "\n"
"x radius factor div sub y radius factor div sub" "\n"
"} def " "\n"
"" "\n"
"/toploop { % nodeno -toploop- xcoord ycoord" "\n"
"dup" "\n"
"xconst mul /x exch def" "\n"
"numnodes 1 add exch sub" "\n"
"yconst mul /y exch def" "\n"
"x y radius add" "\n"
"} def" "\n"
"" "\n"
"/rightloop { % nodeno -rightloop- xcoord ycoord" "\n"
"dup" "\n"
"xconst mul /x exch def" "\n"
"numnodes 1 add exch sub" "\n"
"yconst mul /y exch def" "\n"
"x radius add y" "\n"
"} def" "\n"
"" "\n"
"/arcback {" "\n"
"/second exch def" "\n"
"/first exch def" "\n"
"currentlinewidth" "\n"
"newpath" "\n"
"linewid setlinewidth" "\n"
"first bottom moveto" "\n"
"" "\n"
"first bottom pop /xxx exch def" "\n"
"second bottom exch pop /yyy exch def" "\n"
"" "\n"
"xxx " "\n"
"yyy dup first bottom exch pop sub abs fudge mul add" "\n"
"xxx dup second bottom pop sub abs fudge mul add" "\n"
"yyy" "\n"
"" "\n"
"second bottom" "\n"
"curveto" "\n"
"stroke" "\n"
"" "\n"
"% arrow head" "\n"
"first bottom moveto" "\n"
"first bottom pop 0.25 radius mul arrow mul add" "\n"
"first bottom exch pop radius arrow mul sub" "\n"
"lineto" "\n"
"" "\n"
"first bottom moveto" "\n"
"first bottom pop 0.25 radius mul arrow mul sub" "\n"
"first bottom exch pop radius arrow mul sub" "\n"
"lineto" "\n"
"" "\n"
"stroke" "\n"
"" "\n"
"setlinewidth" "\n"
"} def" "\n"
"" "\n"
"/arcloop {" "\n"
"/n exch def" "\n"
"currentlinewidth" "\n"
"newpath" "\n"
"linewid setlinewidth" "\n"
"n toploop /ytop exch def /xtop exch def" "\n"
"n rightloop /yright exch def /xright exch def" "\n"
"" "\n"
"xright yright moveto" "\n"
"xright radius loopfactor mul add yright radius loopfactor mul 6 div add" "\n"
"xtop ytop radius loopfactor mul add" "\n"
"xtop ytop" "\n"
"curveto" "\n"
"stroke" "\n"
"" "\n"
"% arrow head" "\n"
"xtop ytop moveto" "\n"
"xtop 0.25 radius mul arrow mul add" "\n"
"ytop radius arrow mul add" "\n"
"lineto" "\n"
"" "\n"
"xtop ytop moveto" "\n"
"xtop 0.25 radius mul arrow mul sub" "\n"
"ytop radius arrow mul add" "\n"
"lineto" "\n"
"" "\n"
"stroke" "\n"
"setlinewidth" "\n"
"} def " "\n"
"" "\n"
"/arcfore {" "\n"
"/second exch def" "\n"
"/first exch def" "\n"
"currentlinewidth" "\n"
"newpath" "\n"
"linewid setlinewidth" "\n"
"first top moveto" "\n"
"" "\n"
"second top pop /xxx exch def" "\n"
"first top exch pop /yyy exch def" "\n"
"" "\n"
"xxx dup first bottom pop sub abs fudge mul sub" "\n"
"yyy" "\n"
"xxx " "\n"
"yyy dup second bottom exch pop sub abs fudge mul sub" "\n"
"" "\n"
"" "\n"
"second top" "\n"
"curveto" "\n"
"stroke" "\n"
"" "\n"
"% arrow head" "\n"
"second top moveto" "\n"
"second top pop radius arrow 0.25 mul mul sub" "\n"
"second top exch pop radius arrow mul add" "\n"
"lineto" "\n"
"" "\n"
"second top moveto" "\n"
"second top pop radius arrow 0.25 mul mul add" "\n"
"second top exch pop radius arrow mul add" "\n"
"lineto" "\n"
"" "\n"
"stroke" "\n"
"" "\n"
"setlinewidth" "\n"
"} def" "\n"