%% xypdf-c.tex from $Id: xypdf-c.doc,v $
%%
%% Xy-pic ``Colour extension'' PDF backend support.
%% Copyright (c) 1999-1999 Ross Moore <ross@mpce.mq.edu.au>
%%
%% This file is part of the Xy-pic package for graphs and diagrams in TeX.
%% See the companion README and INSTALL files for further information.
%% Copyright (c) 1991-1999 Kristoffer H. Rose <krisrose@brics.dk>
%%
%% The Xy-pic package is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by the
%% Free Software Foundation; either version 2 of the License, or (at your
%% option) any later version.
%%
%% The Xy-pic package is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
%% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
%% for more details.
%%
%% You should have received a copy of the GNU General Public License along
%% with this package; if not, write to the Free Software Foundation, Inc.,
%% 675 Mass Ave, Cambridge, MA 02139, USA.
%%
%% As a special exception, you may use this file and all files derived
%% from it without restrictions. This special exception was added with
%% version 3.7 of Xy-pic.
%%
\expandafter\ifx\csname xypdf-cloaded\endcsname\empty
 \message{not reloaded}\endinput \fi
\expandafter\let\csname xypdf-cloaded\endcsname=\empty \xycatcodes
\expandafter\ifx \csname xypdf-sloaded\endcsname\empty\else
 \xyinputorelse@{xypdf-s}{\xyerror@{Could not load xypdf-s}{}}%
 \xycatcodes\fi
\xydef@\UsePDFcolor{\installPDFcolor@}
\xydef@\NoPDFcolor{\UnloadColor@}
\xydef@\installPDFcolor@{\installPDFstyle@
 \let\xymath@=\xyPDFmath@ \let\xynomath@=\xyPDFnomath@
 \let\checkxyPDFcolor@=\checkxyPDFcolor@@
 \let\xycolor@@=\xyPDFcolor@@
 \xystandardcolors@ 
 \xyuncatcodes }
\xydef@\xyPDFmath@{\hbox\bgroup\dimen@=.55ex \checkxyPDFcolor@ \xyinside@}
\xydef@\xyPDFnomath@{\hbox\bgroup\dimen@=\z@ \checkxyPDFcolor@ \xyinside@}
\xydef@\checkxyPDFcolor@@{\edef\pdfsaved@color{\pdfcurrent@color}%
 \let\checkxyPDFcolor@=\relax}
\xylet@\checkxyPDFcolor@=\relax
\xydef@\xyPDFnewcolor@#1#2#3#4#5{%
 \expandafter\DN@\expandafter{\csname shape [#1]\endcsname}%
 \DNii@{\relax}\ifx\next@\nextii@\newxycolor{#1}{}\relax\fi
 \DNii@{#4}\ifx\nextii@\empty
 \expandafter\DNii@\expandafter{\csname xyPDFshape@#1@\endcsname}%
 \expandafter\def\nextii@{\xyPDFcolor@{#2//#3}}\else
 \expandafter\DNii@\expandafter{\csname xyPDFshape@#1@\endcsname}%
 \expandafter\def\nextii@{\xyPDFcolor@{#4}}\fi
 \ifx\nextii@\empty\expandafter\def\next@{\xyPDFnotimplemented@@`#1'@@}%
 \else
 \edef\tmp@{\noexpand\let\expandafter\noexpand\next@
 \expandafter\noexpand\nextii@}\expandafter\tmp@\fi }
\xylet@\newxycolor@=\xyPDFnewcolor@
\xydef@\xyPDFcolor@{\ifPDFspecials@\expandafter\xyPDFcolor@@
 \else\expandafter\eat@\fi}
\xydef@\xyPDFcolor@@#1{\bgroup \checkXyStyle@ 
 \def\preStyle@@{\expandafter\addtostyletoks@\expandafter{\xyPDFpre@}}%
 \def\postStyle@@{\expandafter\addtostyletoks@\expandafter{\xyPDFpost@}}%
 \let\modPDFboxz@=\modXYstyle@ \xyPDF@color@@{#1}%
 \toks@={\egroup\let\xy@style@=\relax \def\Drop@@}%
 \expandafter\addtotoks@\expandafter{\expandafter{\Drop@@}\def\Connect@@}%
 \expandafter\addtotoks@\expandafter{\expandafter{\Connect@@}}%
 \the\toks@ }

\xydef@\pdfcurrent@color{1 1 1 1 k 1 1 1 1 K}
\xydef@\pdfsaved@color{1 1 1 1 k 1 1 1 1 K}
\xydef@\xyPDF@color@@#1{%
 \edef\pdfsaved@color{\pdfcurrent@color}%
 \pdf@convertcolor#1////!%
 \edef\next@{\noexpand\xyPDFsplitPDF@{\pdfcurrent@color}{\pdfsaved@color}}%
 \next@}
\xydef@\pdf@convertcolor#1//#2//#3!{\DN@{#2}%
 \DNii@{cmyk}\ifx\next@\nextii@\DN@{#1 k #1 K}%
 \else \DNii@{rgb}\ifx\next@\nextii@\DN@{#1 rg #1 RG}%
 \else \DNii@{gray}\ifx\next@\nextii@\DN@{#1 #1 #1 rg #1 #1 #1 RG}%
 \else \DN@{1 1 1 1 k 1 1 1 1 K}%
 \fi \fi \fi 
 \expandafter\def\expandafter\pdfcurrent@color\expandafter{\next@}}
\xydef@\xycolor@raw@@#1{}%
\endinput
