Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
\usepackage{pst-grad}

\newpsstyle{gradient}
{
    fillstyle=gradient,
    gradbegin=red,
    gradend=yellow,
    gradangle=30,
    gradmidpoint=0.5,
}

\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:
% 1. with gradient style \YinYang{gradient}
% 2. using the \pscustom of \YingYang as a clipper

\end{document}

enter image description here

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]
    {
        \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}
\end{document}

enter image description here

share|improve this question
    
I think the key-value formats defined for filling does not follow a logical pattern. –  cyanide-based food Oct 21 '13 at 3:08
1  
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

1 Answer 1

up vote 4 down vote accepted
\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}}

enter image description here

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}

enter image description here

share|improve this answer
    
Is the \closepath necessary in this case? I noticed there is no difference when I removed the \closepath. –  cyanide-based food Apr 22 at 21:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.