% TeXdraw macros to access PostScript builtins

% $Id: txdps.tex 1.10 2019/04/18 TeXdraw-v2r3 $

%   Copyright (C) 1991-2019  Peter Kabal

% This work is licensed under the Creative Commons Attribution (CC-BY)
% License, any version. To view the licenses, visit
% creativecommons.org/licenses/by or send a letter to
% Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

%  Peter Kabal
%  Department of Electrical & Computer Engineering
%  McGill University

%  peter dot kabal at mcgill dot ca
%  http://www-mmsp.ece.mcgill.ca/MMSP/Documents/Software/

% ===============================================================

\chardef\catamp=\the\catcode`\@
\catcode`\@=11

% The TeXdraw macros assume that a PostScript currentpoint is always
% defined. When using the following macros, always finish off with
% by reestablishing a PostScript currentpoint. This can be done with
% a \PSmoveto command.

\def\PSsetlinecap #1 {\writeps{#1 setlinecap}}
\def\PSsetlinejoin #1 {\writeps{#1 setlinejoin}}
\def\PSstroke {\writeps{stroke}}
\def\PSnewpath {\writeps{newpath}}
\def\PSclosepath {\writeps{closepath}}
\def\PSfill {\writeps{fill}}
\def\PSlineto (#1 #2){\getpos (#1 #2)\a@rgx\a@rgy
                      \s@etpospix \a@rgx \a@rgy
                      \writeps {\the\x@pix\space \the\y@pix\space lineto}}
\def\PSmoveto (#1 #2){\getpos (#1 #2)\a@rgx\a@rgy
                      \s@etpospix \a@rgx \a@rgy
                      \writeps {\the\x@pix\space \the\y@pix\space moveto}}
\def\PSarc r:#1 sd:#2 ed:#3 (#4 #5){\getpos (#4 #5)\a@rgx\a@rgy
                                    \s@etpospix \a@rgx \a@rgy
                                    \coordtopix {#1}\t@pixa
                                    \writeps{\the\x@pix\space \the\y@pix\space
                                             \the\t@pixa\space #2 #3 arc}}
\def\PSarcn r:#1 sd:#2 ed:#3 (#4 #5){\getpos (#4 #5)\a@rgx\a@rgy
                                     \s@etpospix \a@rgx \a@rgy
                                     \coordtopix {#1}\t@pixa
                                     \writeps{\the\x@pix\space \the\y@pix\space
                                              \the\t@pixa\space #2 #3 arcn}}

\catcode`\@=\catamp
