%%
%% 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>
%%
%% February 19, 2001
%%
%% 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.5}
\def\filedate{2001/02/19}
\message{`PST-Polygon' v\fileversion, \filedate\space (Denis Girou)}
\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
\input pst-key.tex
\edef\PstAtCode{\the\catcode`\@}
\catcode`\@=11\relax
\newif\ifPst@PstPicture
\define@key{psset}{PstPicture}[true]{\@nameuse{Pst@PstPicture#1}}
\define@key{psset}{PolyRotation}{\edef\PstPoly@Rotation{#1}}
\define@key{psset}{PolyNbSides}{\pst@getint{#1}{\PstPoly@NbSides}}
\define@key{psset}{PolyOffset}{\pst@getint{#1}{\PstPoly@Offset}}
\newdimen\PstPoly@IntermediatePointDim
\define@key{psset}{PolyIntermediatePoint}{\edef\PstPoly@IntermediatePoint{#1}}
\define@key{psset}{PolyName}{\edef\PstPoly@Name{#1}}
\newif\ifPstPoly@Curves
\define@key{psset}{PolyCurves}[true]{\@nameuse{PstPoly@Curves#1}}
\newif\ifPstPoly@Epicycloid
\define@key{psset}{PolyEpicycloid}[true]{\@nameuse{PstPoly@Epicycloid#1}}
\setkeys{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]{{%
\setkeys{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]{{%
\setkeys{psset}{PolyNbSides=3,PolyRotation=90}% For triangle (360/3*(3/4))
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstSquare{%
\pst@ifstar{\@ifnextchar[{\PstSquare@i}{\PstSquare@i[]}}}
\def\PstSquare@i[#1]{{%
\setkeys{psset}{PolyNbSides=4,PolyRotation=45}% For square (360/4/2)
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstPentagon{%
\pst@ifstar{\@ifnextchar[{\PstPentagon@i}{\PstPentagon@i[]}}}
\def\PstPentagon@i[#1]{{%
\setkeys{psset}{PolyNbSides=5,PolyRotation=18}% For pentagon (360/5/4)
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstHexagon{%
\pst@ifstar{\@ifnextchar[{\PstHexagon@i}{\PstHexagon@i[]}}}
\def\PstHexagon@i[#1]{{%
\setkeys{psset}{PolyNbSides=6}%
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstHeptagon{%
\pst@ifstar{\@ifnextchar[{\PstHeptagon@i}{\PstHeptagon@i[]}}}
\def\PstHeptagon@i[#1]{{%
\setkeys{psset}{PolyNbSides=7,PolyRotation=38.57}% For heptagon (360/7*(3/4))
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstOctogon{%
\pst@ifstar{\@ifnextchar[{\PstOctogon@i}{\PstOctogon@i[]}}}
\def\PstOctogon@i[#1]{{%
\setkeys{psset}{PolyNbSides=8,PolyRotation=22.5}% For octogon (360/8/2)
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstNonagon{%
\pst@ifstar{\@ifnextchar[{\PstNonagon@i}{\PstNonagon@i[]}}}
\def\PstNonagon@i[#1]{{%
\setkeys{psset}{PolyNbSides=9,PolyRotation=10}% For nonagon (360/9/4)
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstDecagon{%
\pst@ifstar{\@ifnextchar[{\PstDecagon@i}{\PstDecagon@i[]}}}
\def\PstDecagon@i[#1]{{%
\setkeys{psset}{PolyNbSides=10}%
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstDodecagon{%
\pst@ifstar{\@ifnextchar[{\PstDodecagon@i}{\PstDodecagon@i[]}}}
\def\PstDodecagon@i[#1]{{%
\setkeys{psset}{PolyNbSides=12,PolyRotation=15}% For dodecagon (360/12/2)
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstStarFiveLines{%
\pst@ifstar{\@ifnextchar[{\PstStarFiveLines@i}{\PstStarFiveLines@i[]}}}
\def\PstStarFiveLines@i[#1]{{%
\setkeys{psset}{PolyOffset=2,PolyRotation=18}%
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\def\PstStarFive{%
\pst@ifstar{\@ifnextchar[{\PstStarFive@i}{\PstStarFive@i[]}}}
\def\PstStarFive@i[#1]{{%
\setkeys{psset}{PolyIntermediatePoint=0.38,PolyRotation=18}%
\setkeys{psset}{#1}%
\if@star\solid@star\fi
\PstPolygon}}
\catcode`\@=\PstAtCode\relax
\endinput
%%
%% End of file `pst-poly.tex'.
