summaryrefslogtreecommitdiff
path: root/info/examples/lgc2/5-15-5.ltx
blob: 69c353539c355767d29b5abf1afeab04b969c011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
%% 
%%  The LaTeX Graphics Companion, 2ed (first printing May 2007)
%% 
%%  Example 5-15-5 on page 308.
%% 
%%  Copyright (C) 2007 Michel Goossens, Frank Mittelbach, Denis Roegel, Sebastian Rahtz, Herbert Vo\ss 
%% 
%%  It may be distributed and/or modified under the conditions
%%  of the LaTeX Project Public License, either version 1.3
%%  of this license or (at your option) any later version.
%% 
%%  See http://www.latex-project.org/lppl.txt for details.
%% 

\documentclass{ttctexa}
\pagestyle{empty}
\setcounter{page}{6}
\setlength\textwidth{159.83385pt}
%
\usepackage{pst-xkey}
\makeatletter
\newif\ifHRInner
\def\psset@HRInner#1{\@nameuse{HRInner#1}}
\psset@HRInner{false}
%
\def\psHexagon{\pst@object{psHexagon}}
\def\psHexagon@i{%
    \@ifnextchar({\psHexagon@ii}{\psHexagon@ii(0,0)}% specify center? )
}
\def\psHexagon@ii(#1)#2{%
  \begin@ClosedObj%                    closed object
    \pst@@getcoor{#1}%                 get center
    \pssetlength\pst@dimc{#2}%         set radius to pt
    \addto@pscode{%                    PostScript
      \pst@coor T %                    xM yM new origin
      \psk@dimen CLW mul %             set line width
      /Radius \pst@number\pst@dimc\space % save radius
        \ifHRInner\space 3 sqrt 2 div div \fi def % inner?
      /angle \ifHRInner 30 \else 0 \fi def % starting angle
      Radius angle PtoC moveto %       go to first point
      6 { %                            6 iterations
        /angle angle 60 add def %      alpha = alpha+60
        Radius angle PtoC L %          line to next point
      } repeat
      closepath %                      closed object
    }%
    \def\pst@linetype{3}%              set linetype
    \showpointsfalse%                  do not show base points
  \end@ClosedObj%                      end
  \ignorespaces%                       swallow spaces
}
\makeatother

\StartShownPreambleCommands
\usepackage{pstricks}
% \psHexagon as defined above
\StopShownPreambleCommands
\begin{document}
\psset{unit=7mm}
\begin{pspicture}(-3,-3)(3,3)
  \psHexagon[linewidth=3pt,linecolor=red]{2.5}
  \pscircle[linestyle=dashed,linecolor=red]{2.5}
%
  \psHexagon[linewidth=3pt,linecolor=blue,%
    HRInner=true]{2.5}
  \pscircle[linestyle=dashed,linecolor=blue]{2.17}
\end{pspicture}
\end{document}