summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex300
1 files changed, 295 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex
index 2c777ef5504..a6965b60e3b 100644
--- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex
+++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex
@@ -1,10 +1,13 @@
-\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.code.tex,v 1.5 2005/10/13 10:12:31 tantau Exp $
-
-% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>.
+% Copyright 2006 by Till Tantau
+%
+% This file may be distributed and/or modified
%
-% This program can be redistributed and/or modified under the terms
-% of the GNU Public License, version 2.
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.code.tex,v 1.9 2006/10/11 15:22:26 tantau Exp $
\pgfdeclareshape{ellipse}
%
@@ -191,6 +194,293 @@
}
+
+
+% Set the recommended shape aspect ratio
+%
+% #1 = aspect ratio
+%
+% Example:
+%
+% \pgfsetshapeminwidth{1.5}
+
+\def\pgfsetshapeaspect#1{%
+ \def\pgfshapeaspect{#1}%
+ % Invert
+ \@tempdima=#1pt%
+ \@tempdima=.125\@tempdima%
+ \c@pgf@counta=\@tempdima\relax% 8192*determinant
+ \@tempdima=8192pt%
+ \divide\@tempdima by\c@pgf@counta%
+ \edef\pgfshapeaspectinverse{\pgf@sys@tonumber{\@tempdima}}
+}
+\pgfsetshapeaspect{1}
+
+
+
+\pgfdeclareshape{diamond}
+{
+ \savedanchor\outernortheast{%
+ %
+ % Calculate width and height of the inner rectangle
+ %
+ \pgf@xa=.5\wd\pgfnodeparttextbox%
+ \setlength\pgf@xc{\pgfshapeinnerxsep}%
+ \advance\pgf@xa by\pgf@xc%
+ \pgf@ya=.5\ht\pgfnodeparttextbox%
+ \advance\pgf@ya by.5\dp\pgfnodeparttextbox%
+ \setlength\pgf@yc{\pgfshapeinnerysep}%
+ \advance\pgf@ya by\pgf@yc%
+ %
+ % Calculate width and height of diamond
+ %
+ \pgf@x=\pgf@xa%
+ \advance\pgf@x by\pgfshapeaspect\pgf@ya%
+ \pgf@y=\pgfshapeaspectinverse\pgf@xa%
+ \advance\pgf@y by\pgf@ya%
+ %
+ % Check against minimum height/width
+ %
+ \setlength\pgf@xb{\pgfshapeminwidth}%
+ \ifdim\pgf@x<\pgf@xb%
+ % yes, too small. Enlarge...
+ \pgf@x=\pgf@xb%
+ \fi%
+ \setlength\pgf@yb{\pgfshapeminheight}%
+ \ifdim\pgf@y<\pgf@yb%
+ % yes, too small. Enlarge...
+ \pgf@y=\pgf@yb%
+ \fi%
+ %
+ % Add outer border
+ %
+ \setlength\pgf@xa{\pgfshapeouterxsep}%
+ \advance\pgf@x by\pgf@xa%
+ \setlength\pgf@ya{\pgfshapeouterysep}%
+ \advance\pgf@y by\pgf@ya%
+ }
+ \savedanchor\text{%
+ \pgf@x=-.5\wd\pgfnodeparttextbox%
+ \pgf@y=-.5\ht\pgfnodeparttextbox%
+ \advance\pgf@y by.5\dp\pgfnodeparttextbox%
+ }
+
+ %
+ % Anchors
+ %
+ \anchor{text}{\text}%
+ \anchor{center}{\pgfpointorigin}%
+ \anchor{mid}{%
+ \pgf@process{\text}%
+ \pgf@x=0pt%
+ \setlength\pgf@ya{.5ex}
+ \advance\pgf@y by\pgf@ya%
+ }
+ \anchor{base}{\pgf@process{\text}\pgf@x=0pt }
+ \anchor{north}{\pgf@process{\outernortheast}\pgf@x=0pt}
+ \anchor{south}{\pgf@process{\outernortheast}\pgf@x=0pt\pgf@y=-\pgf@y}
+ \anchor{west}{\pgf@process{\outernortheast}\pgf@x=-\pgf@x\pgf@y=0pt}
+ \anchor{north west}{\pgf@process{\outernortheast}\pgf@x=-.5\pgf@x\pgf@y=.5\pgf@y}
+ \anchor{south west}{\pgf@process{\outernortheast}\pgf@x=-.5\pgf@x\pgf@y=-.5\pgf@y}
+ \anchor{east}{\pgf@process{\outernortheast}\pgf@y=0pt}
+ \anchor{north east}{\pgf@process{\outernortheast}\pgf@x=.5\pgf@x\pgf@y=.5\pgf@y}
+ \anchor{south east}{\pgf@process{\outernortheast}\pgf@x=.5\pgf@x\pgf@y=-.5\pgf@y}
+ \anchorborder{%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\outernortheast}%
+ \ifdim\pgf@xa>0pt%
+ \else%
+ \pgf@x=-\pgf@x%
+ \fi%
+ \ifdim\pgf@ya>0pt%
+ \else%
+ \pgf@y=-\pgf@y%
+ \fi%
+ \edef\pgf@marshal{%
+ \noexpand\pgfpointintersectionoflines
+ {\noexpand\pgfpointorigin}
+ {\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}
+ {\noexpand\pgfpoint{\the\pgf@x}{0pt}}
+ {\noexpand\pgfpoint{0pt}{\the\pgf@y}}%
+ }%
+ \pgf@process{\pgf@marshal}%
+ }
+
+ %
+ % Background path
+ %
+ \backgroundpath{
+ \pgf@process{\outernortheast}%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \setlength{\pgf@xa}{\pgfshapeouterxsep}%
+ \setlength{\pgf@ya}{\pgfshapeouterysep}%
+ \advance\pgf@xc by-1.414213\pgf@xa%
+ \advance\pgf@yc by-1.414213\pgf@ya%
+ \pgfpathmoveto{\pgfpoint{\pgf@xc}{0pt}}%
+ \pgfpathlineto{\pgfpoint{0pt}{\pgf@yc}}%
+ \pgfpathlineto{\pgfpoint{-\pgf@xc}{0pt}}%
+ \pgfpathlineto{\pgfpoint{0pt}{-\pgf@yc}}%
+ \pgfpathclose%
+ }
+}
+
+
+
+\newbox\pgfnodepartlowerbox
+
+%
+% A circle that is split in the middle into an upper and a lower part.
+%
+% This node consists of two parts: The upper (main) part is shown in
+% the upper half of the circle. The second part is the (optional)
+% lower part.
+%
+% Parts: text, lower
+
+\pgfdeclareshape{circle split}
+{
+ %
+ % Node parts
+ %
+ \nodeparts{text,lower}
+
+ %
+ % Anchors
+ %
+ \savedanchor\centerpoint{%
+ \pgf@x=.5\wd\pgfnodeparttextbox%
+ \setlength{\pgf@y}{\pgfshapeinnerysep}%
+ \pgf@y=-\pgf@y%
+ \advance\pgf@y by-\dp\pgfnodeparttextbox%
+ \advance\pgf@y by-.5\pgflinewidth%
+ }%
+ \savedanchor\loweranchor{%
+ \pgf@x=-.5\wd\pgfnodepartlowerbox%
+ \advance\pgf@x by.5\wd\pgfnodeparttextbox%
+ \setlength{\pgf@y}{\pgfshapeinnerysep}%
+ \pgf@y=-2\pgf@y%
+ \advance\pgf@y by-\ht\pgfnodepartlowerbox%
+ \advance\pgf@y by-.5\pgflinewidth%
+ \advance\pgf@y by-\dp\pgfnodeparttextbox%
+ \advance\pgf@y by-.5\pgflinewidth%
+ }
+
+ \saveddimen\radius{%
+ %
+ % Caculate ``height radius''
+ %
+ \pgf@ya=.5\ht\pgfnodeparttextbox%
+ \advance\pgf@ya by.5\dp\pgfnodeparttextbox%
+ \advance\pgf@ya by.5\ht\pgfnodepartlowerbox%
+ \advance\pgf@ya by.5\dp\pgfnodepartlowerbox%
+ \advance\pgf@ya by.5\pgflinewidth%
+ \setlength\pgf@yb{\pgfshapeinnerysep}%
+ \advance\pgf@ya by2\pgf@yb%
+ %
+ % Caculate ``width radius''
+ %
+ \pgf@xa=.5\wd\pgfnodeparttextbox%
+ \ifdim\pgf@xa<.5\wd\pgfnodepartlowerbox%
+ \pgf@xa=.5\wd\pgfnodepartlowerbox%
+ \fi%
+ \setlength\pgf@xb{\pgfshapeinnerxsep}%
+ \advance\pgf@xa by\pgf@xb%
+ %
+ % Calculate length of radius vector:
+ %
+ \pgf@process{\pgfpointnormalised{\pgfpoint{\pgf@xa}{\pgf@ya}}}%
+ \ifdim\pgf@x>\pgf@y%
+ \c@pgf@counta=\pgf@x%
+ \ifnum\c@pgf@counta=0\relax%
+ \else%
+ \divide\c@pgf@counta by 255\relax%
+ \pgf@xa=16\pgf@xa\relax%
+ \divide\pgf@xa by\c@pgf@counta%
+ \pgf@xa=16\pgf@xa\relax%
+ \fi%
+ \else%
+ \c@pgf@counta=\pgf@y%
+ \ifnum\c@pgf@counta=0\relax%
+ \else%
+ \divide\c@pgf@counta by 255\relax%
+ \pgf@ya=16\pgf@ya\relax%
+ \divide\pgf@ya by\c@pgf@counta%
+ \pgf@xa=16\pgf@ya\relax%
+ \fi%
+ \fi%
+ \pgf@x=\pgf@xa%
+ %
+ % If necessary, adjust radius so that the size requirements are
+ % met:
+ %
+ \setlength{\pgf@xb}{\pgfshapeminwidth}%
+ \setlength{\pgf@yb}{\pgfshapeminheight}%
+ \ifdim\pgf@x<.5\pgf@xb%
+ \pgf@x=.5\pgf@xb%
+ \fi%
+ \ifdim\pgf@x<.5\pgf@yb%
+ \pgf@x=.5\pgf@yb%
+ \fi%
+ %
+ % Now, add larger of outer sepearations.
+ %
+ \setlength{\pgf@xb}{\pgfshapeouterxsep}%
+ \setlength{\pgf@yb}{\pgfshapeouterysep}%
+ \ifdim\pgf@xb<\pgf@yb%
+ \advance\pgf@x by\pgf@yb%
+ \else%
+ \advance\pgf@x by\pgf@xb%
+ \fi%
+ }
+
+ %
+ % Anchors
+ %
+ \inheritanchorborder[from=circle]
+ \inheritanchor[from=circle]{north}
+ \inheritanchor[from=circle]{north west}
+ \inheritanchor[from=circle]{north east}
+ \inheritanchor[from=circle]{center}
+ \inheritanchor[from=circle]{west}
+ \inheritanchor[from=circle]{east}
+ \inheritanchor[from=circle]{mid}
+ \inheritanchor[from=circle]{mid west}
+ \inheritanchor[from=circle]{mid east}
+ \inheritanchor[from=circle]{base}
+ \inheritanchor[from=circle]{base west}
+ \inheritanchor[from=circle]{base east}
+ \inheritanchor[from=circle]{south}
+ \inheritanchor[from=circle]{south west}
+ \inheritanchor[from=circle]{south east}
+ \anchor{lower}{\loweranchor}
+
+ %
+ % Background path
+ %
+ \inheritbackgroundpath[from=circle]
+ \beforebackgroundpath{
+ \@tempdima=\radius%
+ \setlength{\pgf@xb}{\pgfshapeouterxsep}%
+ \setlength{\pgf@yb}{\pgfshapeouterysep}%
+ \ifdim\pgf@xb<\pgf@yb%
+ \advance\@tempdima by-\pgf@yb%
+ \else%
+ \advance\@tempdima by-\pgf@xb%
+ \fi%
+ \advance\@tempdima by-.5\pgflinewidth%
+ \pgfsetshortenstart{0pt}%
+ \pgfsetshortenend{0pt}%
+ \pgfsetarrows{-}%
+ \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfpoint{-\@tempdima}{0pt}}}%
+ \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfpoint{\@tempdima}{0pt}}}%
+ \pgfusepath{stroke}%
+ }
+}
+
+
+
\pgfdeclareshape{cross out}
{
\inheritsavedanchors[from=rectangle] % this is nearly a rectangle