我刚刚注意到奇偶填充规则只能用于实心和阴影填充。有时,我需要奇偶规则用于渐变和裁剪。怎么做?我的代码说明了细节。
\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}
笔记
请不要建议我修改路径并使用零填充规则。
编辑
根据下面 Herbert 的回答,以下使用路径作为剪辑器的情况仍然不起作用。
\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}
答案1
\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}}
和图片一样:
\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}