|
|
Sample Programs from NeXSTEP 3.3
%!PS-Adobe-2.0 EPSF-2.0
%%Title: arrows.eps
%%Creator: Adobe Systems Incorporated
%%Pages: 0 1
%%BoundingBox: 0 0 300 540
%%EndComments
%%BeginProcSet: arrows 1.0 0
% From: Green Book Listing 3-4, on page 47.
% "arrowhead" takes these arguments:
% lineweight prevX prevY
/arrowhead { %def
gsave
currentpoint
4 2 roll exch 4 -1 roll exch
sub 3 1 roll sub
exch atan rotate dup scale
-1 2 rlineto
7 -2 rlineto
-7 -2 rlineto
closepath fill
grestore
newpath
} bind def
/l^ { %def % lineto-arrow
currentlinewidth currentpoint 5 3 roll
lineto
currentpoint stroke moveto
arrowhead
} bind def
/rl^ { %def % rlineto-arrow
currentlinewidth currentpoint 5 3 roll
rlineto
currentpoint stroke moveto
arrowhead
} bind def
/arc^ { %def % arc-arrow
5 copy arc
currentpoint stroke moveto % stroke arc
% getting the correct orientation for the arrowhead
% is tricky. This procedure uses the arguments to
% "arc" to determine the tangent of the curve at the
% endpoint, and it orients the arrowhead along that
% tangent line. It leaves an X-Y point that is just
% behind the arrowhead along the tangent.
% newX = X + radius * cos(endAngle-1)
% newY = Y + radius * sin(endAngle-1)
exch pop 1 sub % endAngle - 1 degree
dup cos 2 index mul 4 index add % arrowX
exch sin 2 index mul 3 index add % arrowY
currentlinewidth 2 add 3 1 roll % thickness
arrowhead pop pop pop % draw -\>
} bind def
%%EndProcSet: arrows 1.0 0
%%EndProlog
% line sample:
150 420 moveto
0 10 360 {
currentlinewidth .1 add setlinewidth
gsave
dup cos 100 mul
exch sin 100 mul
rl^
grestore
} bind for
newpath
% curve sample:
/radius 10 def .1 setlinewidth
0 30 360 {
/radius radius 10 add def
150 150 radius 0 5 -1 roll arc^
} bind for
showpage
%%Trailer
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.