# How to make a custom closed curve independent from other closed curves in a single pscustom?

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\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=->}
\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\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
{
\reversepath
\scale{-1 1}
\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\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]
{
\reversepath
\scale{-1 1}
\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}
\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!

\documentclass[pstricks,border=1cm]{standalone}

\def\HalfEye{\psline(0,-2)(-3,-2)(-3,0)(-2,1)(-1,0)(0,0)}
\def\HalfMouth{\psline(0,-4)(-2,-4)(-2,-3)(0,-3)}

\begin{document}
\begin{pspicture}[showgrid=b](-5,-5)(5,5)
\pscustom[fillstyle=eofill,fillcolor=red]{%
\moveto(0,-2)
\HalfEye
\moveto(0,-4)
\HalfMouth
\reversepath
\scale{-1 1}
\moveto(0,-2)
\HalfEye
\moveto(0,-4)
\HalfMouth
}
\end{pspicture}
\end{document}


• \moveto can be replaced by liftpen=2. – Artificial Stupidity Dec 9 '17 at 3:10
• Is internally the same! – user2478 Dec 9 '17 at 4:44

This is Asymptote code to make a single object gface from half parts of head, eye and mouth curves using evenodd PostScript fill rule in order to use it for filling and clipping:

// clcurve.asy
//
// run
// asy clcurve.asy
//
// to get clcurve.pdf
//
settings.outformat="pdf";
import graph; size(9cm);
guide fpsline(... pair[] p){return graph(p);}

guide   HalfEye=fpsline((-1,0),(-2,1),(-3,0),(-3,-2));
guide   HalfMouth=fpsline((-2,-3),(-2,-4));