# How to use even-odd filling rule either as a clipper or with gradient?

I just noticed that even-odd filling rule can only be used for solid and hatched filling. Sometimes, I need even-odd rule for gradient and as a clipper. How to do so? My code speaks the details.

\documentclass[pstricks,border=12pt]{standalone}

{
}

\newpsstyle{fill}
{
fillstyle=eofill,
fillcolor=orange,
}

\def\YinYang#1{%
\begin{pspicture}(-2,-2)(2,2)
\pscustom[style=#1,dimen=monkey]
{
\pscircle(0,0){2}
\moveto(.25,1)
\pscircle(0,1){.25}
\moveto(0,0)
\psarc(0,-1){1}{90}{270}
\psarc(0,0){2}{270}{90}
\psarcn(0,1){1}{90}{270}
\closepath
\moveto(.25,-1)
\pscircle(0,-1){.25}
}
\end{pspicture}}

\begin{document}
\YinYang{fill}

% there are 2 failed cases:
% 2. using the \pscustom of \YingYang as a clipper

\end{document}


## Note

Please don't suggest me to modify the paths and use zero filling rule.

## Edit

Based on Herbert's answer below, the following case in which the path is used as a clipper still does not work.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=2]{example-grid-100x100pt}}

\psset
{
xunit=.25\wd\IBox,
yunit=.25\ht\IBox,
}
\begin{document}

\begin{pspicture}(-2,-2)(2,2)
\psclip{%
\pscustom[dimen=monkey]
{
\pscircle(0,0){2}
\moveto(.25,1)
\pscircle(0,1){.25}
\moveto(0,0)
\psarc(0,-1){1}{90}{270}
\psarc(0,0){2}{270}{90}
\psarcn(0,1){1}{90}{270}
\closepath
\moveto(.25,-1)
\pscircle(0,-1){.25}
}}
\rput(0,0){\usebox\IBox}
\endpsclip
\end{pspicture}
\end{document}


-
I think the key-value formats defined for filling does not follow a logical pattern. – kiss my armpit Oct 21 '13 at 3:08
Not an answer (but I played around with it): \def\psfs@gradienteofill{\psfs@gradient\psfs@eofill} allows fillstyle=gradientoefill. This actually does the gradient first and then fills the correct path with white (or whatever the fillcolor is). – Qrrbrbirlbel Oct 21 '13 at 3:47

\def\YinYang#1{%
\begin{pspicture}(-2,-2)(2,2)
\pscustom[style=#1,dimen=middle]{
\code{ /clip /eoclip load def } %%%%%%%%%%%%%
\pscircle(0,0){2}
\moveto(.25,1)
\pscircle(0,1){.25}
\moveto(0,0)
\psarc(0,-1){1}{90}{270}
\psarc(0,0){2}{270}{90}
\psarcn(0,1){1}{90}{270}
\closepath
\moveto(.25,-1)
\pscircle(0,-1){.25}
}
\end{pspicture}}


and the same with a picture:

\begin{pspicture}(-2,-2)(2,2)
\psclip{%
\pscustom[dimen=middle]
{
\code{ /clip /eoclip load def }
\pscircle(0,0){2}
\moveto(.25,1)
\pscircle(0,1){.25}
\moveto(0,0)
\psarc(0,-1){1}{90}{270}
\psarc(0,0){2}{270}{90}
\psarcn(0,1){1}{90}{270}
\closepath
\moveto(.25,-1)
\pscircle(0,-1){.25}
}}
\rput(0,0){\usebox\IBox}
\endpsclip
\end{pspicture}


-
Is the \closepath necessary in this case? I noticed there is no difference when I removed the \closepath. – kiss my armpit Apr 22 '14 at 21:10