5

I am trying to fill some custom area in pstricks, and I am a bit surprised by the outcome. This is my MWE:

\documentclass[border=3mm]{standalone}
\usepackage{pstricks}
\begin{document}

\begin{pspicture}(-3,-2.3)(3,3)
\psclip[linestyle=none]{%   
\pscustom{
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
  }}
  \psframe*[linecolor=gray,opacity=0.6](-3,-3)(3,3)
\endpsclip
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}

\begin{pspicture}(-3,-2.3)(3,3)
\pscustom[fillstyle=solid,fillcolor=gray]{
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
  }
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}

\begin{pspicture}(-3,-2.3)(3,3)
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}

\end{document}

And this is the outcome:

enter image description here

The shape I want to fill is shown on the right. On the left and in the middle the outcomes of two different attempts to fill the shape are shown. Not only that both do not precisely fill the shape, also the mismatches depend on whether I use \psclip of the directly \pscustom. Why is that?

1
  • @ArtificialStupidity Thanks! (I'm wondering if you want to post an answer, others may have the same problem.)
    – user121799
    Dec 15, 2017 at 19:11

1 Answer 1

5

In \pscustom the last point of a line/curve (path) is always the first point of the following curve (path)! For example:

      \pscustom{%
        \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
        \pscurve(2.5,-2)(0.9,0)(0,2)
        ...

is wrong! The second \pscurve has now four (!) pairs of coordinates:

        \pscurve(2.5,-2)(2.5,-2)(0.9,0)(0,2)

and that is far different to a curve with \pscurve(2.5,-2)(0.9,0)(0,2) Delete the first point and all will be fine!

\documentclass[border=3mm]{standalone}
\usepackage{pstricks}
\begin{document}


\begin{pspicture}(-3,-2.3)(3,3)
\psclip[linestyle=none]{%   
    \pscustom{
        \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
        \pscurve(0.9,0)(0,2)
        \pscurve(-0.9,0)(-2.5,-2)
    }}
    \psframe*[linecolor=gray,opacity=0.6](-3,-3)(3,3)
    \endpsclip
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
    \end{pspicture}

    \begin{pspicture}(-3,-2.3)(3,3)
    \pscustom[fillstyle=solid,fillcolor=gray]{
        \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
        \pscurve(0.9,0)(0,2)
        \pscurve(-0.9,0)(-2.5,-2)
    }
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
    \end{pspicture}

    \begin{pspicture}(-3,-2.3)(3,3)
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
    \end{pspicture}

\end{document}

enter image description here

There is no difference in the following two curves:

\documentclass[border=3mm]{standalone}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-3,-2.3)(3,3)
\pscustom[linewidth=4pt,linecolor=blue]{
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(0.9,0)(0,2)
    \pscurve(-0.9,0)(-2.5,-2)
    \closepath
}
\psset{linecolor=red,linewidth=1.5pt}
    \pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
    \pscurve(2.5,-2)(0.9,0)(0,2)
    \pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}

\end{document}

enter image description here

10
  • Thanks for the explanation! But why is the outcome for my above curves different depending on whether or not I use \psclip? Naively, I'd expect this to be the same since these should now be the same curves (even if they are wrong).
    – user121799
    Dec 15, 2017 at 19:44
  • Well, I understand this. But from your answer I get that the boundary curves have now 4 points. But shouldn't they still be unique?
    – user121799
    Dec 15, 2017 at 19:50
  • @marmot: It has nothing to do with \psclip. The only difference is using \pscustom or not using it.
    – user2478
    Dec 15, 2017 at 19:59
  • @ArtificialStupidity: A liftpen setting in a series of curves without a moveto makes no sense!
    – user2478
    Dec 15, 2017 at 20:00
  • 1
    @ArtificialStupidity Would you mind writing an answer elaborating the many comments you've left in this thread? I'm sure it would be highly educational and appreciated.
    – Mast
    Dec 16, 2017 at 20:27

You must log in to answer this question.