| 1 |
% special.lpro - public domain. |
| 2 |
% header for the \special command |
| 3 |
% The structure of the PostScript produced by dvips for \special is: |
| 4 |
% @beginspecial |
| 5 |
% - any number of @hsize, @hoffset, @hscale, etc., commands |
| 6 |
% @setspecial |
| 7 |
% - the user's file of PostScript commands |
| 8 |
% @endspecial |
| 9 |
|
| 10 |
TeXDict begin |
| 11 |
/SDict 200 dict N |
| 12 |
SDict begin |
| 13 |
|
| 14 |
/@SpecialDefaults |
| 15 |
{ /hs 612 N |
| 16 |
/vs 792 N |
| 17 |
/ho 0 N |
| 18 |
/vo 0 N |
| 19 |
/hsc 1 N |
| 20 |
/vsc 1 N |
| 21 |
/ang 0 N |
| 22 |
/CLIP 0 N |
| 23 |
/rwiSeen false N |
| 24 |
/rhiSeen false N |
| 25 |
/letter {} N /note {} N /a4 {} N /legal {} N |
| 26 |
} B |
| 27 |
|
| 28 |
% |
| 29 |
% The following definition sets up the units that hscale/vscale are in. |
| 30 |
% For certain sites this might require change, but it is |
| 31 |
% recommended instead that any macro packages that require |
| 32 |
% hscale/vscale set the units appropriately via |
| 33 |
% |
| 34 |
% \special{! /@scaleunit 1 def } |
| 35 |
% |
| 36 |
% if global, or |
| 37 |
% |
| 38 |
% \special{" /@scaleunit 1 def } |
| 39 |
% |
| 40 |
% before each instance if multiple macro packages with |
| 41 |
% different requirements are being used. |
| 42 |
% |
| 43 |
/@scaleunit 100 N |
| 44 |
% s @hscale - set scale factor |
| 45 |
/@hscale {@scaleunit div /hsc X} B |
| 46 |
/@vscale {@scaleunit div /vsc X} B |
| 47 |
|
| 48 |
% d @hsize - specify a horizontal clipping dimension |
| 49 |
/@hsize {/hs X /CLIP 1 N} B |
| 50 |
/@vsize {/vs X /CLIP 1 N} B |
| 51 |
|
| 52 |
/@clip {/CLIP 2 N} B |
| 53 |
|
| 54 |
% d @hoffset - specify a shift for the figure |
| 55 |
/@hoffset {/ho X} B |
| 56 |
/@voffset {/vo X} B |
| 57 |
|
| 58 |
% a @angle - set rotation angle |
| 59 |
/@angle {/ang X} B |
| 60 |
|
| 61 |
% |
| 62 |
% Here we handle bounding box calculations, if necessary. |
| 63 |
% |
| 64 |
/@rwi { 10 div /rwi X /rwiSeen true N } B % rwi will be real width after scaling |
| 65 |
/@rhi { 10 div /rhi X /rhiSeen true N } B % rhi will be real height after scaling |
| 66 |
/@llx { /llx X } B |
| 67 |
/@lly { /lly X } B |
| 68 |
/@urx { /urx X } B |
| 69 |
/@ury { /ury X } B |
| 70 |
|
| 71 |
/magscale true def |
| 72 |
|
| 73 |
end % of SDict |
| 74 |
|
| 75 |
/@MacSetUp |
| 76 |
{ userdict /md known % if md is defined |
| 77 |
{ userdict /md get type /dicttype eq % and if it is a dictionary |
| 78 |
{ |
| 79 |
userdict begin % expand it if necessary |
| 80 |
md length 10 add md maxlength ge |
| 81 |
{/md md dup length 20 add dict copy def}if |
| 82 |
end |
| 83 |
md begin % then redefine some stuff |
| 84 |
/letter {} N |
| 85 |
/note {} N |
| 86 |
/legal {} N |
| 87 |
/od{txpose |
| 88 |
1 0 mtx defaultmatrix dtransform S atan/pa X |
| 89 |
newpath clippath mark |
| 90 |
{transform{itransform moveto}} |
| 91 |
{transform{itransform lineto}} |
| 92 |
{ 6 -2 roll transform |
| 93 |
6 -2 roll transform |
| 94 |
6 -2 roll transform |
| 95 |
{ itransform 6 2 roll |
| 96 |
itransform 6 2 roll |
| 97 |
itransform 6 2 roll |
| 98 |
curveto |
| 99 |
} |
| 100 |
} |
| 101 |
{{closepath}} |
| 102 |
pathforall newpath counttomark array astore /gc xdf |
| 103 |
pop ct 39 0 put |
| 104 |
10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if |
| 105 |
}N |
| 106 |
/txpose{ |
| 107 |
pxs pys scale ppr aload pop |
| 108 |
por { |
| 109 |
noflips { |
| 110 |
pop S neg S TR pop 1 -1 scale |
| 111 |
}if |
| 112 |
xflip yflip and { |
| 113 |
pop S neg S TR 180 rotate 1 -1 scale |
| 114 |
ppr 3 get ppr 1 get neg sub neg ppr 2 get |
| 115 |
ppr 0 get neg sub neg TR |
| 116 |
}if |
| 117 |
xflip yflip not and { |
| 118 |
pop S neg S TR pop 180 rotate |
| 119 |
ppr 3 get ppr 1 get neg sub neg 0 TR |
| 120 |
}if |
| 121 |
yflip xflip not and { |
| 122 |
ppr 1 get neg ppr 0 get neg TR |
| 123 |
}if |
| 124 |
} |
| 125 |
{ |
| 126 |
noflips { |
| 127 |
TR pop pop 270 rotate 1 -1 scale |
| 128 |
}if |
| 129 |
xflip yflip and { |
| 130 |
TR pop pop 90 rotate 1 -1 scale |
| 131 |
ppr 3 get ppr 1 get neg sub neg ppr 2 get |
| 132 |
ppr 0 get neg sub neg TR |
| 133 |
}if |
| 134 |
xflip yflip not and { |
| 135 |
TR pop pop 90 rotate ppr 3 get |
| 136 |
ppr 1 get neg sub neg 0 TR |
| 137 |
}if |
| 138 |
yflip xflip not and { |
| 139 |
TR pop pop 270 rotate ppr 2 get |
| 140 |
ppr 0 get neg sub neg 0 S TR |
| 141 |
}if |
| 142 |
}ifelse |
| 143 |
scaleby96 { |
| 144 |
ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy |
| 145 |
TR .96 dup scale neg S neg S TR |
| 146 |
}if |
| 147 |
}N |
| 148 |
/cp {pop pop showpage pm restore}N |
| 149 |
end |
| 150 |
}if |
| 151 |
} if |
| 152 |
} N |
| 153 |
|
| 154 |
% |
| 155 |
% The following procedure brings us back to PostScript size. It takes |
| 156 |
% into account the current global dvi magnification, so graphics |
| 157 |
% scale with the document. |
| 158 |
% |
| 159 |
/normalscale { |
| 160 |
Resolution 72 div VResolution 72 div neg scale |
| 161 |
magscale { DVImag dup scale } if |
| 162 |
0 setgray |
| 163 |
} N |
| 164 |
% |
| 165 |
% this will be invoked as the result of a \special command (for the |
| 166 |
% inclusion of PostScript graphics). The basic idea is to change all |
| 167 |
% scaling and graphics back to defaults, but to shift the origin |
| 168 |
% to the current position on the page. |
| 169 |
|
| 170 |
/@beginspecial % - @beginspecial - -- enter special mode |
| 171 |
{ SDict begin |
| 172 |
/SpecialSave save N |
| 173 |
gsave |
| 174 |
normalscale |
| 175 |
currentpoint TR %set the current point as the user's origin |
| 176 |
@SpecialDefaults % setup default offsets, scales, sizes, and angle |
| 177 |
count /ocount X /dcount countdictstack N |
| 178 |
} N |
| 179 |
|
| 180 |
/@setspecial % to setup user specified offsets, scales, sizes (for clipping) |
| 181 |
{ |
| 182 |
CLIP 1 eq |
| 183 |
{ newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto |
| 184 |
closepath clip } |
| 185 |
if |
| 186 |
ho vo TR |
| 187 |
hsc vsc scale |
| 188 |
ang rotate |
| 189 |
rwiSeen { |
| 190 |
rwi urx llx sub div |
| 191 |
rhiSeen { rhi ury lly sub div } { dup } ifelse |
| 192 |
scale llx neg lly neg TR |
| 193 |
} { |
| 194 |
rhiSeen { rhi ury lly sub div dup scale llx neg lly neg TR } if |
| 195 |
} ifelse |
| 196 |
CLIP 2 eq |
| 197 |
{ newpath llx lly moveto urx lly lineto urx ury lineto llx ury lineto |
| 198 |
closepath clip } |
| 199 |
if |
| 200 |
/showpage {} N |
| 201 |
/erasepage {} N |
| 202 |
/setpagedevice { pop } N |
| 203 |
/copypage {} N |
| 204 |
newpath |
| 205 |
} N |
| 206 |
|
| 207 |
/@endspecial % - @endspecial - -- leave special mode |
| 208 |
{ count ocount sub {pop} repeat |
| 209 |
countdictstack dcount sub {end} repeat |
| 210 |
grestore SpecialSave restore |
| 211 |
end |
| 212 |
} N |
| 213 |
/@defspecial |
| 214 |
{ |
| 215 |
SDict begin |
| 216 |
} N |
| 217 |
/@fedspecial |
| 218 |
{ |
| 219 |
end |
| 220 |
} B |
| 221 |
|
| 222 |
%%% macros for tpic |
| 223 |
/li % x y li - -- draw line to |
| 224 |
{ lineto |
| 225 |
} B |
| 226 |
|
| 227 |
/rl % dx dy rl - -- draw relative line |
| 228 |
{ rlineto |
| 229 |
} B |
| 230 |
|
| 231 |
/rc % x0 y0 x1 y1 y2 y2 rc -- draw bezier curve |
| 232 |
{ rcurveto |
| 233 |
} B |
| 234 |
|
| 235 |
/np % np - -- start a new path and save currentpoint |
| 236 |
{ /SaveX currentpoint /SaveY X N % remember current point |
| 237 |
1 setlinecap |
| 238 |
newpath |
| 239 |
} N |
| 240 |
|
| 241 |
/st % st - -- draw the last path and restore currentpoint |
| 242 |
{ stroke |
| 243 |
SaveX SaveY moveto % restore the current point |
| 244 |
} N |
| 245 |
|
| 246 |
/fil % fil -- fill the last path and restore currentpoint |
| 247 |
{ fill |
| 248 |
SaveX SaveY moveto % restore the current point |
| 249 |
} N |
| 250 |
|
| 251 |
/ellipse % xc yc xrad yrad startAngle endAngle ellipse |
| 252 |
{ |
| 253 |
/endangle X |
| 254 |
/startangle X |
| 255 |
/yrad X |
| 256 |
/xrad X |
| 257 |
|
| 258 |
/savematrix matrix currentmatrix N |
| 259 |
|
| 260 |
TR xrad yrad scale |
| 261 |
0 0 1 startangle endangle arc |
| 262 |
savematrix setmatrix |
| 263 |
} N |
| 264 |
%%% end of macros for tpic |
| 265 |
end % revert to previous dictionary |