It is related to my previous question but with a little bit different requirement. Rather than editing the previous one that potentially makes "inconvenience" to the accepted answer, let me ask it separately.
Background
Bilateral closed curves can be constructed easily with \reversepath
. For the sake of illustration, let's me take a simple example, i.e., drawing a helmet.
The following three macros define half part of head, eye and mouth curves of the helmet, respectively.
\documentclass[pstricks,border=1cm]{standalone}
\def\HalfHead{\psline(-2,2)(-3,4)(-4,1)(-4,-5)}
\def\HalfEye{\psline(-1,0)(-2,1)(-3,0)(-3,-2)}
\def\HalfMouth{\psline(-2,-3)(-2,-4)}
\begin{document}
\begin{pspicture}[showgrid=b](-5,-5)(5,5)
\psset{linecolor=blue,arrows=->}
\HalfHead
\HalfEye
\HalfMouth
\end{pspicture}
\end{document}
The complete closed curves for head, eye and mouth can be obtained by enclosing each with a single \pscustom
as follows.
\documentclass[pstricks,border=1cm]{standalone}
\def\HalfHead{\psline(-2,2)(-3,4)(-4,1)(-4,-5)}
\def\HalfEye{\psline(-1,0)(-2,1)(-3,0)(-3,-2)}
\def\HalfMouth{\psline(-2,-3)(-2,-4)}
\begin{document}
\begin{pspicture}[showgrid=b](-5,-5)(5,5)
\pscustom
{
\HalfHead
\reversepath
\scale{-1 1}
\HalfHead
\closepath
}
\pscustom
{
\HalfEye
\reversepath
\scale{-1 1}
\HalfEye
\closepath
}
\pscustom
{
\HalfMouth
\reversepath
\scale{-1 1}
\HalfMouth
\closepath
}
\end{pspicture}
\end{document}
Among other purposes (such as filling with gradient color, filling with a pattern, or clipping another image), I want to fill the region bounded by the head, eye and mouth with a solid red.
Unfortunately \pscustom
cannot be nested. I have to use a single \pscustom
as follows but the result is disappointing.
\documentclass[pstricks,border=1cm]{standalone}
\def\HalfHead{\psline(-2,2)(-3,4)(-4,1)(-4,-5)}
\def\HalfEye{\psline(-1,0)(-2,1)(-3,0)(-3,-2)}
\def\HalfMouth{\psline(-2,-3)(-2,-4)}
\begin{document}
\begin{pspicture}[showgrid=b](-5,-5)(5,5)
\pscustom[fillstyle=eofill,fillcolor=red]
{
\HalfHead
\reversepath
\scale{-1 1}
\HalfHead
\closepath
\HalfEye
\reversepath
\scale{-1 1}
\HalfEye
\closepath
\HalfMouth
\reversepath
\scale{-1 1}
\HalfMouth
\closepath
}
\end{pspicture}
\end{document}
Herbert's answer in my previous question uses a trick that seems to be cumbersome. It forces us to retrace the path.
Question
Recall that the built-in closed curves such as
psellipticwedge
psellipse
pscircle
pswedge
pspolygon
psframe
psccurve
can be used independently in a single \pscustom
,
I think it will be better if I make each of the closed curves for head, eye and mouth a single independent object.
How to make
\HalfHead
\reversepath
\scale{-1 1}
\HalfHead
\closepath
as a single independent object for the head such that it can be used together later in a single pscustom
? A solution in Metapost, Asympotote, Tikz, etc is also welcome!