Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/lib/texmf/tex/generic/pstricks/pst2eps.tex

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


%% BEGIN pst2eps.tex
%%
%% For writing EPS files with PSTricks.
%%
\def\fileversion{0.93a}
\def\filedate{93/03/12}
%%
%% COPYRIGHT 1993, by Timothy Van Zandt, tvz@Princeton.EDU
%% See pstricks.tex or pstricks.doc for copying restrictions.
%%
%% See the PSTricks User's Guide for description.
%%

\message{ v\fileversion, \filedate}

\csname PSTfilesLoaded\endcsname
\let\PSTfilesLoaded\endinput

\ifx\PSTricksLoaded\endinput\else
  \def\next{\input pstricks.tex}
  \expandafter\next
\fi

\edef\TheAtCode{\the\catcode`\@}
\catcode`\@=11

% Exporting PostScript files

\def\TeXtoEPS{\begingroup\pst@makebox{}\bgroup\ignorespaces}
\def\endTeXtoEPS{%
    \egroup
% Get contents of page, in case it contains special's:
    \begingroup
      \global\setbox\pst@boxg\box\voidb@x
      \output{\global\setbox\pst@boxg\box\@cclv}%
      \par\hbox{}\penalty-10000
    \endgroup
    \dp\pst@boxg\z@
    \ht\pst@boxg\z@
    \wd\pst@boxg\z@
  \pst@dimg=3pt
  \shipout\hbox{%
    \box\pst@boxg
    \pst@Verb{gsave CM \tx@STV CP newpath moveto
      \pst@number\pst@dimg neg 0 rmoveto clip setmatrix}%
    \vrule width \wd\pst@hbox height \ht\pst@hbox depth \dp\pst@hbox
    \pstVerb{currentpoint grestore moveto}%
    \kern -\wd\pst@hbox
    \unhbox\pst@hbox}%
  \endgroup
  \typeout{PSTricks: Converting TeX box to EPS.}%
  \typeout{\@spaces\@spaces\space\space With dvips, use -E option.}}


% Writing PSTricks graphics to EPS files

\newwrite\pst@epsout
\newwrite\pst@tempout

\def\pst@getbp#1#2#3{%
  \csname psset#1length\endcsname\pst@dimg{#2}%
  \advance\pst@dimg .49bp
  \pst@cntg=\pst@dimg
  \multiply\pst@cntg 5
  \divide\pst@cntg 328909
  \edef#3{\the\pst@cntg}}

\def\psset@bbllx#1{\pst@getbp{x}{#1}\psk@bbllx}
\psset@bbllx{-1pt}

\def\psset@bblly#1{\pst@getbp{y}{#1}\psk@bblly}
\psset@bblly{-1pt}

\def\psset@bburx#1{\pst@getbp{x}{#1}\psk@bburx}
\psset@bburx{1pt}

\def\psset@bbury#1{\pst@getbp{y}{#1}\psk@bbury}
\psset@bbury{1pt}

\def\pst@getboolean#1#2{%
  \def\pst@tempg##1##2\@nil{%
    \ifx t##1\relax\def#2{1\relax}\else\def#2{\z@}\fi}
  \pst@expandafter\pst@tempg{#1}\relax\@nil}

\def\psset@headers#1{%
  \def\pst@tempg##1##2\@nil{%
    \ifx u##1\relax
      \def\psk@headers{1\relax}%
    \else
      \ifx a#1\relax
        \def\psk@headers{2\relax}%
      \else
        \def\psk@headers{\z@}%
      \fi
    \fi}%
  \pst@expandafter\pst@tempg{#1}\relax\@nil}
\psset@headers{none}

\def\psset@checkfile#1{\pst@getboolean{#1}\psk@checkfile}
\psset@checkfile{true}

\def\psset@makeeps#1{%
  \def\pst@tempg{#1}%
  \ifx\pst@tempg\@none
    \def\psk@makeeps{\z@}%
  \else
    \def\pst@temph{all}%
    \ifx\pst@tempg\pst@temph
      \def\psk@makeeps{3\relax}%
    \else
      \def\pst@temph{all*}%
      \ifx\pst@tempg\pst@temph
        \def\psk@makeeps{2\relax}%
      \else
        \def\psk@makeeps{1\relax}%
      \fi
    \fi
  \fi}
\psset@makeeps{new}

\def\psset@headerfile#1{\def\psk@headerfile{#1}}
\psset@headerfile{}

\def\pst@checkfile#1{%
  \ifcase\psk@makeeps
    \@pstfalse
  \or
    \immediate\openin1=#1
    \ifeof1\relax\@psttrue\else\@pstfalse\fi
    \immediate\closein1
  \or
    \immediate\openin1=#1
    \ifeof1
      \@psttrue
    \else
      \typeout{^^J%
      PSTricks warning:^^J%
      !! File `#1' exists and will be erased if in current directory!^^J%
      !! Make `#1'? (y=yes; n=no)}
      \read16 to \pst@tempg
      \if y\pst@tempg\relax\@psttrue\else\@pstfalse\fi
    \fi
    \immediate\closein1=#1
  \or
    \@psttrue
  \fi}

\def\PSTtoEPS{\def\pst@par{}\pst@object{PSTtoEPS}}
\begingroup
\catcode`\%=12
\catcode`\"=14
\long\gdef\PSTtoEPS@i#1#2{"
  \begingroup
    \use@par
    \newlinechar`\^^J"
    \pst@checkfile{#1}"
    \if@pst
      \immediate\openout\pst@epsout=#1
      \def\write@eps##1{\immediate\write\pst@epsout{##1}}"
      \def\addto@pscode##1{"
        \begingroup
          \newlinechar`\ "
          \write@eps{##1}"
        \endgroup}
      \write@eps{"
        %!PS-Adobe-3.0 EPSF-3.0^^J"
        %%Creator: PSTricks^^J"
        %%Title: #1^^J"
        %%CreationDate: \the\year/\the\month/\the\day^^J"
        %%BoundingBox:
          \psk@bbllx\space\psk@bblly\space\psk@bburx\space\psk@bbury^^J"
        %%EndComments}"
      \ifcase\psk@headers
        \def\pst@tempg{}"
      \or
        \let\pst@tempg\psk@headerfile
      \or
        \edef\pst@tempg{\pst@theheaders,\psk@headerfile}"
      \fi
      \ifx\pst@tempg\@empty\else
        \expandafter\pst@writeheaders\pst@tempg,\@nil
      \fi
      \write@eps{%%BeginSetup}"
      \addto@pscode\pst@dict
      \write@eps{%%EndSetup}"
      \ifdim\pstunit=1bp\else
        \pst@dimg=\pstunit\relax
        \write@eps{\number\pst@dimg\space 65781.8 div dup scale}"
      \fi
      \addto@pscode{"
        \tx@STP
        0 setlinecap
        0 setlinejoin
        10 setmiterlimit
        [] 0 setdash
        newpath}"
      \setbox\pst@hbox=\hbox{"
        \def\init@pscode{"
          \write@eps{"
            gsave
            \psk@origin
            \psk@swapaxes
            \pst@number\pslinewidth SLW
            \pst@usecolor\pslinecolor}}"
        \def\use@pscode{\write@eps{grestore}}"
        \let\pst@rawfile\pst@filetoeps
        \def\psclip#1{\pst@misplaced\psclip}"
        \let\endpsclip\relax
        \def\pstextpath@@@[##1](##2,##3)##4{\pst@misplaced\pstextpath}"
        \def\nc@object##1##2##3##4{\pst@misplaced{node connection}}"
        \def\PSTtoEPS@i##1##2{\pst@misplaced\PSTtoEPS}"
        #2}"
      \write@eps{"
        %%Trailer^^J"
        end^^J"
        %%EOF}"
      \immediate\closeout\pst@epsout
    \fi
  \endgroup
  \ignorespaces}

\gdef\pst@writeheaders#1,{"
  \def\pst@tempg{#1}"
  \ifx\pst@tempg\@empty\else
    \write@eps{%%BeginProcSet: #1}"
    \pst@filetoeps{#1}"
    \write@eps{%%EndProcSet}"
  \fi
  \@ifnextchar\@nil{\let\pst@tempg}{\pst@writeheaders}}
\endgroup

\def\pst@filetoeps#1{%
  \begingroup
    \def\do##1{\catcode`##1=12\relax}%
    \dospecials
    \def\addto@pscode##1{\write@eps{##1}}%
    \pst@@rawfile{#1}%
  \endgroup}

\catcode`\@=\TheAtCode\relax

\endinput

%% END pst2eps.tex

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.