-
Notifications
You must be signed in to change notification settings - Fork 346
/
PSL_prologue.ps
145 lines (145 loc) · 5.7 KB
/
PSL_prologue.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
%-----------------------------------------------------------------------------
%- PS dictionary written to header to all GMT PostScript plots
%+ NOTE: No longer used directly as we build a static string in PSL_strings.h.
%+ However, this file is the original source as it may be simpler to see and
%+ edit the logic in this file than in the formatted static string.
%+ Also, if PSL_transp is changed it may require edits to psconvert.c
%-----------------------------------------------------------------------------
% Begin pslib header
250 dict begin
/! {bind def} bind def
/# {load def}!
/A /setgray #
/B /setdash #
/C /setrgbcolor #
/D /rlineto #
/E {dup stringwidth pop}!
/F /fill #
/G /rmoveto #
/H /sethsbcolor #
/I /setpattern #
/K /setcmykcolor #
/L /lineto #
/M /moveto #
/N /newpath #
/P /closepath #
/R /rotate #
/S /stroke #
/T /translate #
/U /grestore #
/V /gsave #
/W /setlinewidth #
/Y {findfont exch scalefont setfont}!
/Z /show #
/FP {true charpath flattenpath}!
/MU {matrix setmatrix}!
/MS {/SMat matrix currentmatrix def}!
/MR {SMat setmatrix}!
/edef {exch def}!
% Path fill
/FS {/fc edef /fs {V fc F U} def}!
/FQ {/fs {} def}!
% Outline off or on
/O0 {/os {N} def}!
/O1 {/os {P S} def}!
% Set both fill and outline
/FO {fs os}!
% Star: radius xc yc
/Sa {M MS dup 0 exch G 0.726542528 mul -72 R dup 0 D 4 {72 R dup 0 D -144 R dup 0 D} repeat pop MR FO}!
% Box: height width xll yll
/Sb {M dup 0 D exch 0 exch D neg 0 D FO}!
% Rounded box: height width radius xll yll
/SB {MS T /BoxR edef /BoxW edef /BoxH edef BoxR 0 M
BoxW 0 BoxW BoxH BoxR arct BoxW BoxH 0 BoxH BoxR arct 0 BoxH 0 0 BoxR arct 0 0 BoxW 0 BoxR arct MR FO}!
% Circle: radius xc yc
/Sc {N 3 -1 roll 0 360 arc FO}!
% Diamond: radius xc yc
/Sd {M 4 {dup} repeat 0 G neg dup dup D exch D D FO}!
% Ellipse: major minor angle xc yc
/Se {N MS T R scale 0 0 1 0 360 arc MR FO}!
% Octagon: radius xc yc
/Sg {M MS 22.5 R dup 0 exch G -22.5 R 0.765366865 mul dup 0 D 6 {-45 R dup 0 D} repeat pop MR FO}!
% Hexagon: radius xc yc
/Sh {M MS dup 0 G -120 R dup 0 D 4 {-60 R dup 0 D} repeat pop MR FO}!
% Inverted triangle: radius xc yc
/Si {M MS dup neg 0 exch G 60 R 1.732050808 mul dup 0 D 120 R 0 D MR FO}!
% Rotated rectangle: height width angle xc yc
/Sj {M MS R dup -2 div 2 index -2 div G dup 0 D exch 0 exch D neg 0 D MR FO}!
% Pentagon: radius xc yc
/Sn {M MS dup 0 exch G -36 R 1.175570505 mul dup 0 D 3 {-72 R dup 0 D} repeat pop MR FO}!
% Dot: radius xc yc [hardwired as circle with no outline]
/Sp {N 3 -1 roll 0 360 arc fs N}!
% Patch fill: x1 y1 ... xn yn n
/SP {M {D} repeat FO}!
% Rectangle: height width xc yc
/Sr {M dup -2 div 2 index -2 div G dup 0 D exch 0 exch D neg 0 D FO}!
% Rounded rectangle: height width radius xc yc
/SR {MS T /BoxR edef /BoxW edef /BoxH edef BoxR BoxW -2 div BoxH -2 div T BoxR 0 M
BoxW 0 BoxW BoxH BoxR arct BoxW BoxH 0 BoxH BoxR arct 0 BoxH 0 0 BoxR arct 0 0 BoxW 0 BoxR arct MR FO}!
% Square: radius xc yc
/Ss {M 1.414213562 mul dup dup dup -2 div dup G 0 D 0 exch D neg 0 D FO}!
% Triangle: radius xc yc
/St {M MS dup 0 exch G -60 R 1.732050808 mul dup 0 D -120 R 0 D MR FO}!
% Single-headed vector
/SV {0 exch M 0 D D D D D 0 D FO}!
% Double-headed vector
/Sv {0 0 M D D 0 D D D D D 0 D D FO}!
% Pie Wedge: radius angle1 angle2 xc yc
/Sw {2 copy M 5 2 roll arc FO}!
% Cross: radius xc yc
/Sx {M 1.414213562 mul 5 {dup} repeat -2 div dup G D neg 0 G neg D S}!
% Y-dash: radius xc yc
/Sy {M dup 0 exch G dup -2 mul dup 0 exch D S}!
% Plus: radius xc yc
/S+ {M dup 0 G dup -2 mul dup 0 D exch dup G 0 exch D S}!
% X-dash: radius xc yc
/S- {M dup 0 G dup -2 mul dup 0 D S}!
% String width, height, depth and total height (height-depth)
/sw {stringwidth pop}!
/sh {V MU 0 0 M FP pathbbox N 4 1 roll pop pop pop U}!
/sd {V MU 0 0 M FP pathbbox N pop pop exch pop U}!
/sH {V MU 0 0 M FP pathbbox N exch pop exch sub exch pop U}!
/sb {E exch sh}!
% To align text {bottom,middle,top}{left,center,right}
/bl {}!
/bc {E -2 div 0 G}!
/br {E neg 0 G}!
/ml {dup 0 exch sh -2 div G}!
/mc {dup E -2 div exch sh -2 div G}!
/mr {dup E neg exch sh -2 div G}!
/tl {dup 0 exch sh neg G}!
/tc {dup E -2 div exch sh neg G}!
/tr {dup E neg exch sh neg G}!
% Maximum of two numbers
/mx {2 copy lt {exch} if pop}!
% Translate and memorize advance
/PSL_xorig 0 def /PSL_yorig 0 def
/TM {2 copy T PSL_yorig add /PSL_yorig edef PSL_xorig add /PSL_xorig edef}!
% To re-encode one font with the provided encoding vector
/PSL_reencode {findfont dup length dict begin
{1 index /FID ne {def}{pop pop} ifelse} forall
exch /Encoding edef currentdict end definefont pop
}!
/PSL_eps_begin { % Marks begin of EPSF inclusion
/PSL_eps_state save def % Save state for cleanup
/PSL_dict_count countdictstack def % Count objects on dict stack
/PSL_op_count count 1 sub def % Count objects on operand stack
userdict begin % Push userdict stack
/showpage {} def % Deactivate showpage command
0 setgray 0 setlinecap 1 setlinewidth % Prepare clean graphics state
0 setlinejoin 10 setmiterlimit [] 0 setdash newpath
/languagelevel where % If level != 1, set strokeadjust and overprint to their defaults
{pop languagelevel 1 ne {false setstrokeadjust false setoverprint} if} if
}!
/PSL_eps_end { % Marks end of EPSF inclusion
count PSL_op_count sub {pop} repeat % Clean up operand stack
countdictstack PSL_dict_count sub {end} repeat % Clean up dict stack
PSL_eps_state restore % Restore saved state
}!
/PSL_transp { % Changes the transparency settings
/PSL_BM_arg edef /PSL_S_arg edef /PSL_F_arg edef
/.setfillconstantalpha where
{ pop PSL_BM_arg .setblendmode PSL_S_arg .setstrokeconstantalpha PSL_F_arg .setfillconstantalpha } % Ghostscript
{ /pdfmark where {pop [ /BM PSL_BM_arg /CA PSL_S_arg /ca PSL_F_arg /SetTransparency pdfmark} if } % Or Adobe
ifelse
}!