# Why don't \pscircle and \psellipse move the current point before drawing their shapes?

I have tested all PSTricks closed curves:

• \psframe
• \psccurve
• \pspolygon
• \pswedge
• \psellipticwedge
• \pscircle
• \psellipse

and I noticed that only \pscircle and \psellipse do not move the current point before drawing their shapes.

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

\psset
{
fillstyle=solid,
fillcolor=cyan,
linewidth=2pt,
linecolor=red,
}

\everypsbox{\color{red}\bfseries\LARGE}
\begin{document}

\begin{pspicture}[showgrid](-4,-5)(4,7)
\pscustom
{
\psframe(-3,4)(3,5)
\psccurve(-3,2)(-1,2)(-1,3)(-1.5,2.5)
\pspolygon(1,2)(3,2)(2,3)
\pswedge(-2,0){1}{0}{270}
\psellipticwedge(2,0)(1,0.5){0}{270}
\pscircle(-2,-3){1}
\psellipse(2,-3)(1,0.5)
}
\rput(0,6.5){Default Behavior}
\end{pspicture}

\begin{pspicture}[showgrid](-4,-5)(4,7)
\pscustom
{
\psframe(-3,4)(3,5)
\psccurve(-3,2)(-1,2)(-1,3)(-1.5,2.5)
\pspolygon(1,2)(3,2)(2,3)
\pswedge(-2,0){1}{0}{270}
\psellipticwedge(2,0)(1,0.5){0}{270}
\moveto(-1,-3)
\pscircle(-2,-3){1}
\moveto(3,-3)
\psellipse(2,-3)(1,0.5)
}
\rput(0,6.5){With \textbackslash moveto()}
\end{pspicture}

\end{document}


Is it a feature by design or a bug?

NOTE:

I intentionally put all objects inside \pscustom to show the current point effect. I am not talking about how to draw a solid rectangle, a solid polygon, a solid wedge, a solid elliptical wedge, a solid circle, and a solid ellipse.

Responding Herbert's comment "it is totally nonsense to use a closed curve inside \pscustom which itself creates a closed path", I show an example where closed curves are sometimes needed inside \pscustom to make

• transparent holes with other parts are opaque and filled with solid color, or
• transparent holes with other parts are opaque and filled with an image via clipping.

So this scenario is more complicated than just a single simple ring provided by \psRing.

\documentclass[border=12pt]{standalone}
\usepackage{pstricks}
\usepackage{graphicx}
\psset{linewidth=3pt,dimen=m}
\begin{document}

\begin{pspicture}[showgrid=top](4,4)
\pscustom[fillstyle=eofill,fillcolor=red]
{
\pscircle(2,2){2}
\moveto(3.75,2.25)
\pscircle(2.75,2.25){1}
\moveto(1.25,2.5)
\pscircle(0.75,2.5){0.5}
\moveto(2,1)
\pscircle(1.5,1){0.5}
}
\end{pspicture}
\hspace{1cm}
\begin{pspicture}[showgrid=top](4,4)
\psclip{%
\pscustom
{
\pscircle(2,2){2}
\moveto(3.75,2.25)
\pscircle(2.75,2.25){1}
\moveto(1.25,2.5)
\pscircle(0.75,2.5){0.5}
\moveto(2,1)
\pscircle(1.5,1){0.5}
}}
\rput(2,2){\includegraphics[width=4cm]{example-grid-100x100pt}}
\endpsclip
\end{pspicture}

\end{document}

-
You can add \pspolygon(-4,-4)(-4,3)(4,3)(4,-4) to show why \pscustom is useful (I don't know how to reverse \psframe)... –  Paul Gaborit Aug 2 '12 at 6:41

I think, \pscustom is the culprit. It wants to draw closed paths. You will get a correct picture if you use \psset instead. Because you use absolute coordinates, there is no need for \moveto.

\documentclass{article}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{pspicture}[showgrid](-4,-4)(4,3)
\psset{fillstyle=solid,fillcolor=cyan}
\psframe(-3,1)(0,2)
\pspolygon(1,1)(3,1)(2,2)
\pswedge(0,0){1}{30}{60}
\pscircle(-2,-2){1}
\psellipse(2,-2)(1,0.5)
\end{pspicture}

\end{document}


-
I am sorry. You might misunderstand my objective. The \pscustom is intentionally used to show the current point effect. –  kiss my armpit Aug 1 '12 at 20:55
I present my bounty to you because I am in hurry to offer another bounty. –  kiss my armpit Aug 5 '12 at 19:49
Thank you for the unexpected bounty! –  Peter Breitfeld Aug 5 '12 at 19:50
You are welcome. :-) –  kiss my armpit Aug 5 '12 at 19:51

You can use all closed curves inside \pscustom. But don't expect the desired behavior. There is no need to use closed curves! You can always use the open alternatives, like polygon, arc, and so on.

\documentclass{standalone}
\usepackage{pstricks,graphicx}

\begin{document}
\begin{pspicture}(6,6)
\psclip{\pscircle[linestyle=none](3,3){3}}
\rput(3,3){\includegraphics[width=6\psunit]{example-grid-100x100pt}}
\endpsclip
\psframe*[linecolor=white,opacity=0.3](1,1)(5,5)
\end{pspicture}

\end{document}


-
Is there a reason why Timothy Van Zandt made the circle and ellipse do not lift the pen before drawing their shapes? –  kiss my armpit Aug 10 '12 at 16:03
\psellipse and \pscircle use the internal postscript function arc and that one is different from all other drawing functions: it doesn't take the current point into account. It needs the center, the radi and the angles. If the center is not the current point then there is always a strait line from the current point to the center of the circle/ellipse if one uses it as part of a path. –  Herbert Apr 8 '13 at 15:26
Please consider again the diagram above. The current point (2,0) and and the straight lines go to (-1,-3) which is NOT the center of the circle and (3,-3) which is NOT the center of the ellipse. –  kiss my armpit Apr 8 '13 at 15:38
the last current point is (2,0). From that point a straight line is drawn to the starting-point (xCenter+radius,yCenter) of the next circle/ellipse –  Herbert Apr 8 '13 at 15:44
I guess the author TVZ forgot to move the current point to the starting point of the circle/ellipses. I mean he forgot to call \moveto(xCenter+radius,yCenter) before drawing the circle/ellipse with the PostScript's arc function. That is why I have to manually call the \moveto. –  kiss my armpit Apr 8 '13 at 15:50

This problem has been fixed in the latest pstricks so I can simplify the code as follows. For the sake of fun, I illustrate how to apply it for defining an even-odd filling and clipping path.

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

\psset{linewidth=6pt}

\begin{document}

\begin{pspicture}[showgrid](-4,-5)(4,6)
\pscustom[fillstyle=eofill,fillcolor=yellow]
{
\psframe(-4,-5)(4,6)
\psframe(-3,4)(3,5)
\psccurve(-3,2)(-1,2)(-1,3)(-1.5,2.5)
\pspolygon(1,2)(3,2)(2,3)
\pswedge(-2,0){1}{0}{270}
\psellipticwedge(2,0)(1,0.5){0}{270}
\pscircle(-2,-3){1}
\psellipse(2,-3)(1,0.5)
}
\end{pspicture}

% note that clipping trim the line strokes
\begin{pspicture}[showgrid](-4,-5)(4,6)
\psclip{
\pscustom
{
\psframe(-4,-5)(4,6)
\psframe(-3,4)(3,5)
\psccurve(-3,2)(-1,2)(-1,3)(-1.5,2.5)
\pspolygon(1,2)(3,2)(2,3)
\pswedge(-2,0){1}{0}{270}
\psellipticwedge(2,0)(1,0.5){0}{270}
\pscircle(-2,-3){1}
\psellipse(2,-3)(1,0.5)
}}
\psframe*[linecolor=yellow](-6,-6)(7,7)
\endpsclip
\end{pspicture}

\end{document}

-