%%
%% This is file `pst-poly.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pst-poly.dtx  (with options: `pst-poly')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from pst-poly.tex.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file pst-poly.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%%
%% Package `pst-poly.dtx'
%%
%% Denis Girou (CNRS/IDRIS - France) <Denis.Girou@idris.fr>
%% Herbert Voss <voss _at_ pstricks.de>
%%
%% Novermber 20, 2004
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-poly' is a PSTricks package to draw easily various kinds of regular
%%   or non regular polygons, with various customizations.
%%
\def\fileversion{1.60}
\def\filedate{2004/11/20}
\message{`PST-Polygon' v\fileversion, \filedate\space (DG/hv)}
\csname PSTPolygonLoaded\endcsname
\let\PSTPolygonLoaded\endinput
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node.tex\fi
\ifx\MultidoLoaded\endinput\else\input multido.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi
\edef\PstAtCode{\the\catcode`\@}
\catcode`\@=11\relax
\pst@addfams{pst-poly}
\newif\ifPst@PstPicture
\define@key[psset]{pst-poly}{PstPicture}[true]{\@nameuse{Pst@PstPicture#1}}
\define@key[psset]{pst-poly}{PolyRotation}{\edef\PstPoly@Rotation{#1}}
\define@key[psset]{pst-poly}{PolyNbSides}{\pst@getint{#1}{\PstPoly@NbSides}}
\define@key[psset]{pst-poly}{PolyOffset}{\pst@getint{#1}{\PstPoly@Offset}}
\newdimen\PstPoly@IntermediatePointDim
\define@key[psset]{pst-poly}{PolyIntermediatePoint}{\edef\PstPoly@IntermediatePoint{#1}}
\define@key[psset]{pst-poly}{PolyName}{\edef\PstPoly@Name{#1}}
\newif\ifPstPoly@Curves
\define@key[psset]{pst-poly}{PolyCurves}[true]{\@nameuse{PstPoly@Curves#1}}
\newif\ifPstPoly@Epicycloid
\define@key[psset]{pst-poly}{PolyEpicycloid}[true]{\@nameuse{PstPoly@Epicycloid#1}}
\psset{%
  PstPicture=true,PolyRotation=0,PolyNbSides=5,PolyOffset=1,
  PolyIntermediatePoint=,PolyName=,PolyCurves=false,PolyEpicycloid=false}
\def\PstPolygon{\pst@ifstar{\@ifnextchar[{\PstPolygon@i}{\PstPolygon@i[]}}}
\def\PstPolygon@i[#1]{{%
\psset{#1}%
\if@star\solid@star\fi
\ifnum\PstPoly@NbSides<3
  \@pstrickserr{PolyNbSides must be greater than 2
                (and not `\PstPoly@NbSides')}{\@eha}%
\fi
\ifnum\PstPoly@NbSides>200
  \@pstrickserr{PolyNbSides must be less than 201
                (and not `\PstPoly@NbSides')}{\@eha}%
\fi
\ifnum\PstPoly@Offset<1
  \@pstrickserr{PolyOffset must be greater than 0
                (and not `\PstPoly@Offset')}{\@eha}%
\fi
\ifodd\PstPoly@Offset
  \def\PstPoly@Decimal{.5}%
\else
  \def\PstPoly@Decimal{}%
\fi
\SpecialCoor
\ifPst@PstPicture\pspicture(-1,-1)(1,1)\fi
\rput{\PstPoly@Rotation}(0,0){%
  \degrees[\PstPoly@NbSides]
  \pssetlength{\PstPoly@IntermediatePointDim}{\PstPoly@IntermediatePoint}
  \ifx\PstPoly@Name\@empty
  \else
    \pnode(0,0){\PstPoly@Name 0}
    \ifnum\psxunit=\psyunit
      \def\PstPoly@Node{\pnode(1;\i)}%
    \else
      \def\PstPoly@Node{%
        \pnode(! \i\space 360 \PstPoly@NbSides\space div mul cos
                 \i\space 360 \PstPoly@NbSides\space div mul sin)}%
    \fi
    \multido{\i=0+1}{\PstPoly@NbSides}{%
      \PstPoly@Node{\PstPoly@Name\the\multidocount}}
  \fi
  \pscustom{%
    \ifPstPoly@Epicycloid
      \pst@cnta=\PstPoly@NbSides
      \divide\pst@cnta\tw@
      \multido{\i=0+1}{\PstPoly@NbSides}{%
        \moveto(1;\i)
        \lineto(1;\the\pst@cnta)
        \advance\pst@cnta\PstPoly@Offset}
    \else
      \ifnum\psxunit=\psyunit
        \moveto(1,0)
      \else
        \moveto(! 1 0)
      \fi
      \ifx\PstPoly@IntermediatePoint\@empty
        \ifnum\psxunit=\psyunit
          \def\PstPoly@Junction{\lineto(1;\i)}%
        \else
          \def\PstPoly@Junction{\lineto%
            (! \i\space 360 \PstPoly@NbSides\space div mul cos
               \i\space 360 \PstPoly@NbSides\space div mul sin)}%
        \fi
        \multido{\i=\PstPoly@Offset+\PstPoly@Offset}{\PstPoly@NbSides}{%
          \PstPoly@Junction}
      \else
        \ifPstPoly@Curves
          \let\PstPoly@JunctionType\pscurve
        \else
          \let\PstPoly@JunctionType\psline
        \fi
        \ifnum\psxunit=\psyunit
          \def\PstPoly@Junction{\PstPoly@JunctionType%
            (\PstPoly@IntermediatePointDim;\the\pst@cnta\PstPoly@Decimal)
            (1;\i)}%
        \else
          \def\PstPoly@Junction{\PstPoly@JunctionType%
            (! \PstPoly@IntermediatePoint\space
                 \the\pst@cnta\PstPoly@Decimal\space 360
                   \PstPoly@NbSides\space div mul cos mul
               \PstPoly@IntermediatePoint\space
                 \the\pst@cnta\PstPoly@Decimal\space 360
                   \PstPoly@NbSides\space div mul sin mul)
            (! \i\space 360 \PstPoly@NbSides\space div mul cos
               \i\space 360 \PstPoly@NbSides\space div mul sin)}%
        \fi
        \pst@cnta=\PstPoly@Offset
        \divide\pst@cnta\tw@
        \multido{\i=\PstPoly@Offset+\PstPoly@Offset}{\PstPoly@NbSides}{%
          \PstPoly@Junction
          \advance\pst@cnta\PstPoly@Offset}
      \fi
    \fi}
  \ifx\PstPolygonNode\@undefined
  \else
    \multido{\INode=\z@+\PstPoly@Offset}{\PstPoly@NbSides}{%
      \PstPolygonNode}
  \fi}
\ifPst@PstPicture
  \endpspicture
\fi}}
\def\PstTriangle{%
\pst@ifstar{\@ifnextchar[{\PstTriangle@i}{\PstTriangle@i[]}}}
\def\PstTriangle@i[#1]{{%
\psset{PolyNbSides=3,PolyRotation=90}% For triangle (360/3*(3/4))
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstSquare{%
\pst@ifstar{\@ifnextchar[{\PstSquare@i}{\PstSquare@i[]}}}
\def\PstSquare@i[#1]{{%
\psset{PolyNbSides=4,PolyRotation=45}% For square (360/4/2)
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstPentagon{%
\pst@ifstar{\@ifnextchar[{\PstPentagon@i}{\PstPentagon@i[]}}}
\def\PstPentagon@i[#1]{{%
\psset{PolyNbSides=5,PolyRotation=18}% For pentagon (360/5/4)
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstHexagon{%
\pst@ifstar{\@ifnextchar[{\PstHexagon@i}{\PstHexagon@i[]}}}
\def\PstHexagon@i[#1]{{%
\psset{PolyNbSides=6}%
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstHeptagon{%
\pst@ifstar{\@ifnextchar[{\PstHeptagon@i}{\PstHeptagon@i[]}}}
\def\PstHeptagon@i[#1]{{%
\psset{PolyNbSides=7,PolyRotation=38.57}% For heptagon (360/7*(3/4))
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstOctogon{%
\pst@ifstar{\@ifnextchar[{\PstOctogon@i}{\PstOctogon@i[]}}}
\def\PstOctogon@i[#1]{{%
\psset{PolyNbSides=8,PolyRotation=22.5}% For octogon (360/8/2)
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstNonagon{%
\pst@ifstar{\@ifnextchar[{\PstNonagon@i}{\PstNonagon@i[]}}}
\def\PstNonagon@i[#1]{{%
\psset{PolyNbSides=9,PolyRotation=10}% For nonagon (360/9/4)
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstDecagon{%
\pst@ifstar{\@ifnextchar[{\PstDecagon@i}{\PstDecagon@i[]}}}
\def\PstDecagon@i[#1]{{%
\psset{PolyNbSides=10}%
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstDodecagon{%
\pst@ifstar{\@ifnextchar[{\PstDodecagon@i}{\PstDodecagon@i[]}}}
\def\PstDodecagon@i[#1]{{%
\psset{PolyNbSides=12,PolyRotation=15}% For dodecagon (360/12/2)
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstStarFiveLines{%
\pst@ifstar{\@ifnextchar[{\PstStarFiveLines@i}{\PstStarFiveLines@i[]}}}
\def\PstStarFiveLines@i[#1]{{%
\psset{PolyOffset=2,PolyRotation=18}%
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstStarFive{%
\pst@ifstar{\@ifnextchar[{\PstStarFive@i}{\PstStarFive@i[]}}}
\def\PstStarFive@i[#1]{{%
\psset{PolyIntermediatePoint=0.38,PolyRotation=18}%
\psset{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\newdimen\pst@dimm
\newdimen\pst@dimn
\newdimen\pst@dimo
\newdimen\pst@dimp
\def\pspolygonbox{\pst@object{pspolygonbox}}%   voss 2004-11-20
\def\pspolygonbox@i{\pst@makebox\pspolygonbox@ii}
\def\pspolygonbox@ii{{%
   \begingroup%
   \pst@useboxpar%
   \pst@dima=\pslinewidth%
   \ifpsdoubleline%
     \advance\pst@dima by \psdoublesep\pslinewidth%
     \advance\pst@dima by \pslinewidth%
   \fi%
   \advance\pst@dima by \psframesep%
   \pst@dimc=\wd\pst@hbox%
   \pst@dimp=\pst@dimc\advance\pst@dimp by 2\pst@dima%
   \pst@dimb=\dp\pst@hbox\pst@dimo=\pst@dimb%
   \pst@dimd=\ht\pst@hbox\advance\pst@dimo by \pst@dimd% totalheight
   \pst@pyth\pst@dimp\pst@dimo\pst@dimm%
   \divide\pst@dimm by 2% Radius
   \setbox\pst@hbox=\hbox{%
     \ifpsboxsep\kern\pst@dima\fi% left side
     \begin@ClosedObj%
       \addto@pscode{%
         /framesep \pst@number\pst@dima def
 /boxdepth \pst@number\pst@dimb framesep add def
         /boxheight0 \pst@number\pst@dimd def
         /boxheight boxheight0 framesep add def
         /boxwidth \pst@number\pst@dimc def
         /radius \pst@number\pst@dimm def
         /order \PstPoly@NbSides\space def
         /dAlpha 360 order div def
 /alpha \PstPoly@Rotation\space def
         \pst@cp
 \tx@polygonB
 \psline@iii
%%  \tx@Line
 \tx@Polygon
       }%
       \def\pst@linetype{1}%
       \showpointsfalse%
     \end@ClosedObj%
     \box\pst@hbox%
     \ifpsboxsep\kern\pst@dima\fi%% right side
   }%
   \ifpsboxsep%
     \pst@dimn=-.5\pst@dimo\advance\pst@dimn by \pst@dimb%
     \advance\pst@dimn by 0.809\pst@dimm%
     \dp\pst@hbox=\pst@dimn%
     \pst@dimn=\pst@dimm\advance\pst@dimn by 0.5\pst@dimo%
     \advance\pst@dimn by -\pst@dimb%
     \ht\pst@hbox=\pst@dimn\fi%
   \leavevmode%
   \box\pst@hbox%
   \endgroup%
}\ignorespaces}
\pst@def{polygonB}<{%
  /x1 framesep neg def
  /x2 boxwidth framesep add def
  /y1 boxdepth framesep add neg def
  /y2 boxheight framesep add def
  x2 x1 add 2 div y2 y1 add 2 div translate
  [
  alpha cos radius mul
  alpha sin radius mul
  order { /alpha alpha dAlpha add def
    radius alpha cos mul
    radius alpha sin mul
  } repeat
}>
\catcode`\@=\PstAtCode\relax
\endinput
%%
%% End of file `pst-poly.tex'.
