| 1 |
% |
| 2 |
% \iffalse |
| 3 |
%% |
| 4 |
%% Source File `pspicture.dtx'. |
| 5 |
%% Copyright (C) 1992 1999 David Carlisle |
| 6 |
%% This file may be distributed under the terms of the LPPL. |
| 7 |
%% See 00readme.txt for details. |
| 8 |
%% |
| 9 |
% |
| 10 |
%<*dtx> |
| 11 |
\ProvidesFile{pspicture.dtx} |
| 12 |
%</dtx> |
| 13 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 14 |
%<package>\ProvidesPackage{pspicture} |
| 15 |
%<driver>\ProvidesFile{pspicture.drv} |
| 16 |
%<*package,driver> |
| 17 |
% \fi |
| 18 |
% \ProvidesFile{pspicture.dtx} |
| 19 |
[1999/04/11/ v2.02 Picture mode via PS specials (DPC)] |
| 20 |
% |
| 21 |
% \iffalse |
| 22 |
%</package,driver> |
| 23 |
%<*driver> |
| 24 |
\documentclass{ltxdoc} |
| 25 |
\begin{document} |
| 26 |
\DocInput{pspicture.dtx} |
| 27 |
\end{document} |
| 28 |
%</driver> |
| 29 |
% \fi |
| 30 |
% |
| 31 |
% \GetFileInfo{pspicture.dtx} |
| 32 |
% \CheckSum{110} |
| 33 |
% |
| 34 |
% \changes{1} {1989/05/10}{(Not made widely available)} |
| 35 |
% \changes{2} {1992/01/02}{support for dvips added} |
| 36 |
% \changes{2.01}{1992/06/16}{First public release} |
| 37 |
% \changes{2.02}{1999/04/11}{Fix for `new' docstrip, and LPPL} |
| 38 |
% |
| 39 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 40 |
% |
| 41 |
% \title{The \textsf{pspicture} package\thanks{This file |
| 42 |
% has version number \fileversion, last |
| 43 |
% revised \filedate.}} |
| 44 |
% |
| 45 |
% \author{D. P. Carlisle} |
| 46 |
% \date{16 June 1992} |
| 47 |
% \maketitle |
| 48 |
% |
| 49 |
% |
| 50 |
% \section{Introduction} |
| 51 |
% {\tt pspicture} is a re-implementation, and extension of, \LaTeX's |
| 52 |
% {\tt picture} environment, using PostScript |\special|'s. This has |
| 53 |
% several advantages, mainly that lines of arbitrary slope and thickness |
| 54 |
% may be specified, and there is no limit on the size of the circles |
| 55 |
% that may be drawn\footnote{^^A |
| 56 |
% There is a certain amount of overlap between this style option and the |
| 57 |
% widely available {\tt eepic} option. However when I wrote the first |
| 58 |
% version of this, in 1989, I was not aware of {\tt eepic}, and {\tt |
| 59 |
% pspicture} has been reasonably popular in Manchester, even |
| 60 |
% though {\tt epic} and {\tt eepic} have been installed.}. |
| 61 |
% |
| 62 |
% One disadvantage is that the picture can no longer be previewed on a |
| 63 |
% |dvi| previewer, such as |xdvi|. To help with this problem, a |
| 64 |
% companion style option, {\tt texpicture}, may be used while developing |
| 65 |
% a document, this uses the standard picture commands as much as |
| 66 |
% possible, and silently omits any picture objects that can not be drawn |
| 67 |
% with standard \LaTeX. |
| 68 |
% |
| 69 |
% A second disadvantage, is that a {\tt dvi} file produced with {\tt |
| 70 |
% pspicture} will contain embedded |\special| commands. These commands |
| 71 |
% will only work with the driver program for which they were intended. |
| 72 |
% This makes the {\tt dvi} file less portable. {\tt pspicture} will by |
| 73 |
% default use |\special|'s set up for Rokicki's {\tt dvips} program, |
| 74 |
% although it should be easy to modify the code to work with other |
| 75 |
% PostScript drivers. A {\sc DocStrip} option for a version of {\tt |
| 76 |
% dvi2ps} is included with this distribution. |
| 77 |
% |
| 78 |
% \subsection{Commands Available}{\parskip=\baselineskip\parindent=0pt |
| 79 |
% \DescribeMacro{\circle}\DescribeMacro{\circle*} |
| 80 |
% Use as described in the \LaTeX\ book but with no maximum diameter. |
| 81 |
% The thickness of the circle is altered by the |\linethickness| |
| 82 |
% command. The size of the circle produced by |\circle*| is not |
| 83 |
% affected by |\linethickness|, so it is not the same as `filling in' |
| 84 |
% the circle drawn by |\circle|. |
| 85 |
% |
| 86 |
% \DescribeMacro{\oval} |
| 87 |
% Use as described in the \LaTeX\ book, but as there is no maximum |
| 88 |
% diameter for the circular arcs, the oval (in the absence of the |
| 89 |
% optional |[tr]| etc) always consists of two semi-circular arcs |
| 90 |
% joined by a pair of parallel lines. To obtain a `rectangle with |
| 91 |
% rounded corners' the oval command has a second optional argument |
| 92 |
% (given first !).\\ |
| 93 |
% |\oval[20](100,200)[t]|\\ |
| 94 |
% Produces the top half of an oval with quarter circles of radius |
| 95 |
% 20*unitlength. |
| 96 |
% If unitlength = 1pt then this is equivalent to the standard oval |
| 97 |
% command. In general |\oval[R](x,y)| uses circular arcs of radius |
| 98 |
% $\min(R,x/2,y/2)$. |
| 99 |
% |
| 100 |
% \DescribeMacro{\line}\DescribeMacro{\vector} |
| 101 |
% Use as described in the \LaTeX\ book but with no restriction on the |
| 102 |
% available slopes. The thickness of a sloping line is altered by the |
| 103 |
% |\linethickness| command. |
| 104 |
% |
| 105 |
% \DescribeMacro{\Line}\DescribeMacro{\Vector} |
| 106 |
% New forms of the line and vector commands.\\ |
| 107 |
% |\put(x1,y1){\Line(x2,y2)}|\\ |
| 108 |
% produces a line from (x1,y1) to (x1+x2,y1+y2) and similarly for |
| 109 |
% |\Vector|. |
| 110 |
% |
| 111 |
% \DescribeMacro{\Curve} |
| 112 |
% Like |\Line| except that it produce a curve!\\ |
| 113 |
% |\put(x1,y1){\Curve(x2,y2){m}}|\\ |
| 114 |
% produces a curve from (x1,y1) to (x1+x2,y1+y2). the amount of |
| 115 |
% curvature is controlled by m but try $1$ or $-1$ first. m does not |
| 116 |
% have to be an integer. Negative numbers curve the opposite way to |
| 117 |
% positive numbers. |
| 118 |
% |
| 119 |
% \DescribeMacro{\thinlines}\DescribeMacro{\thicklines}% |
| 120 |
% \DescribeMacro{\linethickness} |
| 121 |
% These commands alter the thickness of {\bf all} lines including |
| 122 |
% slanted lines and circular arcs.\vspace{\baselineskip} |
| 123 |
% |
| 124 |
% \DescribeMacro{\arrowlength} |
| 125 |
% A new command which specifies the size of the arrowhead drawn by the |
| 126 |
% |\vector| and |\Vector| commands. Like |\linethickness| it does not |
| 127 |
% get multiplied by |\unitlength|. At present the arrowhead is |
| 128 |
% triangular. If a head with curved sides more like the standard |
| 129 |
% \LaTeX\ head is required the definition of |!A| in pspicture.ps |
| 130 |
% should be altered. |
| 131 |
% |
| 132 |
% Other {\tt picture} mode commands are not altered by this style, and |
| 133 |
% so may be used, just as described in the \LaTeX\ book. These include: |
| 134 |
% |\put|, |\multiput|, |\makebox|, |\framebox|, |dashbox| and |
| 135 |
% |\shortstack|. |
| 136 |
% |
| 137 |
% }\newpage\section{Examples} |
| 138 |
% |
| 139 |
% \noindent A picture built with \LaTeX's line and circle fonts. |
| 140 |
% |
| 141 |
% \noindent\begin{picture}(300,130) |
| 142 |
% \put(0,0){\line(1,2){50}} |
| 143 |
% \put(50,50){\vector(1,1){30}} |
| 144 |
% \put(50,50){\circle{30}} |
| 145 |
% \put(100,50){\circle*{10}} |
| 146 |
% \put(150,50){\oval(50,20)[t]} |
| 147 |
% \put(150,100){\oval(30,30)[bl]} |
| 148 |
% |
| 149 |
% ^^A LaTeX does not do these so well |
| 150 |
% \put(250,60){\circle{60}} |
| 151 |
% \put(250,60){\circle{50}} |
| 152 |
% |
| 153 |
% \end{picture} |
| 154 |
% |
| 155 |
% \bigskip |
| 156 |
% \def\eatmodule#1>{} |
| 157 |
|
| 158 |
%\eatmodule |
| 159 |
%<*x> |
| 160 |
\ifcat a\noexpand @\else |
| 161 |
\MakePercentComment |
| 162 |
\def\ProvidesPackage#1[#2]{} |
| 163 |
\def\NeedsTeXFormat#1{} |
| 164 |
\makeatletter ^^A This is NOT the usual way to access this |
| 165 |
\input{pspicture.sty} ^^A style. It is intended as a style option: |
| 166 |
\makeatother ^^A \documentstyle[a4,pspicture]{article} |
| 167 |
\MakePercentIgnore |
| 168 |
\fi |
| 169 |
%\eatmodule |
| 170 |
%</x> |
| 171 |
% |
| 172 |
% \noindent The same picture built with PostScript |\special|'s. |
| 173 |
% |
| 174 |
% \noindent\begin{picture}(300,130) |
| 175 |
% \put(0,0){\line(1,2){50}} |
| 176 |
% \put(50,50){\vector(1,1){30}} |
| 177 |
% \put(50,50){\circle{30}} |
| 178 |
% \put(100,50){\circle*{10}} |
| 179 |
% \put(150,50){\oval(50,20)[t]} |
| 180 |
% \put(150,100){\oval(30,30)[bl]} |
| 181 |
% |
| 182 |
% ^^A LaTeX does not do these so well |
| 183 |
% \put(250,60){\circle{60}} |
| 184 |
% \put(250,60){\circle{50}} |
| 185 |
% |
| 186 |
% \end{picture} |
| 187 |
% |
| 188 |
% \bigskip |
| 189 |
% \noindent Some extra features not available using the standard picture |
| 190 |
% mode. |
| 191 |
% |
| 192 |
% \noindent\begin{picture}(300,150) |
| 193 |
% \put(250,60){\vector(-8,1){50}} ^^A Vector of any slope. |
| 194 |
% \put(200,0){\Line(100,100)} ^^A Line command. |
| 195 |
% \put(210,100){\Vector(90,10)} ^^A Vector command. |
| 196 |
% \put(70,90){\oval(100,70)} ^^A Control over the radius of |
| 197 |
% \put(70,90){\oval[10](100,70)} ^^A `corners' of an oval. |
| 198 |
% \linethickness{3pt} |
| 199 |
% \put(20,20){\circle{20}} ^^A Circles of any thickness and size. |
| 200 |
% \put(20,20){\line(10,1){30}} ^^A Sloping lines of any thickness. |
| 201 |
% |
| 202 |
% \end{picture} |
| 203 |
% |
| 204 |
% \StopEventually{} |
| 205 |
% |
| 206 |
% \section{pspicture.sty} |
| 207 |
% \begin{macrocode} |
| 208 |
%<*package> |
| 209 |
% \end{macrocode} |
| 210 |
% |
| 211 |
% First we set up the code that is specific to the driver program that |
| 212 |
% is being used. If the driver can incorporate a header file, define |
| 213 |
% |\PS@header| appropriately, |\PS@special| should expand to the format |
| 214 |
% for inline PostScript code. The driver should protect this code with a |
| 215 |
% (g)save (g)restore pair. dvips is treated specially so that it will be |
| 216 |
% the default driver if this file is used without being stripped. If you |
| 217 |
% find definitions of these macros which work for the driver you use, |
| 218 |
% email me, and I will include them in the next release. |
| 219 |
% \begin{macro}{\PS@header} |
| 220 |
% Code to include the PostScript header. |
| 221 |
% \begin{macrocode} |
| 222 |
%<*dvips> |
| 223 |
\def\PS@header#1{\special{header=#1}} |
| 224 |
%</dvips> |
| 225 |
%<dvi2ps>\def\PS@header#1{\typeout{Print with the option -i #1}} |
| 226 |
\PS@header{pspicture.ps} |
| 227 |
% \end{macrocode} |
| 228 |
% \end{macro} |
| 229 |
% |
| 230 |
% \begin{macro}{\PS@special} |
| 231 |
% The format of the |\special| command for inline PostScript. |
| 232 |
% \begin{macrocode} |
| 233 |
%<*dvips> |
| 234 |
\def\PS@special#1{\special{"#1}} |
| 235 |
%</dvips> |
| 236 |
%<dvi2ps>\def\PS@special#1{\special{pstext="#1"}} |
| 237 |
% \end{macrocode} |
| 238 |
% \end{macro} |
| 239 |
% |
| 240 |
% \begin{macro}{\strippt} |
| 241 |
% Strip the final `pt' off the string returned by |\the|. |
| 242 |
% \begin{macrocode} |
| 243 |
{\catcode`t=12\catcode`p=12\gdef\noPT#1pt{#1}} |
| 244 |
\def\strippt#1{\expandafter\noPT\the#1\space} |
| 245 |
% \end{macrocode} |
| 246 |
% \end{macro} |
| 247 |
% |
| 248 |
% \begin{macro}{\@circle} |
| 249 |
% Internal name for |\circle|. |
| 250 |
% \begin{macrocode} |
| 251 |
\def\@circle#1{% |
| 252 |
\@tempdimb #1\unitlength |
| 253 |
\PS@special{% |
| 254 |
\strippt\@wholewidth |
| 255 |
\strippt\@tempdimb |
| 256 |
!C}} |
| 257 |
% \end{macrocode} |
| 258 |
% \end{macro} |
| 259 |
% |
| 260 |
% \begin{macro}{\@dot} |
| 261 |
% Internal name for |\circle*|. |
| 262 |
% \begin{macrocode} |
| 263 |
\def\@dot#1{% |
| 264 |
\@tempdimb #1\unitlength |
| 265 |
\PS@special{% |
| 266 |
\strippt\@tempdimb |
| 267 |
!D}} |
| 268 |
% \end{macrocode} |
| 269 |
% \end{macro} |
| 270 |
% |
| 271 |
% \begin{macro}{\line} |
| 272 |
% Line with a \LaTeX\ style slope specification. |
| 273 |
% \begin{macrocode} |
| 274 |
\def\line(#1,#2)#3{% |
| 275 |
\@linelen=#3\unitlength |
| 276 |
\PS@special{% |
| 277 |
\strippt\@wholewidth |
| 278 |
#1 |
| 279 |
#2 |
| 280 |
\strippt\@linelen |
| 281 |
!L}} |
| 282 |
% \end{macrocode} |
| 283 |
% \end{macro} |
| 284 |
% |
| 285 |
% \begin{macro}{\vector} |
| 286 |
% Line and arrow head with a \LaTeX\ style slope specification. |
| 287 |
% \begin{macrocode} |
| 288 |
\def\vector(#1,#2)#3{% |
| 289 |
\@linelen=#3\unitlength |
| 290 |
\PS@special{% |
| 291 |
\strippt\@arrowlength |
| 292 |
\strippt\@wholewidth |
| 293 |
#1 |
| 294 |
#2 |
| 295 |
\strippt\@linelen |
| 296 |
!V}} |
| 297 |
% \end{macrocode} |
| 298 |
% \end{macro} |
| 299 |
% |
| 300 |
% \begin{macro}{\oval} |
| 301 |
% If no optional argument appears, use a default of maximum radius of |
| 302 |
% \TeX's maximum length. |
| 303 |
% \begin{macrocode} |
| 304 |
\def\oval{% |
| 305 |
\@ifnextchar[% |
| 306 |
{\@ov@l}% |
| 307 |
{\count@=\maxdimen \divide\count@ by \unitlength \@ov@l[\count@]}} |
| 308 |
% \end{macrocode} |
| 309 |
% \end{macro} |
| 310 |
% |
| 311 |
% \begin{macro}{\@ov@l} |
| 312 |
% Look for an optional |tlbr| argument. |
| 313 |
% \begin{macrocode} |
| 314 |
\def\@ov@l[#1](#2,#3){% |
| 315 |
\@ifnextchar[{\@oval[#1](#2,#3)}{\@oval[#1](#2,#3)[]}}% |
| 316 |
% \end{macrocode} |
| 317 |
% \end{macro} |
| 318 |
% |
| 319 |
% \begin{macro}{\@oval} |
| 320 |
% The PostScript version of the |\oval| command will print each quarter |
| 321 |
% of the oval separately, each quarter will only be printed if the |
| 322 |
% appropriate argument is $1$. An optional argument of |t| causes the |
| 323 |
% arguments for the two bottom quarters to be set to $0$, similarly, |r| |
| 324 |
% causes the two left quarters to be set to $0$. Thus an argument [tr] |
| 325 |
% will set the bottom and left quarters to $0$, resulting in only the |
| 326 |
% top right quarter being printed. |
| 327 |
% \begin{macrocode} |
| 328 |
\def\@oval[#1](#2,#3)[#4]{\begingroup |
| 329 |
\@tempdimb #1\unitlength |
| 330 |
\@ovxx #2\unitlength |
| 331 |
\@ovyy #3\unitlength |
| 332 |
\def\r{\def\TL{0 }\def\BL{0 }}% |
| 333 |
\def\l{\def\TR{0 }\def\BR{0 }}% |
| 334 |
\def\t{\def\BL{0 }\def\BR{0 }}% |
| 335 |
\def\b{\def\TL{0 }\def\TR{0 }}% |
| 336 |
\def\TL{1 }\def\BL{1 }\def\TR{1 }\def\BR{1 }% |
| 337 |
\@tfor\@tempa :=#4\do{\csname\@tempa\endcsname}% |
| 338 |
\PS@special{% |
| 339 |
\BR\BL\TR\TL |
| 340 |
\strippt\@wholewidth |
| 341 |
\strippt\@tempdimb |
| 342 |
\strippt\@ovxx |
| 343 |
\strippt\@ovyy |
| 344 |
!O}% |
| 345 |
\endgroup} |
| 346 |
% \end{macrocode} |
| 347 |
% \end{macro} |
| 348 |
% |
| 349 |
% \begin{macro}{\Line} |
| 350 |
% New style |\Line| command. |
| 351 |
% \begin{macrocode} |
| 352 |
\def\Line(#1,#2){% |
| 353 |
\@ovxx #1\unitlength |
| 354 |
\@ovyy #2\unitlength |
| 355 |
\PS@special{% |
| 356 |
\strippt\@wholewidth |
| 357 |
\strippt\@ovxx |
| 358 |
\strippt\@ovyy |
| 359 |
!L2}} |
| 360 |
% \end{macrocode} |
| 361 |
% \end{macro} |
| 362 |
% |
| 363 |
% \begin{macro}{\Curve} |
| 364 |
% Not particularly good, but it will do for now. |
| 365 |
% \begin{macrocode} |
| 366 |
\def\Curve(#1,#2)#3{% |
| 367 |
\@ovxx #1\unitlength |
| 368 |
\@ovyy #2\unitlength |
| 369 |
\PS@special{% |
| 370 |
\strippt\@wholewidth |
| 371 |
\strippt\@ovxx |
| 372 |
\strippt\@ovyy |
| 373 |
#3 |
| 374 |
!C2}} |
| 375 |
% \end{macrocode} |
| 376 |
% \end{macro} |
| 377 |
% |
| 378 |
% \begin{macro}{\Vector} |
| 379 |
% New style |\Vector| command. |
| 380 |
% \begin{macrocode} |
| 381 |
\def\Vector(#1,#2){% |
| 382 |
\@ovxx #1\unitlength |
| 383 |
\@ovyy #2\unitlength |
| 384 |
\PS@special{% |
| 385 |
\strippt\@arrowlength |
| 386 |
\strippt\@wholewidth |
| 387 |
\strippt\@ovxx |
| 388 |
\strippt\@ovyy |
| 389 |
!V2}} |
| 390 |
% \end{macrocode} |
| 391 |
% \end{macro} |
| 392 |
% |
| 393 |
% \begin{macro}{\@arrowlength} |
| 394 |
% Length of an arrow head. |
| 395 |
% \begin{macrocode} |
| 396 |
\newdimen\@arrowlength |
| 397 |
% \end{macrocode} |
| 398 |
% \end{macro} |
| 399 |
% |
| 400 |
% \begin{macro}{\arrowlength} |
| 401 |
% Set the length of an arrow head. |
| 402 |
% \begin{macrocode} |
| 403 |
\def\arrowlength#1{\@arrowlength #1} |
| 404 |
\arrowlength{8pt} |
| 405 |
% \end{macrocode} |
| 406 |
% \end{macro} |
| 407 |
% If this file is used as a {\tt .sty} file without being stripped, we |
| 408 |
% want to stop here. The |\endinput| must not be at the beginning of the |
| 409 |
% line, or {\sf DocStrip} will stop here as well!. |
| 410 |
% \begin{macrocode} |
| 411 |
\endinput |
| 412 |
% \end{macrocode} |
| 413 |
% |
| 414 |
% \begin{macrocode} |
| 415 |
%</package> |
| 416 |
% \end{macrocode} |
| 417 |
|
| 418 |
% \section{texpicture.sty} |
| 419 |
% A dummy style file so that documents using {\tt pspicture.sty} |
| 420 |
% can be previewed or printed (as much as possible) using a |
| 421 |
% dvi (not PostScript) previewer or printer driver. |
| 422 |
|
| 423 |
% Just change `{\tt pspicture}' to `{\tt texpicture}' in the |
| 424 |
% |\documentstyle| options list. |
| 425 |
|
| 426 |
% \begin{macrocode} |
| 427 |
%<*texsty> |
| 428 |
% \end{macrocode} |
| 429 |
|
| 430 |
% \begin{macrocode} |
| 431 |
\@warning{texpicture.sty in operation:^^J\@spaces |
| 432 |
LaTeX document with pspicture.sty before printing} |
| 433 |
% \end{macrocode} |
| 434 |
% \begin{macro}{\Line} |
| 435 |
% \begin{macro}{\Vector} |
| 436 |
% \begin{macro}{\arrowlength} |
| 437 |
% \begin{macro}{\Curve} |
| 438 |
% Define all these new commands to silently gobble their arguments. |
| 439 |
% \begin{macrocode} |
| 440 |
\def\Line(#1,#2){} |
| 441 |
\def\Vector(#1,#2){} |
| 442 |
\def\arrowlength#1{} |
| 443 |
\def\Curve(#1,#2)#3{} |
| 444 |
% \end{macrocode} |
| 445 |
% \end{macro} |
| 446 |
% \end{macro} |
| 447 |
% \end{macro} |
| 448 |
% \end{macro} |
| 449 |
% |
| 450 |
% \begin{macro}{\@badlinearg} |
| 451 |
% If a vector or line is called with a slope specification that is not |
| 452 |
% allowed by standard \LaTeX, |\@badlinearg| is called to produce the |
| 453 |
% error message. We do not want to see these errors, so: |
| 454 |
% \begin{macrocode} |
| 455 |
\def\@badlinearg{} |
| 456 |
% \end{macrocode} |
| 457 |
% \end{macro} |
| 458 |
% |
| 459 |
% \begin{macro}{\oval} |
| 460 |
% \begin{macro}{\@@v@l} |
| 461 |
% \begin{macro}{\@@vv@l} |
| 462 |
% Give the standard |\oval| command another optional argument (which |
| 463 |
% will be ignored), to match the extra argument defined in {\tt |
| 464 |
% pspicture.sty}. |
| 465 |
% \begin{macrocode} |
| 466 |
\let\@@v@l\oval |
| 467 |
\def\@@@v@l[#1]{\@@v@l} |
| 468 |
\def\oval{\@ifnextchar[{\@@@v@l}{\@@v@l}} |
| 469 |
% \end{macrocode} |
| 470 |
% \end{macro} |
| 471 |
% \end{macro} |
| 472 |
% \end{macro} |
| 473 |
% |
| 474 |
% \begin{macrocode} |
| 475 |
%</texsty> |
| 476 |
% \end{macrocode} |
| 477 |
% |
| 478 |
% \section{pspicture.ps} |
| 479 |
% The PostScript header file for use with {\tt pspicture.sty}. |
| 480 |
% Probably this should use the PostScript dictionary mechanism, to keep |
| 481 |
% identifiers local to this package, but for now, just give them names |
| 482 |
% begining with {\tt!}. |
| 483 |
% \begin{macrocode} |
| 484 |
%<*ps> |
| 485 |
% \end{macrocode} |
| 486 |
% |
| 487 |
% \begin{macro}{!BP} |
| 488 |
% PostScript uses \TeX's |bp|, that is $1/72$ of an inch, not \TeX's |
| 489 |
% |pt|, $1/72.27$ of an inch, but it is inconvenient to get \TeX\ to |
| 490 |
% output in |bp|, so we need to scale the PostScript. |
| 491 |
% \begin{macrocode} |
| 492 |
/!BP{ |
| 493 |
72 72.27 div dup scale |
| 494 |
}def |
| 495 |
% \end{macrocode} |
| 496 |
% \end{macro} |
| 497 |
% |
| 498 |
% \begin{macro}{!A} |
| 499 |
% Arrow head:\\ |
| 500 |
% \meta{arrow length} |!A| |
| 501 |
% \begin{macrocode} |
| 502 |
/!A{ |
| 503 |
newpath |
| 504 |
0 0 moveto |
| 505 |
dup neg dup .4 mul rlineto |
| 506 |
.8 mul 0 exch rlineto |
| 507 |
closepath |
| 508 |
fill |
| 509 |
} def |
| 510 |
% \end{macrocode} |
| 511 |
% \end{macro} |
| 512 |
% |
| 513 |
% \begin{macro}{!V} |
| 514 |
% |\vector(|\meta{x}|,|\meta{y}|)| \\ |
| 515 |
% \meta{arrow length} \meta{line width} \meta{x} \meta{y} |
| 516 |
% \meta{len*unitlength} |!V| |
| 517 |
% \begin{macrocode} |
| 518 |
/!V{ |
| 519 |
!BP |
| 520 |
/!X exch def |
| 521 |
/!y exch def |
| 522 |
/!x exch def |
| 523 |
newpath |
| 524 |
0 0 moveto |
| 525 |
!x 0 eq {0 !y 0 lt {!X neg}{!X} ifelse} |
| 526 |
{!x 0 lt {!X neg}{!X}ifelse !X !y mul !x abs div} ifelse |
| 527 |
lineto |
| 528 |
setlinewidth % @wholewidth |
| 529 |
currentpoint |
| 530 |
stroke |
| 531 |
translate |
| 532 |
!y !x atan |
| 533 |
rotate |
| 534 |
!A % @arrowlength |
| 535 |
}def |
| 536 |
% \end{macrocode} |
| 537 |
% \end{macro} |
| 538 |
% |
| 539 |
% \begin{macro}{!L} |
| 540 |
% |\line(|\meta{x}|,|\meta{y}|)| \\ |
| 541 |
% \meta{arrow length} \meta{line width} \meta{x} \meta{y} |
| 542 |
% \meta{len*unitlength} |!L| |
| 543 |
% \begin{macrocode} |
| 544 |
/!L{ |
| 545 |
!BP |
| 546 |
/!X exch def |
| 547 |
/!y exch def |
| 548 |
/!x exch def |
| 549 |
newpath |
| 550 |
0 0 moveto |
| 551 |
!x 0 eq {0 !y 0 lt {!X neg}{!X} ifelse} |
| 552 |
{!x 0 lt {!X neg}{!X}ifelse !X !y mul !x abs div} ifelse |
| 553 |
lineto |
| 554 |
setlinewidth % @wholewidth |
| 555 |
stroke |
| 556 |
}def |
| 557 |
% \end{macrocode} |
| 558 |
% \end{macro} |
| 559 |
% |
| 560 |
% \begin{macro}{!C} |
| 561 |
% |\circle{|\meta{diam}|}| \\ |
| 562 |
% \meta{line width} \meta{diam*unitlength} |!C| |
| 563 |
% \begin{macrocode} |
| 564 |
/!C{ |
| 565 |
!BP |
| 566 |
0 0 3 2 roll |
| 567 |
2 div 0 360 arc |
| 568 |
setlinewidth % @wholewidth |
| 569 |
stroke |
| 570 |
}def |
| 571 |
% \end{macrocode} |
| 572 |
% \end{macro} |
| 573 |
% |
| 574 |
% \begin{macro}{!D} |
| 575 |
% |\circle*{|\meta{diam}|}| \\ |
| 576 |
% \meta{diam*unitlength} |!D| |
| 577 |
% \begin{macrocode} |
| 578 |
/!D{ |
| 579 |
!BP |
| 580 |
0 0 3 2 roll |
| 581 |
2 div 0 360 arc fill |
| 582 |
}def |
| 583 |
% \end{macrocode} |
| 584 |
% \end{macro} |
| 585 |
% |
| 586 |
% \begin{macro}{!O} |
| 587 |
% |\oval[|\meta{max-radius}|](|\meta{x}|,|\meta{y}|)[|\meta{tlbr}|]| \\ |
| 588 |
% \meta{br}\meta{bl}\meta{tr}\meta{tl}\\ |
| 589 |
% \meta{line width} \meta{max-radius*unitlength} |
| 590 |
% \meta{x*unitlength} \meta{y*unitlength} |!O|\\ |
| 591 |
% The first four arguments should be either $0$, denoting that that |
| 592 |
% quarter should not be drawn, or $1$, to draw a quarter oval. |
| 593 |
% \begin{macrocode} |
| 594 |
/!O{ |
| 595 |
!BP |
| 596 |
/!y exch 2 div def |
| 597 |
/!x exch 2 div def |
| 598 |
/!r exch !x !y |
| 599 |
% \end{macrocode} |
| 600 |
% Ghostscript appears to have a {\tt min} operator, so the following 2 |
| 601 |
% lines could be coded as {\tt min min}, but it's not in the |
| 602 |
% Ref.~Manual, and it doesn't work on my printer! |
| 603 |
% \begin{macrocode} |
| 604 |
2 copy gt {exch} if pop |
| 605 |
2 copy gt {exch} if pop |
| 606 |
def |
| 607 |
setlinewidth % @wholewidth |
| 608 |
1 eq |
| 609 |
{newpath |
| 610 |
!x neg 0 moveto |
| 611 |
!x neg !y 0 !y !r arcto 4 {pop} repeat |
| 612 |
0 !y lineto |
| 613 |
stroke}if |
| 614 |
1 eq |
| 615 |
{newpath |
| 616 |
!x 0 moveto |
| 617 |
!x !y 0 !y !r arcto 4 {pop} repeat |
| 618 |
0 !y lineto |
| 619 |
stroke}if |
| 620 |
1 eq |
| 621 |
{newpath |
| 622 |
!x neg 0 moveto |
| 623 |
!x neg !y neg 0 !y neg !r arcto 4 {pop} repeat |
| 624 |
0 !y neg lineto |
| 625 |
stroke}if |
| 626 |
1 eq |
| 627 |
{newpath |
| 628 |
!x 0 moveto |
| 629 |
!x !y neg 0 !y neg !r arcto 4 {pop} repeat |
| 630 |
0 !y neg lineto |
| 631 |
stroke}if |
| 632 |
}def |
| 633 |
% \end{macrocode} |
| 634 |
% \end{macro} |
| 635 |
% |
| 636 |
% \begin{macro}{!V2} |
| 637 |
% |\Vector(|\meta{x}|,|\meta{y}|)| \\ |
| 638 |
% \meta{arrow length} \meta{line width} \meta{x*unitlength} |
| 639 |
% \meta{y*unitlength} |!V2| |
| 640 |
% \begin{macrocode} |
| 641 |
/!V2{ |
| 642 |
!BP |
| 643 |
2 copy exch |
| 644 |
atan |
| 645 |
/a exch def |
| 646 |
2 copy |
| 647 |
newpath |
| 648 |
0 0 moveto |
| 649 |
lineto % <x*unitlength> <y*unitlength> |
| 650 |
3 2 roll |
| 651 |
setlinewidth % @wholewidth |
| 652 |
stroke |
| 653 |
translate % <x*unitlength> <y*unitlength> |
| 654 |
a rotate |
| 655 |
!A % @arrowlength |
| 656 |
}def |
| 657 |
% \end{macrocode} |
| 658 |
% \end{macro} |
| 659 |
% |
| 660 |
% \begin{macro}{!L2} |
| 661 |
% |\Line(|\meta{x}|,|\meta{y}|)| \\ |
| 662 |
% \meta{line width} \meta{x*unitlength} \meta{y*unitlength} |!L2| |
| 663 |
% \begin{macrocode} |
| 664 |
/!L2{ |
| 665 |
!BP |
| 666 |
newpath |
| 667 |
0 0 moveto |
| 668 |
lineto % <x*unitlength> <y*unitlength> |
| 669 |
setlinewidth % @wholewidth |
| 670 |
stroke |
| 671 |
}def |
| 672 |
% \end{macrocode} |
| 673 |
% \end{macro} |
| 674 |
% |
| 675 |
% \begin{macro}{!C2} |
| 676 |
% |\Curve(|\meta{x}|,|\meta{y}|){|\meta{$\pm$}|}| \\ |
| 677 |
% \meta{line width} \meta{x*unitlength} \meta{y*unitlength} \meta{$\pm$} |
| 678 |
% |!C2| |
| 679 |
% \begin{macrocode} |
| 680 |
/!C2{ |
| 681 |
!BP |
| 682 |
/!s exch def |
| 683 |
/!y exch def |
| 684 |
/!x exch def |
| 685 |
newpath |
| 686 |
0 0 moveto |
| 687 |
0 0 |
| 688 |
!x 2 div !y 10 div !s mul add |
| 689 |
!y 2 div !x 10 div !s mul sub |
| 690 |
!x !y |
| 691 |
curveto |
| 692 |
setlinewidth % @wholewidth |
| 693 |
stroke |
| 694 |
}def |
| 695 |
% \end{macrocode} |
| 696 |
% \end{macro} |
| 697 |
% |
| 698 |
% \begin{macrocode} |
| 699 |
%</ps> |
| 700 |
% \end{macrocode} |
| 701 |
% |
| 702 |
% \end{document} |
| 703 |
% \Finale |