-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patharrows.ps
123 lines (114 loc) · 3.11 KB
/
arrows.ps
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
% these procedures have been posted in comp.lang.postscript
% by Bill Lee, [email protected], on Apr 19 1995
% subject: arc with arrow head
% changes by Cristian Barbarosie in 2018 [email protected]
%* _____________________________ Arrows ____________________________________
%* Procedure to draw the path for an arrow head. Note: the arrowhead will be
%* added to the current path. The arrowhead will also be drawn and filled.
%*
%* Usage: Linewidth deltaX deltaY rArrowHead
%*
%* where: LineWidth is the width in points of the arrow head lines
%*
%* deltaX and deltaY define the direction that the arrow points
%*
%* Note: If Linewidth is zero, a value of 1 will be substituted
%*
/rArrowHead {
exch atan matrix currentmatrix exch rotate exch
dup 0 eq
{ pop 1 } if
dup scale
-7 2 rlineto
1 -2 rlineto
-1 -2 rlineto
7 2 rlineto
currentpoint
gsave
newpath moveto
-7 2 rlineto
1 -2 rlineto
-1 -2 rlineto
closepath
fill
grestore
setmatrix
} def
%* Procedure to draw the path for an arrow head. Note: the arrowhead will be
%* added to the current path. The arrowhead will also be drawn and filled.
%*
%* Usage: Linewidth PreviousX PreviousY ArrowHead
%*
%* where: LineWidth is the width in points of the arrow head lines
%*
%* PreviousX and PreviousY along with the currentpoint
%* define the direction that the arrow points
%*
%* Note: If Linewidth is zero, a value of 1 will be substituted
%*
/ArrowHead {
currentpoint
4 2 roll exch 4 -1 roll exch
sub 3 1 roll sub
rArrowHead
} def
%* _____________________________ RLineto^ ____________________________________
%* Procedure to add a relative line to the current path and then add the
%* path for an arrow on its end.
%*
%* Usage: x y RLineto^
%*
%* where: x and y are the offsets from the current point
%*
/RLineto^ {
currentlinewidth currentpoint 5 3 roll
rlineto
ArrowHead
} def
%* _____________________________ Lineto^ ____________________________________
%* Procedure to add a line to the current path and then add the
%* path for an arrow on its end.
%*
%* Usage: x y Lineto^
%*
%* where: x and y are the new points for the path
%*
/Lineto^ {
currentlinewidth currentpoint 5 3 roll
lineto
ArrowHead
} def
%* _____________________________ Arc^ ____________________________________
%* Procedure to add an arc to the current path and then add the
%* path for arrow on its end.
%*
%* Usage: x y r ang1 ang2 Arc^
%*
%* where: x, y, ang1, ang2, and r are the normal parameters
%* for drawing an arc.
%*
/Arc^ {
5 copy arc
exch pop 2 sub
dup cos 2 index mul 4 index add
exch sin 2 index mul 3 index add
currentlinewidth 3 1 roll
ArrowHead pop pop pop
} def
%* _____________________________ Arcn^ ____________________________________
%* Procedure to add an arc to the current path and then add the
%* path for arrow on its end.
%*
%* Usage: x y r ang1 ang2 Arcn^
%*
%* where: x, y, ang1, ang2, and r are the normal parameters
%* for drawing an arcn.
%*
/Arcn^ {
5 copy arcn
exch pop 2 add
dup cos 2 index mul 4 index add
exch sin 2 index mul 3 index add
currentlinewidth 3 1 roll
ArrowHead pop pop pop
} def