[pstricks] \pspolygon and dimen=inner

Jean-Côme Charpentier Jean-Come.Charpentier at wanadoo.fr
Sun Feb 5 18:26:09 CET 2006


Herbert Voss wrote:
> Adam Fenn wrote:
> 
>>>> The graphics parameter dimen=inner may be used with \psframe, 
>>>> \pscircle, \psellipse and
>>>> \pswedge. Can the same effect be created for \pspolygon?
>>
>>  >no, because it makes no sense. What is inner and outer
>>  >when you have crossed lines, e.g. drawing an eight.
>>
>> None of my polygons have crossing lines, so they do enclose 'inner' 
>> space.
> 
> sure, but you can have a right turn or a left turn ...
> and then the meaning of inner/outer changes.

Obviously, we can define an inner and an outer for closed path, even for 
crossed path (there is several different definitions in this case) but 
it's not easy to code.

Here is a not so good solution:

\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}

\begin{document}
% inner
\begin{pspicture}(0,0)(3,4)
   \def\cliparg{[linewidth=0pt]}
   \def\polygonarg{[linewidth=10pt]}
   \def\polygonpath{(0,0)(2,4)(3,1)(2,0)}
   \begin{psclip}{\expandafter\expandafter\expandafter
       \pspolygon\expandafter\cliparg\polygonpath}
     \expandafter\expandafter\expandafter
       \pspolygon\expandafter\polygonarg\polygonpath
   \end{psclip}
   \pspolygon[linewidth=0.2pt,linecolor=green](0,0)(2,4)(3,1)(2,0)
\end{pspicture}

\vspace{5mm}
%outer
\begin{pspicture}(0,0)(3,4)
   \def\cliparg{[linewidth=0pt]}
   \def\polygonarg{[linewidth=10pt]}
   \def\polygonpath{(0,0)(2,4)(3,1)(2,0)}
   \expandafter\expandafter\expandafter
     \pspolygon\expandafter\polygonarg\polygonpath
   \pscustom[fillstyle=solid,fillcolor=white,linewidth=0pt]{%
     \expandafter\expandafter\expandafter
       \pspolygon\expandafter\cliparg\polygonpath
   }
   \pspolygon[linewidth=0.2pt,linecolor=green](0,0)(2,4)(3,1)(2,0)
\end{pspicture}

\vspace{5mm}
% problem!
\begin{pspicture}(0,0)(3,4)
   \def\cliparg{[linewidth=0pt]}
   \def\polygonarg{[linewidth=10pt]}
   \def\polygonpath{(0,2)(1.5,4)(3,2)(2,0)(1,2)(1.5,3)(2,2)(1,0)}
   \begin{psclip}{\expandafter\expandafter\expandafter
       \pspolygon\expandafter\cliparg\polygonpath}
     \expandafter\expandafter\expandafter
       \pspolygon\expandafter\polygonarg\polygonpath
   \end{psclip}
   \pspolygon[linewidth=0.2pt,linecolor=green]%
     (0,2)(1.5,4)(3,2)(2,0)(1,2)(1.5,3)(2,2)(1,0)
\end{pspicture}

\vspace{5mm}
% fixed by hand :-)
\begin{pspicture}(0,0)(3,4)
   \def\cliparg{[linewidth=0pt]}
   \def\polygonarg{[linewidth=10pt]}
   \def\polygonpath{(0,2)(1.5,4)(3,2)(2,0)%
     (1.5,1)% crossed point
     %(1,2)
     (2,2)% exchange (1,2) and (2,2)
          % in order to have a "non-crossed path"
     (1.5,3)
     %(2,2)
     (1,2)%
     (1.5,1)% crossed point (bis)
     (1,0)}
   \begin{psclip}{\expandafter\expandafter\expandafter
       \pspolygon\expandafter\cliparg\polygonpath}
     \expandafter\expandafter\expandafter
       \pspolygon\expandafter\polygonarg\polygonpath
   \end{psclip}
   \pspolygon[linewidth=0.2pt,linecolor=green]%
     (0,2)(1.5,4)(3,2)(2,0)(1,2)(1.5,3)(2,2)(1,0)
\end{pspicture}

\end{document}

Outer uses \pscustom[fill...] so older objects disapeare. Inner is more 
robust but when path cross, there is some additional work for human!

   Jean-Côme Charpentier




More information about the PSTricks mailing list