diff options
author | Karl Berry <karl@freefriends.org> | 2008-02-24 18:22:07 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-02-24 18:22:07 +0000 |
commit | ac768be5ab2e638802806ac364ca4402e8e9935e (patch) | |
tree | bf26e0d972206f02cda2535e35dd8c2a33c04eaa /Master/texmf-dist/tex/generic/pgf/basiclayer | |
parent | bc195e7c0fe9d96cd9b6c0230da50da6fc28de26 (diff) |
pgf 2.0, third try
git-svn-id: svn://tug.org/texlive/trunk@6747 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/basiclayer')
12 files changed, 5549 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex new file mode 100644 index 00000000000..b76772cc4ac --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex @@ -0,0 +1,32 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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. + +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcore.code.tex,v 1.6 2008/01/15 10:27:34 tantau Exp $ + +\newif\ifpgf@draftmode + +\input pgfmath.code.tex + +\input pgfcorepoints.code.tex +\input pgfcorepathconstruct.code.tex +\input pgfcorepathusage.code.tex +\input pgfcorescopes.code.tex +\input pgfcoregraphicstate.code.tex +\input pgfcoretransformations.code.tex +\input pgfcorequick.code.tex +\input pgfcoreobjects.code.tex +\input pgfcorepathprocessing.code.tex +\input pgfcorearrows.code.tex +\input pgfcoreshade.code.tex +\input pgfcoreimage.code.tex +\input pgfcorelayers.code.tex +\input pgfcoretransparency.code.tex +\input pgfcorepatterns.code.tex + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.code.tex new file mode 100644 index 00000000000..bdf4906c1be --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.code.tex @@ -0,0 +1,513 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorearrows.code.tex,v 1.8 2007/06/07 07:41:10 tantau Exp $ + + +% Sets the end arrow +% +% #1 = An arrow name +% +% Example: +% +% \pgfsetarrowsend{stealth} + +\def\pgfsetarrowsend#1{\pgf@arrowset{end}{#1}} +\def\pgf@arrowset#1#2{% + \pgfutil@ifundefined{pgf@arrow@code@#2} + {\PackageError{pgf}{Arrow #1 type ``#2'' unknown}{}} + {% + \edef\pgf@arrow@temp{#2}% + \ifx\pgf@arrow@temp\pgfutil@empty% ah. clear! + \expandafter\let\csname pgf@#1arrow\endcsname=\pgfutil@empty% + \expandafter\let\csname pgf@shorten@#1\endcsname=\pgfutil@empty% + \else% + %\pgf@arrow@prepare{#2}% + \expandafter\def\csname pgf@#1arrow\endcsname{\pgf@arrow@call{#2}}% + \expandafter\edef\csname pgf@shorten@#1\endcsname{\expandafter\noexpand\csname pgf@arrow@right@#2\endcsname}% + \fi% + }% +} + + +% Sets the start arrow +% +% #1 = An arrow name +% +% Example: +% +% \pgfsetarrowsstart{stealth} + +\def\pgfsetarrowsstart#1{\pgf@arrowset{start}{\csname pgf@arrows@invert#1\endcsname}} + +\def\pgf@arrows@invname#1#2{\expandafter\def\csname pgf@arrows@invert#1\endcsname{#2}} +\pgf@arrows@invname{}{} + + + + +% Sets arrows +% +% #1 = An arrow specification of the form ``left''-``right''. The last +% and right should be arrow types that have been defined using +% the \pgfarrowsdef command +% +% Example: +% +% \pgfsetarrows{-to} + +\def\pgfsetarrows#1{\pgf@arrows#1\pgf@stop} +\def\pgf@arrows#1-#2\pgf@stop{% + \pgfsetarrowsstart{#1} + \pgfsetarrowsend{#2} +} + +\def\pgf@arrows@checked#1#2#3{% + \pgfutil@ifundefined{pgf@arrow@code@#2}% + {% + \PackageError{pgf}{Arrow end type ``#2'' unknown}{}}% + {% + \pgfutil@ifundefined{pgf@arrow@code@\csname pgf@arrows@invert#1\endcsname} + {\PackageError{pgf}{Arrow start type ``#1'' unknown}{}}% + {#3}% + }% +} + +\def\pgf@arrows@check@already#1#2#3{% + \pgfutil@ifundefined{pgf@arrow@code@#2} + {#3}% + {\PackageError{pgf}{Arrow end type ``#2'' already defined}{}}% +} + + +% Called when an arrow needs to be rendered + +\def\pgf@arrow@call#1{% + \expandafter\ifx\csname pgf@arrow@prot@#1@\the\pgflinewidth\endcsname\relax% + \pgfsysprotocol@getcurrentprotocol\pgf@arrow@temp% + {% + \pgfinterruptpath% + \let\pgfusepath=\pgf@nousepath@here% + \pgf@relevantforpicturesizefalse% + \pgftransformreset% + \pgfsysprotocol@setcurrentprotocol\pgfutil@empty% + \pgfsysprotocol@bufferedtrue% + \pgfsys@beginscope% + \csname pgf@arrow@code@#1\endcsname% + \pgfsys@endscope% + \pgfsysprotocol@getcurrentprotocol\pgf@@arrow@temp% + \global\let\pgf@@arrow@temp=\pgf@@arrow@temp% + \endpgfinterruptpath% + \expandafter\def\expandafter\pgf@temp\expandafter{\expandafter\pgfsys@invoke\expandafter{\pgf@@arrow@temp}}% + \expandafter\global\expandafter\let\csname pgf@arrow@prot@#1@\the\pgflinewidth\endcsname=\pgf@temp% + }% + \pgfsysprotocol@setcurrentprotocol\pgf@arrow@temp% + \fi% + \csname pgf@arrow@prot@#1@\the\pgflinewidth\endcsname% +} + +\def\pgf@arrow@code@{} % dummy + +\def\pgf@nousepath@here#1{% + \PackageError{pgf}{The definition of an arrow may not use \string\pgfusepath}{} +} + + + +% Define an arrow type. +% +% #1 = name or mnemonic for arrow when used at the start (examples: ``to'' or ``<'') +% #2 = name or mnemonic for arrow when used at the end (examples: ``to'' or ``>'') +% #3 = code to setup the left and right extend of the arrow. To set +% the left extend, call \pgfarrowsleftextend, for the right \pgfarrowsrightextend. +% #4 = protocolable code +% +% Description: +% +% When you define an arrow using this command, you must give two +% names. The first is used for the arrow when it is ``at the start'', +% the other when it is at the end. For example, a simple arrow might +% have the names ``<'' and ``>'', though these particular names are +% not used by pgf and left for the user. +% +% The code should be ``protocolable'' code. This means that it uses +% only pretty simple commands. +% +% The arrow code will be protocolled once for each line width at which +% the arrow is used. Thus, the code can (and often should) depend on +% the line width. +% +% The arrow should ``point right'' in the coordinate system. The end +% of the line at which the arrow should be drawn will be at the origin +% of the coordinate system. The coordinate system will be scaled and +% rotated appropriately before the arrow is drawn. +% +% The right extend of the arrow should be set to how much the arrow +% ``protrudes over the right''. Prior to drawing the arrow, the line +% will be shortened by this amount so that the arrow tip will exactly +% touch the original right end of the unshortened line. +% +% The left extend specifies the leftmost point of the arrow. This is +% important only if you use the swapping command, when this end is +% used to compute the shortening. +% +% The definition of an arrow should normally take care of the fact +% that the line cap of the main line may be a butt cap, a round cap or +% a rect cap. In all cases, the arrow should ``cover'' the cap +% completely or not at all. +% +% Example: +% +% \pgfarrowsdeclare{stealth}{stealth} +% { +% \pgfarrowsleftextend{-6\pgflinewidth} +% \pgfarrowsrightextend{2\pgflinewidth} +% { +% \pgfpathmoveto{\pgfpoint{2\pgflinewidth}{0pt}} +% \pgfpathlineto{\pgfpoint{-6\pgflinewidth}{4\pgflinewidth}} +% \pgfpathlineto{\pgfpoint{-3\pgflinewidth}{0pt}} +% \pgfpathlineto{\pgfpoint{-6\pgflinewidth}{-4\pgflinewidth}} +% \pgfusepathqfill +% } + +\def\pgfarrowsdeclare#1#2#3#4{% + \pgf@arrows@check@already{#1}{#2} + {% + \expandafter\def\csname pgf@arrow@code@#2\endcsname{#4}% + \expandafter\def\csname pgf@arrow@left@#2\endcsname{#3\advance\pgf@x by-\pgf@xa}% + \expandafter\def\csname pgf@arrow@right@#2\endcsname{#3\advance\pgf@x by\pgf@xb}% + \pgf@arrows@invname{#1}{#2}% + }% +} + +\def\pgfarrowsleftextend#1{\pgfmathsetlength\pgf@xa{#1}} +\def\pgfarrowsrightextend#1{\pgfmathsetlength\pgf@xb{#1}} + +\def\pgf@arrows@repeat#1#2{% + \edef\pgf@arrows@marshal{\noexpand\let\expandafter\noexpand\csname#2\endcsname=\expandafter\noexpand\csname#1\endcsname}% + \pgf@arrows@marshal} + + + +% Declare a new arrow type to be the same as another one. +% +% #1 = name of new start +% #2 = name or new end +% #3 = name or old start +% #4 = name or old end +% +% Example: +% +% \pgfarrowsdeclarealias{<}{>}{to}{to} + +\def\pgfarrowsdeclarealias#1#2#3#4{% + \pgf@arrows@check@already{#1}{#2} + {% + \pgf@arrows@checked{#3}{#4}% + {% + \pgf@arrows@repeat{pgf@arrow@code@#4}{pgf@arrow@code@#2}% + \pgf@arrows@repeat{pgf@arrow@left@#4}{pgf@arrow@left@#2}% + \pgf@arrows@repeat{pgf@arrow@right@#4}{pgf@arrow@right@#2}% + \pgf@arrows@invname{#1}{#2}% + }% + }% +} + + + + +% Creates a new arrows by ``swapping'' an existing arrow. +% +% #1 = name of new start +% #2 = name of new end +% #3 = name of old start +% #4 = name of old end +% +% Example: +% +% \pgfarrowsdeclarealias{]}{[}{[}{]} + +\def\pgfarrowsdeclarereversed#1#2#3#4{% + \pgf@arrows@check@already{#1}{#2}% + {% + \pgf@arrows@checked{#3}{#4}% + {% + \expandafter\def\csname pgf@arrow@code@#2\endcsname{% + \pgflowlevel{\pgftransformxscale{-1}}% + \csname pgf@arrow@code@#4\endcsname}% + \pgf@arrows@repeat{pgf@arrow@right@#4}{pgf@arrow@left@#2}% + \pgf@arrows@repeat{pgf@arrow@left@#4}{pgf@arrow@right@#2}% + \pgf@arrows@invname{#1}{#2}% + }% + }% +} + + + +% Creates new arrows by combining two existing arrows. +% +% #1 = optional additional space +% #2 = name of new start +% #3 = name of new end +% #4 = name of second (innermost) start +% #5 = name of second end +% #6 = name of first (outermost) start +% #7 = name of first end +% +% In the star form, the line will end at the innermost arrows, +% otherwise the line will end at the outermost arrows. +% +% Example: +% +% \pgfarrowsdeclarecombine*{|<}{>|}{|}{|}{<}{>} +% \pgfarrowsdeclarecombine{<<}{>>}{<}{>}{<}{>} + +\def\pgfarrowsdeclarecombine{\pgfutil@ifnextchar*{\pgfarrowsdeclarecombine@star}{\pgf@@arrowsdeclarecombine}} + +\def\pgf@@arrowsdeclarecombine{\pgfutil@ifnextchar[{\pgf@arrowsdeclarecombine}{\pgf@arrowsdeclarecombine[0pt]}} +\def\pgf@arrowsdeclarecombine[#1]#2#3#4#5#6#7{% + \pgf@arrows@check@already{#2}{#3}% + {% + \pgf@arrows@checked{#4}{#5}% + {% + \pgf@arrows@checked{#6}{#7}% + {% + \expandafter\edef\csname pgf@arrow@code@#3\endcsname{% + \noexpand\pgfscope% + {\expandafter\noexpand\csname pgf@arrow@code@#7\endcsname}% + \noexpand\endpgfscope% + {% + \noexpand\pgfmathsetlength\pgf@x{#1}% + \noexpand\pgf@process{\expandafter\noexpand\csname pgf@arrow@left@#7\endcsname}% + \noexpand\pgf@process{\expandafter\noexpand\csname pgf@arrow@right@#5\endcsname}% + \pgf@x=-\pgf@x% + \noexpand\pgflowlevel{\noexpand\pgftransformxshift{\pgf@x}}% + \expandafter\noexpand\csname pgf@arrow@code@#5\endcsname}% + }% + \pgf@arrows@repeat{pgf@arrow@right@#7}{pgf@arrow@right@#3}% + \expandafter\def\csname pgf@arrow@left@#3\endcsname{% + \pgf@process{% + \pgfmathsetlength\pgf@y{#1}% + \advance\pgf@x by\pgf@y% + \pgf@process{\csname pgf@arrow@left@#7\endcsname}% + \pgf@process{\csname pgf@arrow@right@#5\endcsname}% + \pgf@process{\csname pgf@arrow@left@#5\endcsname}% + }% + }% + \pgf@arrows@invname{#2}{#3}% + }% + }% + }% +} + +\def\pgfarrowsdeclarecombine@star*{\pgfutil@ifnextchar[{\pgf@arrowsdeclarecombine@star}{\pgf@arrowsdeclarecombine@star[0pt]}} +\def\pgf@arrowsdeclarecombine@star[#1]#2#3#4#5#6#7{% + \pgf@arrows@check@already{#2}{#3}% + {% + \pgf@arrows@checked{#4}{#5}% + {% + \pgf@arrows@checked{#6}{#7}% + {% + \expandafter\edef\csname pgf@arrow@code@#3\endcsname{% + \noexpand\pgfscope% + {% + \noexpand\pgfmathsetlength\pgf@x{#1}% + \pgf@process{\expandafter\noexpand\csname pgf@arrow@left@#7\endcsname}% + \pgf@process{\expandafter\noexpand\csname pgf@arrow@right@#5\endcsname}% + \noexpand\pgflowlevel{\noexpand\pgftransformxshift{\pgf@x}}% + }% + {\expandafter\noexpand\csname pgf@arrow@code@#7\endcsname}% + \noexpand\endpgfscope% + \expandafter\noexpand\csname pgf@arrow@code@#5\endcsname% + }% + \pgf@arrows@repeat{pgf@arrow@left@#7}{pgf@arrow@left@#3}% + \expandafter\def\csname pgf@arrow@right@#3\endcsname{% + \pgf@process{% + \pgfmathsetlength\pgf@y{#1}% + \advance\pgf@x by\pgf@y% + \pgf@process{\csname pgf@arrow@left@#7\endcsname}% + \pgf@process{\csname pgf@arrow@right@#5\endcsname}% + \pgf@process{\csname pgf@arrow@right@#7\endcsname}% + }% + }% + \pgf@arrows@invname{#2}{#3}% + }% + }% + }% +} + + + +% Creates new arrows by doubling/tripling existing arrows. +% +% #1 = optional additional space in multiples of line width +% #2 = name of new start +% #3 = name of new end +% #4 = name of old start +% #5 = name of old end +% +% Example: +% +% \pgfarrowsdeclaredouble{<<}{>>}{<}{>} + +\def\pgfarrowsdeclaredouble{\pgfutil@ifnextchar[{\pgf@arrowsdeclaredouble}{\pgf@arrowsdeclaredouble[0pt]}} +\def\pgf@arrowsdeclaredouble[#1]#2#3#4#5{\pgfarrowsdeclarecombine[#1]{#2}{#3}{#4}{#5}{#4}{#5}} +\def\pgfarrowsdeclaretriple{\pgfutil@ifnextchar[{\pgf@arrowsdeclaretriple}{\pgf@arrowsdeclaretriple[0pt]}} +\def\pgf@arrowsdeclaretriple[#1]#2#3#4#5{% + \pgfarrowsdeclarecombine[#1]{pgf@trip@#2}{pgf@trip@#3}{#4}{#5}{#4}{#5}% + \pgfarrowsdeclarecombine[#1]{#2}{#3}{pgf@trip@#2}{pgf@trip@#3}{#4}{#5}% +} + + +% A stealth-fighter-like pointed arrow +% +% Example: +% +% \pgfsetarrows{-stealth} + +\pgfarrowsdeclare{stealth}{stealth} +{ + \pgfutil@tempdima=0.28pt% + \advance\pgfutil@tempdima by.3\pgflinewidth% + \pgfarrowsleftextend{+-3\pgfutil@tempdima} + \pgfarrowsrightextend{+5\pgfutil@tempdima} +} +{ + \pgfutil@tempdima=0.28pt% + \advance\pgfutil@tempdima by.3\pgflinewidth% + \pgfpathmoveto{\pgfqpoint{5\pgfutil@tempdima}{0pt}} + \pgfpathlineto{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}} + \pgfpathlineto{\pgfpointorigin} + \pgfpathlineto{\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}} + \pgfusepathqfill +} + +\pgfarrowsdeclarereversed{stealth reversed}{stealth reversed}{stealth}{stealth} + + +% An arrow similar to the $\to$ arrow +% +% Example: +% +% \pgfsetarrow{-to} + +\pgfarrowsdeclare{to}{to} +{ + \pgfutil@tempdima=-0.84pt% + \advance\pgfutil@tempdima by-1.3\pgflinewidth% + \pgfutil@tempdimb=0.21pt% + \advance\pgfutil@tempdimb by.625\pgflinewidth% + \pgfarrowsleftextend{+\pgfutil@tempdima} + \pgfarrowsrightextend{+\pgfutil@tempdimb} +} +{ + \pgfutil@tempdima=0.28pt% + \advance\pgfutil@tempdima by.3\pgflinewidth% + \pgfsetlinewidth{0.8\pgflinewidth} + \pgfsetdash{}{+0pt} + \pgfsetroundcap + \pgfsetroundjoin + \pgfpathmoveto{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}} + \pgfpathcurveto + {\pgfqpoint{-2.75\pgfutil@tempdima}{2.5\pgfutil@tempdima}} + {\pgfqpoint{0pt}{0.25\pgfutil@tempdima}} + {\pgfqpoint{0.75\pgfutil@tempdima}{0pt}} + \pgfpathcurveto + {\pgfqpoint{0pt}{-0.25\pgfutil@tempdima}} + {\pgfqpoint{-2.75\pgfutil@tempdima}{-2.5\pgfutil@tempdima}} + {\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}} + \pgfusepathqstroke +} + +\pgfarrowsdeclare{to reversed}{to reversed} +{ + \pgfutil@tempdima=-0.21pt% + \advance\pgfutil@tempdima by-0.475\pgflinewidth% + \pgfutil@tempdimb=0.98pt% + \advance\pgfutil@tempdimb by1.45\pgflinewidth% + \pgfarrowsleftextend{+\pgfutil@tempdima} + \pgfarrowsrightextend{+\pgfutil@tempdimb} +} +{ + \pgfutil@tempdima=0.28pt% + \advance\pgfutil@tempdima by.3\pgflinewidth% + \pgfsetlinewidth{+0.8\pgflinewidth} + \pgfsetdash{}{+0pt} + \pgfsetroundcap + \pgfsetroundjoin + \pgfpathmoveto{\pgfqpoint{3.5\pgfutil@tempdima}{4\pgfutil@tempdima}} + \pgfpathcurveto + {\pgfqpoint{3.25\pgfutil@tempdima}{2.5\pgfutil@tempdima}} + {\pgfqpoint{0.5\pgfutil@tempdima}{0.25\pgfutil@tempdima}} + {\pgfqpoint{-0.25\pgfutil@tempdima}{0\pgfutil@tempdima}} + \pgfpathcurveto + {\pgfqpoint{0.5\pgfutil@tempdima}{-0.25\pgfutil@tempdima}} + {\pgfqpoint{3.25\pgfutil@tempdima}{-2.5\pgfutil@tempdima}} + {\pgfqpoint{3.5\pgfutil@tempdima}{-4\pgfutil@tempdima}} + \pgfusepathqstroke +} + + + +% LaTeX's orginal arrow type +% +% Example: +% +% \pgfsetarrows{-latex} + +\pgfarrowsdeclare{latex}{latex} +{ + \pgfutil@tempdima=0.28pt% + \advance\pgfutil@tempdima by.3\pgflinewidth% + \pgfarrowsleftextend{+-1\pgfutil@tempdima} + \pgfarrowsrightextend{+9\pgfutil@tempdima} +} +{ + \pgfutil@tempdima=0.28pt% + \advance\pgfutil@tempdima by.3\pgflinewidth% + \pgfpathmoveto{\pgfqpoint{9\pgfutil@tempdima}{0pt}} + \pgfpathcurveto + {\pgfqpoint{6.3333\pgfutil@tempdima}{.5\pgfutil@tempdima}} + {\pgfqpoint{2\pgfutil@tempdima}{2\pgfutil@tempdima}} + {\pgfqpoint{-1\pgfutil@tempdima}{3.75\pgfutil@tempdima}} + \pgfpathlineto{\pgfqpoint{-1\pgfutil@tempdima}{-3.75\pgfutil@tempdima}} + \pgfpathcurveto + {\pgfqpoint{2\pgfutil@tempdima}{-2\pgfutil@tempdima}} + {\pgfqpoint{6.3333\pgfutil@tempdima}{-.5\pgfutil@tempdima}} + {\pgfqpoint{9\pgfutil@tempdima}{0pt}} + \pgfusepathqfill +} +\pgfarrowsdeclarereversed{latex reversed}{latex reversed}{latex}{latex} + + + +% A bar shaped arrow +% +% Example: +% +% \pgfsetarrows{-|} + +\pgfarrowsdeclare{|}{|} +{ + \pgfarrowsleftextend{+-0.25\pgflinewidth} + \pgfarrowsrightextend{+.75\pgflinewidth} +} +{ + \pgfutil@tempdima=2pt% + \advance\pgfutil@tempdima by1.5\pgflinewidth% + \pgfsetdash{}{+0pt} + \pgfsetrectcap + \pgfpathmoveto{\pgfqpoint{0.25\pgflinewidth}{-\pgfutil@tempdima}} + \pgfpathlineto{\pgfqpoint{0.25\pgflinewidth}{\pgfutil@tempdima}} + \pgfusepathqstroke +} + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicstate.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicstate.code.tex new file mode 100644 index 00000000000..b3a04e6cad0 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicstate.code.tex @@ -0,0 +1,230 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoregraphicstate.code.tex,v 1.8 2007/12/12 16:57:17 tantau Exp $ + +% Globals + +\newdimen\pgflinewidth + + +% Set the line width to #1. +% +% #1 = new line width. +% +% Example: +% +% \pgfsetlinewidth{3pt} + +\def\pgfsetlinewidth#1{% + \pgfmathsetlength\pgflinewidth{#1}% + \global\pgflinewidth=\pgflinewidth% + \pgfsys@setlinewidth{\the\pgflinewidth}% + \ignorespaces} + + +% Set the miter limit to #1. +% +% #1 = new miter limit factor. +% +% Example: +% +% \pgfsetmiterlimit{3} + +\def\pgfsetmiterlimit#1{% + \pgfsys@setmiterlimit{#1}% + \ignorespaces} + + +% Set the dash pattern to #1 with phase #2/ +% +% #1 = a row of numbers of length of ``on'' and ``off'' points. +% #2 = a phase +% +% Example: +% +% \pgfsetdash{} {0pt} % solid line +% \pgfsetdash{{.1cm}} {0pt} % long dashes +% \pgfsetdash{{1pt}{1ex}}{0pt} % dotted + +\def\pgfsetdash#1#2{% + \def\pgf@temp{}% + \def\pgf@next{\pgf@strip}% + \pgf@strip#1{pgf@stop}% + \pgfmathsetlength\pgf@x{#2}% + \pgfsys@setdash{\pgf@temp}{\the\pgf@x}% + \ignorespaces} + +\def\pgf@strip#1{% + \def\pgf@@temp{#1}% + \ifx\pgf@@temp\pgf@stop% + \let\pgf@next=\relax% + \else% + \pgfmathsetlength\pgf@x{#1}% + \ifx\pgf@temp\pgfutil@empty% + \edef\pgf@temp{\the\pgf@x}% + \else% + \edef\pgf@temp{\pgf@temp,\the\pgf@x}% + \fi% + \fi\pgf@next} + +\def\pgf@stop{pgf@stop} + + +% Set color of strokes. This will overrule the normal color. +% +% Example: +% +% \pgfsetstrokecolor{red} + +\def\pgfsetstrokecolor#1{% + \pgfutil@colorlet{pgf@tempcolor}{#1}% + \pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgf@tempcolor}}% + \expandafter\expandafter\expandafter\pgf@setstrokecolor\csname\string\color@pgf@tempcolor\endcsname% +} +\def\pgf@setstrokecolor#1#2#3#4#5{% + \expandafter\ifx\csname pgfsys@color@#4@stroke\endcsname\relax% + \PackageError{pgfbase}{Unsupported color model `#4'. Sorry}{}% + \else% + \edef\pgf@colmarshal{\expandafter\noexpand\csname pgfsys@color@#4@stroke\endcsname}% + \pgf@uncomma#5,,% + \pgf@colmarshal% + \fi} + +\def\pgf@uncomma#1,{% + \def\pgf@coltest{#1}% + \ifx\pgf@coltest\pgfutil@empty% + \let\pgf@colnext=\relax% + \else% + \expandafter\def\expandafter\pgf@colmarshal\expandafter{\pgf@colmarshal{#1}}% + \let\pgf@colnext=\pgf@uncomma% + \fi% + \pgf@colnext% +} + + +% Set color of fills. This will overrule the normal color. +% +% Example: +% +% \pgfsetfillcolor{gray} + +\def\pgfsetfillcolor#1{% + \pgfutil@colorlet{pgf@tempcolor}{#1}% + \pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgf@tempcolor}}% + \expandafter\expandafter\expandafter\pgf@setfillcolor\csname\string\color@pgf@tempcolor\endcsname% +} +\def\pgf@setfillcolor#1#2#3#4#5{% + \expandafter\ifx\csname pgfsys@color@#4@fill\endcsname\relax% + \PackageError{pgfbase}{Unsupported color model `#4'. Sorry}{}% + \else% + \edef\pgf@colmarshal{\expandafter\noexpand\csname pgfsys@color@#4@fill\endcsname}% + \pgf@uncomma#5,,% + \pgf@colmarshal% + \fi} + + + +% Sets both the stroke and fill color. +% +% Example: +% +% \pgfsetcolor{blue} + +\def\pgfsetcolor#1{% + \pgfutil@colorlet{pgf@tempcolor}{#1}% + \pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgf@tempcolor}}% + \expandafter\expandafter\expandafter\pgf@setcolor\csname\string\color@pgf@tempcolor\endcsname% +} +\def\pgf@setcolor#1#2#3#4#5{% + \expandafter\ifx\csname pgfsys@color@#4\endcsname\relax% + \PackageError{pgfbase}{Unsupported color model `#4'. Sorry}{}% + \else% + \edef\pgf@colmarshal{\expandafter\noexpand\csname pgfsys@color@#4\endcsname}% + \pgf@uncomma#5,,% + \pgf@colmarshal% + \fi} + +% Code for ensuring the stroke/fill colors are correctly reset. +\def\XC@bcolor{\pgfsys@color@reset} + +% Set a butt line cap. +% +% Example: +% +% \pgfsetbuttcap + +\def\pgfsetbuttcap{\pgfsys@buttcap\ignorespaces} + + +% Set a round line cap. +% +% Example: +% +% \pgfsetroundcap + +\def\pgfsetroundcap{\pgfsys@roundcap\ignorespaces} + + +% Set a rectangular line cap. +% +% Example: +% +% \pgfsetrectcap + +\def\pgfsetrectcap{\pgfsys@rectcap\ignorespaces} + + +% Set a miter line join. +% +% Example: +% +% \pgfsetmiterjoin + +\def\pgfsetmiterjoin{\pgfsys@miterjoin\ignorespaces} + + +% Set a bevel line join. +% +% Example: +% +% \pgfsetbeveljoin + +\def\pgfsetbeveljoin{\pgfsys@beveljoin\ignorespaces} + + +% Set a round line join. +% +% Example: +% +% \pgfsetroundjoin + +\def\pgfsetroundjoin{\pgfsys@roundjoin\ignorespaces} + + +% Sets the even-odd rule for filling and clipping. +% +% Example: +% +% \pgfseteorule + +\def\pgfseteorule{\pgfsys@eoruletrue\ignorespaces} + + +% Sets the non-zero winding number rule for filling and clipping. +% +% Example: +% +% \pgfsetnonzerorule + +\def\pgfsetnonzerorule{\pgfsys@eorulefalse\ignorespaces} + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex new file mode 100644 index 00000000000..557558d82ef --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex @@ -0,0 +1,101 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreobjects.code.tex,v 1.2 2006/10/11 15:22:25 tantau Exp $ + + +% Object reuse + + +% Define a pgf object for reuse. Such objects will be stored +% efficiently internally. +% +% #1 = name for later reuse +% #2 = lower left corner point of bounding box +% #3 = upper right left corner point of bounding box +% #4 = pure pgf code (nothing too fancy!) +% +% Description: +% +% Used to define reusable objects. The object must be composed of +% basic pgf graphic primitives. Nothing fancy can be used. The +% created object will be stored as an xform object in pdf or as a +% postscript procedure in postscript. +% +% Example: +% +% \pgfdefobject{myrect}{\pgfpoint{-1pt}{-1pt}}{\pgfpoint{11pt}{11pt}} +% {\pgfpathqmoveto{0pt}{0pt} +% \pgfpathqmoveto{10pt}{0pt} +% \pgfpathqmoveto{10pt}{10pt} +% \pgfpathqmoveto{0pt}{10pt} +% \pgfpathclose +% \pgfusepath{stroke}} +% +% \begin{pgfpicture}{0cm}{0cm}{1cm}{1cm} +% \pgfuseobject{myrect} +% \end{pgfpicture} + +\def\pgfdefobject#1#2#3#4{% + \pgfinterruptpath% + \pgf@relevantforpicturesizefalse% + \pgfsys@defobject{#1}{#2}{#3}{#4}% + \endpgfinterruptpath% + \ignorespaces% +} + + +% Use an object that was previously defined using pgfdefobject +% +% #1 = name of previously defined object +% +% Example: +% +% \pgfdefobject{myrect}{\pgfpoint{-1pt}{-1pt}}{\pgfpoint{11pt}{11pt}} +% {\pgfqmoveto{0}{0} +% \pgfqmoveto{10}{0} +% \pgfqmoveto{10}{10} +% \pgfqmoveto{0}{10} +% \pgfclosestroke} +% +% \begin{pgfpicture}{0cm}{0cm}{1cm}{1cm} +% \pgfuseobject{myrect} +% \end{pgfpicture} + +\def\pgfuseobject#1{\pgfsys@beginscope\pgfsys@useobject{#1}{}\pgfsys@endscope} + + +% Use an object that was previously defined using pgfdefobject, but +% magnify the object by the current x and y register values +% +% #1 = name of previously defined object +% +% Example: +% +% \pgfdefobject{myrect}{\pgfpoint{-1pt}{-1pt}}{\pgfpoint{11pt}{11pt}} +% {\pgfqmoveto{0}{0} +% \pgfqmoveto{10}{0} +% \pgfqmoveto{10}{10} +% \pgfqmoveto{0}{10} +% \pgfclosestroke} +% +% \begin{pgfpicture}{0cm}{0cm}{1cm}{1cm} +% \pgf@x=2pt% Scale by factor two in x-direction +% \pgf@y=2pt% Scale by factor two in y-direction +% \pgfuseobjectmagnify{myrect} +% \end{pgfpicture} + +\def\pgfuseobjectmagnify#1{% + \pgfsys@beginscope% + \pgfsys@useobject{#1}{\pgfsys@transformxyscale{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}}% + \pgfsys@endscope% +} + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruct.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruct.code.tex new file mode 100644 index 00000000000..b96d766b081 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruct.code.tex @@ -0,0 +1,890 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorepathconstruct.code.tex,v 1.14 2008/02/13 15:10:06 tantau Exp $ + + +\newdimen\pgf@path@lastx +\newdimen\pgf@path@lasty + + + +% Replace corners by arcs. +% +% #1 = in-size of arc +% #2 = out-size of arc +% +% Description: +% +% This command influences path construction command like +% \pgfpathlineto or \pgfpatharc. It will cause the corners at the end +% of these commands to be replaced by little arcs. If the +% corner is a 90 degrees corner and if #1=#2, a quarter-circle of +% radius #1 is put in place of the corner. If #1 and #2 are different, +% the quarter circle will instead by a quarter ellipse. If the angle +% is different from 90 degrees, a deformed quarter circle will +% result, which may or may not be desirable. For a ``perfect'' arc you +% must use the \pgfpatharc command. +% +% +% Example: One rounded corner. +% +% \pgfpathmoveto{\pgfpointxy{0}{0}} +% \pgfsetcornersarced{4pt}{4pt} +% \pgfpathlineto{\pgfpointxy{0}{1}} +% \pgfpathlineto{\pgfpointxy{1}{1}} +% \pgfstroke +% +% Example: A rounded rectangle +% +% \pgfsetcornersarced{4pt}{4pt} +% \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{1cm}{1cm}} +% \pgfstroke +% +% Example: A rounded triangles +% +% \pgfsetcornersarced{4pt}{4pt} +% \pgfpathmoveto{\pgfpointorigin} +% \pgfpathlineto{\pgfpoint{1cm}{0cm}} +% \pgfpathlineto{\pgfpoint{1cm}{1cm}} +% \pgfpathclose +% \pgfstroke + +\newif\ifpgf@arccorners + +\def\pgfsetcornersarced#1{% + \pgf@process{#1}% + \edef\pgf@corner@arc{{\the\pgf@x}{\the\pgf@y}}% + \pgf@arccornerstrue% + \ifdim\pgf@x=0pt% + \ifdim\pgf@y=0pt\relax% + \pgf@arccornersfalse% + \fi% + \fi% +} + +\def\pgf@roundcornerifneeded{% + \ifpgf@arccorners\expandafter\pgfsyssoftpath@specialround\pgf@corner@arc\fi% +} + + +% Move current point to #1. +% +% #1 = new current point +% +% Example: +% +% \pgfpathmoveto{\pgfxy(0,0)} +% \pgfpathlineto{\pgfxy(0,1)} +% \pgfstroke + +\def\pgfpathmoveto#1{% + \pgfpointtransformed{#1}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgfsyssoftpath@moveto{\the\pgf@x}{\the\pgf@y}% + \global\pgf@path@lastx=\pgf@x% + \global\pgf@path@lasty=\pgf@y% +} + +\def\pgf@protocolsizes#1#2{% + \ifpgf@relevantforpicturesize% + \ifdim#1<\pgf@picminx\global\pgf@picminx#1\fi% + \ifdim#1>\pgf@picmaxx\global\pgf@picmaxx#1\fi% + \ifdim#2<\pgf@picminy\global\pgf@picminy#2\fi% + \ifdim#2>\pgf@picmaxy\global\pgf@picmaxy#2\fi% + \fi% + \ifdim#1<\pgf@pathminx\global\pgf@pathminx#1\fi% + \ifdim#1>\pgf@pathmaxx\global\pgf@pathmaxx#1\fi% + \ifdim#2<\pgf@pathminy\global\pgf@pathminy#2\fi% + \ifdim#2>\pgf@pathmaxy\global\pgf@pathmaxy#2\fi% + \ifpgf@size@hooked% + \let\pgf@size@hook@x#1\let\pgf@size@hook@y#2\pgf@path@size@hook% + \fi% +} +\newif\ifpgf@size@hooked +\let\pgf@path@size@hook=\pgfutil@empty% + +\def\pgf@resetpathsizes{% + \global\pgf@pathmaxx=-16000pt\relax% + \global\pgf@pathminx=16000pt\relax% + \global\pgf@pathmaxy=-16000pt\relax% + \global\pgf@pathminy=16000pt\relax% +} + +\def\pgf@getpathsizes#1{% + \edef#1{{\the\pgf@pathmaxx}{\the\pgf@pathminx}{\the\pgf@pathmaxy}{\the\pgf@pathminy}}% +} +\def\pgf@setpathsizes#1{% + \expandafter\pgf@@setpathsizes#1% +} +\def\pgf@@setpathsizes#1#2#3#4{% + \global\pgf@pathmaxx=#1\relax% + \global\pgf@pathminx=#2\relax% + \global\pgf@pathmaxy=#3\relax% + \global\pgf@pathminy=#4\relax% +} + + + + + +% Append a line from the current point to #1 to the current path. +% +% #1 = end of line +% +% Example: +% +% \pgfpathmoveto{\pgfxy(0,0)} +% \pgfpathlineto{\pgfxy(0,1)} +% \pgfstroke + +\def\pgfpathlineto#1{% + \pgfpointtransformed{#1}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@roundcornerifneeded% + \pgfsyssoftpath@lineto{\the\pgf@x}{\the\pgf@y}% + \global\pgf@path@lastx=\pgf@x% + \global\pgf@path@lasty=\pgf@y% +} + + + +% Close the current path. +% +% Example: +% +% % Draws two triangles +% \pgfpathmoveto{\pgfxy(0,0)} +% \pgfpathlineto{\pgfxy(0,1)} +% \pgfpathlineto{\pgfxy(1,0)} +% \pgfclosepath +% \pgfpathmoveto{\pgfxy(2,0)} +% \pgfpathlineto{\pgfxy(2,1)} +% \pgfpathlineto{\pgfxy(3,0)} +% \pgfpathclose +% \pgfstroke + +\def\pgfpathclose{% + \pgf@roundcornerifneeded% + \pgfsyssoftpath@closepath% +} + + +% Append a bezier spline from the current point to #3 with control +% points #1 and #2 to the current path. +% +% #1 = first control point +% #2 = second control point +% #3 = end point +% +% Example: +% +% \pgfpathmoveto{\pgfxy(0,0)} +% \pgfpathcurveto{\pgfxy(0,1)}{\pgfxy(1,1)}{\pgfxy(1,2)} +% \pgfstroke + +\def\pgfpathcurveto#1#2#3{% + \pgfpointtransformed{#3}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgfpointtransformed{#2}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgfpointtransformed{#1}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@roundcornerifneeded% + \pgfsyssoftpath@curveto{\the\pgf@x}{\the\pgf@y}{\the\pgf@xa}{\the\pgf@ya}{\the\pgf@xb}{\the\pgf@yb}% + \global\pgf@path@lastx=\pgf@xb% + \global\pgf@path@lasty=\pgf@yb% +} + + +% Append an arc to the current point, where the current point is at +% angle #1 and the end is at angle #2. If #2 > #1, the arc is drawn +% counter-clockwise, otherwise it is clockwise. +% +% #1 = angle of first point +% #2 = angle of second point +% #3 = radius or x-radius/y-radius +% +% Example: +% +% \pgfpathmoveto{\pgfxy(0,0)} +% \pgfpatharc{0}{90}{2cm} +% \pgfstroke + +\def\pgfpatharc#1#2#3{% + {% + \pgfmathparse{#1}\let\pgf@temp@a=\pgfmathresult% + \pgfmathparse{#2}\let\pgf@temp@b=\pgfmathresult% + \pgfutil@in@{and }{#3}% + \ifpgfutil@in@% + \pgf@arc@get@radii#3\pgf@arc@stop% + \else + \pgf@arc@get@radii#3and #3\pgf@arc@stop% + \fi% + \pgf@arc@local@angle@a=\pgf@temp@a pt% + \pgf@arc@local@angle@b=\pgf@temp@b pt% + \relax% + \ifdim\pgf@arc@local@angle@a>360pt\relax% + \advance\pgf@arc@local@angle@a by-360pt\relax% + \fi% + \ifdim\pgf@arc@local@angle@a<-360pt\relax% + \advance\pgf@arc@local@angle@a by360pt\relax% + \fi% + \ifdim\pgf@arc@local@angle@b>360pt\relax% + \advance\pgf@arc@local@angle@b by-360pt\relax% + \fi% + \ifdim\pgf@arc@local@angle@b<-360pt\relax% + \advance\pgf@arc@local@angle@b by360pt\relax% + \fi% + \loop% + \pgfutil@tempdima=\pgf@arc@local@angle@a% + \advance\pgfutil@tempdima by-\pgf@arc@local@angle@b\relax% + \ifdim\pgfutil@tempdima<0pt\relax% + \pgfutil@tempdima=-\pgfutil@tempdima\relax% + \fi% + \ifdim\pgfutil@tempdima>90pt\relax% + \ifdim\pgfutil@tempdima>115pt\relax% + \pgf@arc@temp=90pt% big skip + \else% + \pgf@arc@temp=60pt% smaller skip to ensure wide segments + % (important shortened end segments because + % of arrow tips) + \fi% + \ifdim\pgf@arc@local@angle@b>\pgf@arc@local@angle@a\relax% + {% + \pgf@arc@local@angle@b=\pgf@arc@local@angle@a\relax% + \advance\pgf@arc@local@angle@b by\pgf@arc@temp\relax% + \pgf@arc% + } + \advance\pgf@arc@local@angle@a by\pgf@arc@temp\relax% + \else + {% + \pgf@arc@local@angle@b=\pgf@arc@local@angle@a\relax% + \advance\pgf@arc@local@angle@b by-\pgf@arc@temp\relax% + \pgf@arc% + }% + \advance\pgf@arc@local@angle@a by-\pgf@arc@temp\relax% + \fi% + \repeat% + \pgf@roundcornerifneeded% + \pgf@arc% + }% +} +\dimendef\pgf@arc@local@angle@a=0 +\dimendef\pgf@arc@local@angle@b=1 +\dimendef\pgf@arc@temp=2 + +\def\pgf@arc@get@radii#1and #2\pgf@arc@stop{% + \pgfmathparse{#1}\let\pgf@arc@radius@a=\pgfmathresult% + \pgfmathparse{#2}\let\pgf@arc@radius@b=\pgfmathresult% +} + + +\def\pgf@arc{% + {% + % \pgfmathsetlength{\pgfutil@tempdima}{#3}% + % \pgfmathsetlength{\pgfutil@tempdimb}{#4}% + \pgfutil@tempdima=\pgf@arc@radius@a pt% + \pgfutil@tempdimb=\pgf@arc@radius@b pt% + % + \pgf@xa=\pgf@arc@local@angle@a\relax% + \pgf@xb=\pgf@arc@local@angle@b\relax% + % \pgfutil@tempcnta=#1\relax% + % \pgfutil@tempcntb=#2\relax% + \advance\pgf@xb by-\pgf@xa\relax% + \ifdim\pgf@xb<0pt\relax% + \pgf@xb=-\pgf@xb\relax% + \fi% + \ifdim\pgf@xb>85pt\relax% hackery to correct the control points + \pgfutil@tempdima=0.0555\pgfutil@tempdima\relax% + \pgfutil@tempdimb=0.0555\pgfutil@tempdimb\relax% + \else% + \ifdim\pgf@xb>75pt\relax% + \pgfutil@tempdima=0.055\pgfutil@tempdima\relax% + \pgfutil@tempdimb=0.055\pgfutil@tempdimb\relax% + \else% + \ifdim\pgf@xb>60pt\relax% + \pgfutil@tempdima=0.0545\pgfutil@tempdima\relax% + \pgfutil@tempdimb=0.0545\pgfutil@tempdimb\relax% + \else% + \pgfutil@tempdima=0.054\pgfutil@tempdima\relax% + \pgfutil@tempdimb=0.054\pgfutil@tempdimb\relax% + \fi% + \fi% + \fi + \pgfutil@tempdima=\pgf@sys@tonumber{\pgf@xb}\pgfutil@tempdima\relax% + \divide\pgfutil@tempdima by 9\relax% + \pgfutil@tempdimb=\pgf@sys@tonumber{\pgf@xb}\pgfutil@tempdimb\relax% + \divide\pgfutil@tempdimb by 9\relax% + %.. controls +(\pgf@xa+90:\pgfutil@tempdima) and +(\pgf@xb-90:\pgfutil@tempdima) .. +(-(#1:#3)+(#2:#3))% + % store first support vector in xa/ya: + \pgf@xa=\pgf@arc@local@angle@a\relax% + \ifdim\pgf@arc@local@angle@b>\pgf@arc@local@angle@a\relax% + \advance\pgf@xa by 90pt\relax% + \else% + \advance\pgf@xa by -90pt\relax% + \fi% + \edef\pgf@arc@angle{\pgf@sys@tonumber{\pgf@xa}}% + \pgfpointtransformed{\pgfpointpolar{\pgf@arc@angle}{\pgfutil@tempdima and \pgfutil@tempdimb}}% + \advance\pgf@x by-\pgf@pt@x% + \advance\pgf@y by-\pgf@pt@y% + \pgf@xa=\pgf@path@lastx% + \pgf@ya=\pgf@path@lasty% + \advance\pgf@xa by \pgf@x% + \advance\pgf@ya by \pgf@y% + % store target in xb/yb: + \pgfpointtransformed{\pgfpointpolar{\pgf@sys@tonumber{\pgf@arc@local@angle@a}}{\pgf@arc@radius@a pt and \pgf@arc@radius@b pt}}% + \pgf@xb=\pgf@path@lastx% + \pgf@yb=\pgf@path@lasty% + \advance\pgf@xb by -\pgf@x% + \advance\pgf@yb by -\pgf@y% + \pgfpointtransformed{\pgfpointpolar{\pgf@sys@tonumber{\pgf@arc@local@angle@b}}{\pgf@arc@radius@a pt and \pgf@arc@radius@b pt}}% + \advance\pgf@xb by \pgf@x% + \advance\pgf@yb by \pgf@y% + % store second support xc/yc: + \ifdim\pgf@arc@local@angle@b>\pgf@arc@local@angle@a\relax% + \advance\pgf@arc@local@angle@b by -90pt\relax% + \else% + \advance\pgf@arc@local@angle@b by 90pt\relax% + \fi% + \pgfpointtransformed{\pgfpointpolar{\pgf@sys@tonumber{\pgf@arc@local@angle@b}}{\pgfutil@tempdima and \pgfutil@tempdimb}}% + \advance\pgf@x by-\pgf@pt@x% + \advance\pgf@y by-\pgf@pt@y% + \pgf@xc=\pgf@xb\relax% + \pgf@yc=\pgf@yb\relax% + \advance \pgf@xc by \pgf@x\relax% + \advance \pgf@yc by \pgf@y\relax% + \pgfsyssoftpath@curveto{\the\pgf@xa}{\the\pgf@ya}{\the\pgf@xc}{\the\pgf@yc}{\the\pgf@xb}{\the\pgf@yb}% + \global\pgf@path@lastx=\pgf@xb% + \global\pgf@path@lasty=\pgf@yb% + \pgf@protocolsizes{\pgf@xa}{\pgf@ya}% + \pgf@protocolsizes{\pgf@xb}{\pgf@yb}% + \pgf@protocolsizes{\pgf@xc}{\pgf@yc}% + }% +} + +% Append an arc to the current point, where the arc is on an ellipse +% given by two axis vectors. +% +% #1 = angle of first point +% #2 = angle of second point +% #3 = first axis +% #4 = second axis +% +% Example: +% +% \pgfpathmoveto{\pgfxy(0,0)} +% \pgfpatharcaxes{0}{90}{\pgfpointxy{2}{0}}{\pgfpointxy{0}{2}} +% \pgfstroke + +\def\pgfpatharcaxes#1#2#3#4{% + {% + \pgftransformtriangle{\pgfpointorigin}{#3}{#4}% + \pgfpatharc{#1}{#2}{1pt}% + }% +} + + + + +% Append an ellipse to the current path. +% +% #1 = center +% #2 = first axis +% #3 = second axis +% +% Example: +% +% % Add a circle of radius 3cm around the origin +% \pgfpathellipse{\pgforigin}{\pgfxy(2,0)}{\pgfxy(0,1)} +% +% % Draw a non-filled circle of radius 1cm around the point (1,1) +% \pgfpathellipse{\pgfxy(1,1)}{\pgfxy(1,1)}{\pgfxy(-2,2)} +% \pgfstroke + +\def\pgfpathellipse#1#2#3{% + \pgfpointtransformed{#1}% store center in xc/yc + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgfpointtransformed{#2}% + \pgf@xa=\pgf@x% store first axis in xa/ya + \pgf@ya=\pgf@y% + \advance\pgf@xa by-\pgf@pt@x% + \advance\pgf@ya by-\pgf@pt@y% + \pgfpointtransformed{#3}% + \pgf@xb=\pgf@x% store second axis in xb/yb + \pgf@yb=\pgf@y% + \advance\pgf@xb by-\pgf@pt@x% + \advance\pgf@yb by-\pgf@pt@y% + {% + \advance\pgf@xa by\pgf@xc% + \advance\pgf@ya by\pgf@yc% + \pgfsyssoftpath@moveto{\the\pgf@xa}{\the\pgf@ya}% + \pgf@protocolsizes{\pgf@xa}{\pgf@ya}% + }% + \pgf@x=0.555\pgf@xb% first arc + \pgf@y=0.555\pgf@yb% + \advance\pgf@x by\pgf@xa% + \advance\pgf@y by\pgf@ya% + \advance\pgf@x by\pgf@xc% + \advance\pgf@y by\pgf@yc% + \edef\pgf@temp{{\the\pgf@x}{\the\pgf@y}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@x=0.555\pgf@xa% + \pgf@y=0.555\pgf@ya% + \advance\pgf@x by\pgf@xb% + \advance\pgf@y by\pgf@yb% + {% + \advance\pgf@x by\pgf@xc% + \advance\pgf@y by\pgf@yc% + \advance\pgf@xb by\pgf@xc% + \advance\pgf@yb by\pgf@yc% + \expandafter\pgfsyssoftpath@curveto\pgf@temp{\the\pgf@x}{\the\pgf@y}{\the\pgf@xb}{\the\pgf@yb}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@protocolsizes{\pgf@xb}{\pgf@yb}% + }% + \pgf@xa=-\pgf@xa% flip first axis + \pgf@ya=-\pgf@ya% + \pgf@x=0.555\pgf@xa% second arc + \pgf@y=0.555\pgf@ya% + \advance\pgf@x by\pgf@xb% + \advance\pgf@y by\pgf@yb% + \advance\pgf@x by\pgf@xc% + \advance\pgf@y by\pgf@yc% + \edef\pgf@temp{{\the\pgf@x}{\the\pgf@y}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@x=0.555\pgf@xb% + \pgf@y=0.555\pgf@yb% + \advance\pgf@x by\pgf@xa% + \advance\pgf@y by\pgf@ya% + {% + \advance\pgf@x by\pgf@xc% + \advance\pgf@y by\pgf@yc% + \advance\pgf@xa by\pgf@xc% + \advance\pgf@ya by\pgf@yc% + \expandafter\pgfsyssoftpath@curveto\pgf@temp{\the\pgf@x}{\the\pgf@y}{\the\pgf@xa}{\the\pgf@ya}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@protocolsizes{\pgf@xa}{\pgf@ya}% + }% + \pgf@xb=-\pgf@xb% flip second axis + \pgf@yb=-\pgf@yb% + \pgf@x=0.555\pgf@xb% third arc + \pgf@y=0.555\pgf@yb% + \advance\pgf@x by\pgf@xa% + \advance\pgf@y by\pgf@ya% + \advance\pgf@x by\pgf@xc% + \advance\pgf@y by\pgf@yc% + \edef\pgf@temp{{\the\pgf@x}{\the\pgf@y}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@x=0.555\pgf@xa% + \pgf@y=0.555\pgf@ya% + \advance\pgf@x by\pgf@xb% + \advance\pgf@y by\pgf@yb% + {% + \advance\pgf@x by\pgf@xc% + \advance\pgf@y by\pgf@yc% + \advance\pgf@xb by\pgf@xc% + \advance\pgf@yb by\pgf@yc% + \expandafter\pgfsyssoftpath@curveto\pgf@temp{\the\pgf@x}{\the\pgf@y}{\the\pgf@xb}{\the\pgf@yb}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@protocolsizes{\pgf@xb}{\pgf@yb}% + }% + \pgf@xa=-\pgf@xa% flip first axis once more + \pgf@ya=-\pgf@ya% + \pgf@x=0.555\pgf@xa% fourth arc + \pgf@y=0.555\pgf@ya% + \advance\pgf@x by\pgf@xb% + \advance\pgf@y by\pgf@yb% + \advance\pgf@x by\pgf@xc% + \advance\pgf@y by\pgf@yc% + \edef\pgf@temp{{\the\pgf@x}{\the\pgf@y}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@x=0.555\pgf@xb% + \pgf@y=0.555\pgf@yb% + \advance\pgf@x by\pgf@xa% + \advance\pgf@y by\pgf@ya% + {% + \advance\pgf@x by\pgf@xc% + \advance\pgf@y by\pgf@yc% + \advance\pgf@xa by\pgf@xc% + \advance\pgf@ya by\pgf@yc% + \expandafter\pgfsyssoftpath@curveto\pgf@temp{\the\pgf@x}{\the\pgf@y}{\the\pgf@xa}{\the\pgf@ya}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@protocolsizes{\pgf@xa}{\pgf@ya}% + }% + \pgfsyssoftpath@closepath% + \pgfsyssoftpath@moveto{\the\pgf@xc}{\the\pgf@yc}% +} + + + +% Append a circle to the current path +% +% #1 = center +% #2 = radius +% +% Example: +% +% % Append a circle of radius 3cm around the the point (1,1) +% \pgfpathcircle{\pgxy(1,1)}{3cm} + +\def\pgfpathcircle#1#2{\pgfpathellipse{#1}{\pgfpoint{#2}{0pt}}{\pgfpoint{0pt}{#2}}} + + + + +% Append a rectangle to the current path +% +% #1 = lower left corner point of rectangle +% #2 = width and height vector +% +% Example: +% +% % A rectangle with corners (2,2) and (3,3) +% \pgfpathrectangle{\pgfpointxy{2}{2}}{\pgfpointxy{1}{1}} + +\def\pgfpathrectangle{% + \let\pgfrect@next=\pgf@specialrect% + \ifpgf@pt@identity% + \ifpgf@arccorners% + \else% + \let\pgfrect@next=\pgf@normalrect% + \fi% + \fi% + \pgfrect@next% +} + +\def\pgf@normalrect#1#2{% + \pgf@process{#2}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgfpointtransformed{#1}% + \pgfsyssoftpath@rect{\the\pgf@x}{\the\pgf@y}{\the\pgf@xa}{\the\pgf@ya}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \advance\pgf@x by\pgf@xa\relax% + \advance\pgf@y by\pgf@ya\relax% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% +} + +\def\pgf@specialrect#1#2{% + \pgf@process{#2}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#1}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \advance\pgf@xa by\pgf@xb% + \advance\pgf@ya by\pgf@yb% + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathclose% + \pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@yb}}% +} + +% Append a rectangle to the current path +% +% #1 = one corner of the rectangle +% #2 = opposite corner of the rectangle +% +% Example: +% +% % A rectangle with corners (2,2) and (3,3) +% \pgfpathrectanglecorners{\pgfpointxy{2}{2}}{\pgfpointxy{3}{3}} + +\def\pgfpathrectanglecorners#1#2{% + \pgf@process{#2}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{#1}% + \advance\pgf@xc by-\pgf@x% + \advance\pgf@yc by-\pgf@y% + \pgfpathrectangle{#1}{\pgfqpoint{\pgf@xc}{\pgf@yc}}% +} + + +% Append a grid to the current path. +% +% #1 = lower left point of grid +% #2 = upper right point of grid +% +% Options: +% +% stepx = x-step dimension (default 1cm) +% stepy = y-step dimension (default 1cm) +% step = dimesion vector +% +% Example: +% +% \pgfsetlinewidth{0.8pt} +% \pgfgrid{\pgfxy(0,0)}{\pgfxy(3,2)} +% \pgfsetlinewidth{0.4pt} +% \pgfgrid[stepx=1cm,stepy=1cm]{\pgfxy(0,0)}{\pgfxy(3,2)} + +\pgfkeys{ + /pgf/stepx/.initial=1cm, + /pgf/stepy/.initial=1cm, + /pgf/step/.code={\pgf@process{#1}\pgfkeysalso{/pgf/stepx/.expanded=\the\pgf@x,/pgf/stepy/.expanded=\the\pgf@y}}, + /pgf/step/.value required +} + +\def\pgfpathgrid{\pgfutil@ifnextchar[{\pgf@pathgrid}{\pgf@pathgrid[]}} +\def\pgf@pathgrid[#1]#2#3{% + \pgfset{#1}% + \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/stepx}}% + \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/stepy}}% + \pgf@process{#3}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@process{#2}% + \pgf@xa=\pgf@x\relax% + \pgf@ya=\pgf@y\relax% + {% + % compute bounding box + % first corner + \pgf@x=\pgf@xb% + \pgf@y=\pgf@yb% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + % second corner + \pgf@x=\pgf@xb% + \pgf@y=\pgf@ya% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + % third corner + \pgf@x=\pgf@xa% + \pgf@y=\pgf@yb% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + % fourth corner + \pgf@x=\pgf@xa% + \pgf@y=\pgf@ya% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + }% + \c@pgf@counta=\pgf@y\relax% + \c@pgf@countb=\pgf@yc\relax% + \divide\c@pgf@counta by\c@pgf@countb\relax% + \pgf@y=\c@pgf@counta\pgf@yc\relax% + \ifdim\pgf@y<\pgf@ya% + \advance\pgf@y by\pgf@yc% + \fi% + \loop% horizontal lines + {% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@pos@transform{\pgf@xa}{\pgf@ya} + \pgfsyssoftpath@moveto{\the\pgf@xa}{\the\pgf@ya}% + \pgf@xa=\pgf@xb% + \pgf@ya=\pgf@y% + \pgf@pos@transform{\pgf@xa}{\pgf@ya} + \pgfsyssoftpath@lineto{\the\pgf@xa}{\the\pgf@ya}% + }% + \advance\pgf@y by\pgf@yc% + \ifdim\pgf@y<\pgf@yb% + \repeat% + \advance\pgf@y by-0.01pt\relax% + \ifdim\pgf@y<\pgf@yb% + {% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@pos@transform{\pgf@xa}{\pgf@ya} + \pgfsyssoftpath@moveto{\the\pgf@xa}{\the\pgf@ya}% + \pgf@xa=\pgf@xb% + \pgf@ya=\pgf@y% + \pgf@pos@transform{\pgf@xa}{\pgf@ya} + \pgfsyssoftpath@lineto{\the\pgf@xa}{\the\pgf@ya}% + }% + \fi% + \c@pgf@counta=\pgf@x\relax% + \c@pgf@countb=\pgf@xc\relax% + \divide\c@pgf@counta by\c@pgf@countb\relax% + \pgf@x=\c@pgf@counta\pgf@xc\relax% + \ifdim\pgf@x<\pgf@xa% + \advance\pgf@x by\pgf@xc% + \fi% + \loop% vertical lines + {% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@ya% + \pgf@pos@transform{\pgf@xc}{\pgf@yc} + \pgfsyssoftpath@moveto{\the\pgf@xc}{\the\pgf@yc}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@yb% + \pgf@pos@transform{\pgf@xc}{\pgf@yc} + \pgfsyssoftpath@lineto{\the\pgf@xc}{\the\pgf@yc}% + }% + \advance\pgf@x by\pgf@xc% + \ifdim\pgf@x<\pgf@xb% + \repeat% + \advance\pgf@x by-0.01pt\relax% + \ifdim\pgf@x<\pgf@xb% + {% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@ya% + \pgf@pos@transform{\pgf@xc}{\pgf@yc} + \pgfsyssoftpath@moveto{\the\pgf@xc}{\the\pgf@yc}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@yb% + \pgf@pos@transform{\pgf@xc}{\pgf@yc} + \pgfsyssoftpath@lineto{\the\pgf@xc}{\the\pgf@yc}% + }% + \fi% +} + + + +% Append two half-parabolas to the path +% +% #1 = bend (relative to current point) +% #2 = end point (relative to bend point) +% +% Description: +% +% This command appends a half-parabola that starts at the current point +% and has its bend at #1+current point. Then, a second parabola is +% appended that starts at #1+current point, where it also has its +% minimum/maximum, and ends at #1+current point+#2, which becomes the +% new current point. +% +% By setting #2 = (0,0) you draw only a half parabola that goes from the +% current point to the bend; by setting #1 = (0,0) +% you draw a half parabola that going to current point + #2 and has its +% bend at the current point. +% +% Examples: +% +% % Half-parabola going ``up and right'' +% \pgfpathmoveto{\pgfpointorigin} +% \pgfpathparabola{\pgfpointorigin}{\pgfpoint{2cm}{4cm}} +% +% % Half-parabola going ``down and right'' +% \pgfpathmoveto{\pgfpointorigin} +% \pgfpathparabola{\pgfpoint{-2cm}{4cm}}}{\pgfpointorigin} +% +% % Full parabola +% \pgfpathmoveto{\pgfpointorigin} +% \pgfpathparabola{\pgfpoint{-2cm}{4cm}}{\pgfpoint{2cm}{4cm}} + +\def\pgfpathparabola#1#2{% + {% + \pgf@process{#2}% untransformed + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@process{#1}% untransformed + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgfutil@tempswatrue% + \ifdim\pgf@xb=0pt\relax% + \ifdim\pgf@yb=0pt\relax% + \pgfutil@tempswafalse% + \fi% + \fi% + {% + \ifpgfutil@tempswa% + \pgf@arccornersfalse + \else% + \fi% + \pgfutil@tempswatrue% + \ifdim\pgf@xc=0pt\relax% + \ifdim\pgf@yc=0pt\relax% + \pgfutil@tempswafalse% + \fi% + \fi% + \ifpgfutil@tempswa + {% + \pgf@pt@x=\pgf@path@lastx% + \pgf@pt@y=\pgf@path@lasty% + \pgfpathcurveto% + {\pgfqpoint{.1125\pgf@xc}{.225\pgf@yc}}% found by trial and error + {\pgfqpoint{.5\pgf@xc}{\pgf@yc}}% found by trial and error + {\pgfqpoint{\pgf@xc}{\pgf@yc}}% + }% + \fi% + }% + \ifpgfutil@tempswa% + \pgf@xc=\pgf@xb% + \pgf@yc=\pgf@yb% + {% + \pgf@pt@x=\pgf@path@lastx% + \pgf@pt@y=\pgf@path@lasty% + \pgfpathcurveto% + {\pgfqpoint{.5\pgf@xc}{0\pgf@yc}}% found by trial and error + {\pgfqpoint{.8875\pgf@xc}{.775\pgf@yc}}% found by trial and error + {\pgfqpoint{\pgf@xc}{\pgf@yc}}% + }% + \fi% + }% +} + + + + +% Append a sine curve between 0 and \pi/2 to the path. +% +% #1 = vector, describing the width and height of the curve +% +% Description: +% +% This command appends a sine curve in the interval 0 and \pi/2 to the +% current path. The sine curve ends at currentpoint+#1. +% +% Examples: +% +% % One complete sine in the interval [0,\pi] +% \pgfpathmoveto{\pgfpointorigin} +% \pgfpathsine{\pgfpoint{1.57cm}{1cm}} +% \pgfpathcosine{\pgfpoint{3.141cm}{0cm}} + +\def\pgfpathsine#1{% + {% + \pgf@process{#1}% untransformed + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@pt@x=\pgf@path@lastx% evil trickery to transform to the last point + \pgf@pt@y=\pgf@path@lasty% + \pgfpathcurveto% + {\pgfqpoint{.31831\pgf@xc}{.5\pgf@yc}}% found by trial and error + {\pgfqpoint{.63503\pgf@xc}{\pgf@yc}}% found by trial and error + {\pgfqpoint{\pgf@xc}{\pgf@yc}}% + }% +} + +% Append a cosine curve between 0 and \pi/2 to the path. +% +% #1 = vector, describing the width and height of the curve +% +% Examples: +% +% % One complete sine in the interval [0,\pi] +% \pgfpathmoveto{\pgfpointorigin} +% \pgfpathsine{\pgfpoint{1.57cm}{1cm}} +% \pgfpathcosine{\pgfpoint{3.141cm}{0cm}} + +\def\pgfpathcosine#1{% + {% + \pgf@process{#1}% untransformed + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@pt@x=\pgf@path@lastx% evil trickery to transform to the last point + \pgf@pt@y=\pgf@path@lasty% + \pgfpathcurveto% + {\pgfqpoint{.36497\pgf@xc}{0pt}}% found by trial and error + {\pgfqpoint{.68169\pgf@xc}{.5\pgf@yc}}% found by trial and error + {\pgfqpoint{\pgf@xc}{\pgf@yc}}% + }% +} + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathprocessing.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathprocessing.code.tex new file mode 100644 index 00000000000..a8da0ca9410 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathprocessing.code.tex @@ -0,0 +1,465 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorepathprocessing.code.tex,v 1.7 2008/01/23 15:22:29 tantau Exp $ + + + + + +% Extract start and end vectors of a path +% +% #1 = a macro that stores a path +% +% Description: +% +% This command will extract the first and second coordinate on the +% path as well as the last and second-last. These coordinates will be +% put in the pgfpoint-macros \pgfpointfirstonpath, +% \pgfpointsecondonpath, \pgfpointsecondlastonpath, and +% \pgfpointlastonpath. If the path is empty, these macros are set to +% \pgfpointorigin. +% +% Example: +% +% \pgfsyssoftpath@moveto{0}{0} +% \pgfsyssoftpath@lineto{10}{10} +% \pgfsyssoftpath@curveto{20}{20}{30}{30}{40}{40} +% \pgfsyssoftpath@getcurrentpath\mypath +% \pgfprocesspathextractpoints\mypath +% +% % \pgfpointfirstonpath is now \pgfpoint{0}{0} +% % \pgfpointsecondonpath is now \pgfpoint{10bp}{10bp} +% % \pgfpointsecondlastonpath is now \pgfpoint{30bp}{30bp} +% % \pgfpointlastonpath is now \pgfpoint{40bp}{40bp} + +\def\pgfprocesspathextractpoints#1{% + \ifx#1\pgfutil@empty% + \let\pgfpointfirstonpath=\pgfpointorigin% + \let\pgfpointsecondonpath=\pgfpointorigin% + \let\pgfpointsecondlastonpath=\pgfpointorigin% + \let\pgfpointlastonpath=\pgfpointorigin% + \else% + \expandafter\pgf@extractprocessorfirst#1\pgf@stop% + \fi% +} + +\def\pgf@extractprocessorfirst#1#2#3#4{% + \def\pgfpointfirstonpath{\pgfqpoint{#2}{#3}}% + \ifx#4\pgf@stop% + % pretty short path... + \let\pgfpointsecondonpath=\pgfpointfirstonpath% + \let\pgfpointsecondlastonpath=\pgfpointfirstonpath% + \let\pgfpointlastonpath=\pgfpointfirstonpath% + \let\next=\pgfutil@gobble% + \else + \let\next=\pgf@extractprocessorsecond% + \fi% + \next#4% +} + +\def\pgf@extractprocessorsecond#1{% + \ifx#1\pgfsyssoftpath@movetotoken% + % Reset things... + \let\pgf@next=\pgf@extractprocessorfirst% + \else% + \let\pgf@next=\pgf@@extractprocessorsecond% + \fi% + \pgf@next#1% +} +\def\pgf@@extractprocessorsecond#1#2#3#4{% + \def\pgfpointsecondonpath{\pgfqpoint{#2}{#3}}% + \let\pgfpointsecondlastonpath=\pgfpointfirstonpath% + \let\pgfpointlastonpath=\pgfpointsecondonpath% + \ifx#4\pgf@stop% + % short path... + \let\next=\pgfutil@gobble% + \else + \let\next=\pgf@extractprocessorother% + \fi% + \next#4% +} + +\def\pgf@extractprocessorother#1{% + \ifx#1\pgfsyssoftpath@movetotoken% + % Reset things... + \let\pgf@next=\pgf@extractprocessorfirst% + \else% + \let\pgf@next=\pgf@@extractprocessorother% + \fi% + \pgf@next#1% +} +\def\pgf@@extractprocessorother#1#2#3#4{% + \let\pgfpointsecondlastonpath=\pgfpointlastonpath% + \def\pgfpointlastonpath{\pgfqpoint{#2}{#3}}% + \ifx#4\pgf@stop% + % end! + \let\next=\pgfutil@gobble% + \fi% + \next#4% +} + + + +% Check for closepath and rectangles +% +% #1 = a macro that stores a path +% #2 = command to be executed when a closepath or a rectangle is encountered +% +% Example: +% +% \pgfsyssoftpath@moveto{0}{0} +% \pgfsyssoftpath@lineto{10}{10} +% \pgfsyssoftpath@curveto{20}{20}{30}{30}{40}{40} +% \pgfsyssoftpath@getcurrentpath\mypath +% \pgfprocesscheckclosed{\mypath}{\pgf@drawarrowsfalse} + +\def\pgfprocesscheckclosed#1#2{% + {% + \global\let\pgf@proc@todo=\relax% + \let\pgfsyssoftpath@movetotoken=\pgfutil@gobbletwo% + \let\pgfsyssoftpath@linetotoken=\pgfutil@gobbletwo% + \let\pgfsyssoftpath@curvetosupportatoken=\pgfutil@gobbletwo% + \let\pgfsyssoftpath@curvetosupportbtoken=\pgfutil@gobbletwo% + \let\pgfsyssoftpath@curvetotoken=\pgfutil@gobbletwo% + \def\pgfsyssoftpath@rectcornertoken{\gdef\pgf@proc@todo{#2}\pgfutil@gobbletwo}% + \def\pgfsyssoftpath@rectsizetoken{\gdef\pgf@proc@todo{#2}\pgfutil@gobbletwo}% + \def\pgfsyssoftpath@closepathtoken{\gdef\pgf@proc@todo{#2}\pgfutil@gobbletwo}% + #1% + }% + \pgf@proc@todo% +} + + +% Resolve specialround +% +% #1 = a macro that stores a path +% #2 = a macro that stores the new path +% +% Description: +% +% Resolves all specialround tokens. When such a token is encountered, +% the objective is to replace the next corner by a rounded corner. +% + +\def\pgfprocessround#1#2{% + % first, check whether #1 contains \pgfsyssoftpath@specialroundtoken. + % if not, do quick assignment! + \expandafter\pgf@processroundcheck\expandafter#1\expandafter#2#1\pgfsyssoftpath@specialroundtoken\pgf@stop% +} + +\def\pgf@processroundcheck#1#2#3\pgfsyssoftpath@specialroundtoken#4\pgf@stop{% + \def\pgf@test{#4}% + \ifx\pgf@test\pgfutil@empty% + % ok, nothing to be done! + \let#2=#1% + \else% + % very well... + \pgf@@processround#1#2% + \fi% +} + + +\def\pgf@@processround#1#2{% + \let\pgfprocess@newpath\pgfutil@empty% + \let\pgfprocess@moveto\pgfutil@empty% + \let\pgfprocess@firstto\pgfutil@empty% + \let\pgfprocess@segment\pgfutil@empty% + \pgf@xa=0pt% + \pgf@ya=0pt% + \expandafter\pgfprocess@round#1\pgf@stop{0pt}{0pt}% + \expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@moveto}% + \expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@segment}% + \let#2=\pgfprocess@newpath% +} + +\def\pgfprocess@round#1#2#3{% + \ifx#1\pgf@stop% + \let\next=\relax% + \else% + \ifx#1\pgfsyssoftpath@specialroundtoken% + \def\pgfprocess@savex{#2}% + \def\pgfprocess@savey{#3}% + \let\next=\pgfprocess@specialround% + \ifdim#2=0pt% + \ifdim#3=0pt% + \let\next=\pgfprocess@round% skip! + \fi% + \fi% + \else% + \ifx\pgfprocess@firstto\pgfutil@empty% + \def\pgfprocess@firstto{{#2}{#3}}% + \fi% + \pgf@xa=#2% + \pgf@ya=#3% + \ifx#1\pgfsyssoftpath@movetotoken% + % ok, move old segment to newpath + \expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@moveto}% + \expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@segment}% + \def\pgfprocess@moveto{#1{#2}{#3}}% + \let\pgfprocess@firstto=\pgfutil@empty% + \let\pgfprocess@segment=\pgfutil@empty% + \else% + \pgfutil@g@addto@macro\pgfprocess@segment{#1{#2}{#3}}% + \fi% + \let\next=\pgfprocess@round% + \fi% + \fi% + \next% +} + +\def\pgfprocess@specialround#1#2#3{% + \ifx\pgfprocess@firstto\pgfutil@empty% + \def\pgfprocess@firstto{{#2}{#3}}% + \fi% + \let\next=\pgfprocess@round% default: do nothing + \ifx#1\pgfsyssoftpath@linetotoken% + % Ok, round a lineto + \let\next=\pgfprocess@specialroundcope% + \else% + \ifx#1\pgfsyssoftpath@curvetosupportatoken% + % Ok, round a curveto. + \let\next=\pgfprocess@specialroundcurveto% + \else% + \ifx#1\pgfsyssoftpath@closepathtoken% + % Ok, round a closepath (this is tricky...) + \let\next=\pgfprocess@specialroundclose% + \fi% + \fi% + \fi% + \next#1{#2}{#3}% +}% + +\def\pgfprocess@specialroundcope#1#2#3#4#5#6{% + \let\next=\pgfprocess@round% do nothing by default + \let\pgfprocess@continueafterrounding=\pgfprocess@round% + \ifx#4\pgfsyssoftpath@linetotoken% + % ok, let's get kicking... + \pgf@xc=#5% + \pgf@yc=#6% + \let\next=\pgfprocess@@specialround% + \else% + \ifx#4\pgfsyssoftpath@curvetosupportatoken% + \pgf@xc=#5% + \pgf@yc=#6% + \let\next=\pgfprocess@@specialround% + \else% + \ifx#4\pgfsyssoftpath@closepathtoken% + \pgf@xc=#5% + \pgf@yc=#6% + \let\next=\pgfprocess@@specialround% + \else + \ifx#4\pgfsyssoftpath@specialroundtoken% + \let\next=\pgfprocess@@findrightcoordinates% + \fi% + \fi% + \fi% + \fi% + \next#1{#2}{#3}#4{#5}{#6}% +} + +\def\pgfprocess@@findrightcoordinates#1#2#3#4#5#6#7#8#9{% + \pgf@xc=#8% + \pgf@yc=#9% + \pgfprocess@@specialround#1{#2}{#3}#4{#5}{#6}#7{#8}{#9}% +} + +\def\pgfprocess@@specialround#1#2#3{% + \pgfutil@g@addto@macro\pgfprocess@segment{#1}% + % calculate start coordinate of the curve + \pgf@xb=#2% + \pgf@yb=#3% + % + \edef\pgf@marshal% + {\noexpand\pgfpointlineatdistance{\pgfprocess@savex}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + {\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}}% + \pgf@process{\pgf@marshal}% + \pgf@xa=\pgf@x% save start point of added curve + \pgf@ya=\pgf@y% + \edef\pgfprocess@addition{{\the\pgf@x}{\the\pgf@y}}% + \expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% + % + % now add curve + % + \edef\pgf@marshal% + {\noexpand\pgfpointlineatdistance{\pgfprocess@savey}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}}% + \pgf@process{\pgf@marshal}% + \pgf@xc=\pgf@x% save end point of added curve + \pgf@yc=\pgf@y% + % calculate first support: + {% + \pgf@x=\pgf@xb% + \pgf@y=\pgf@yb% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@y by-\pgf@ya% + \advance\pgf@xa by 0.555\pgf@x% + \advance\pgf@ya by 0.555\pgf@y% + \edef\pgfprocess@addition{\noexpand\pgfsyssoftpath@curvetosupportatoken{\the\pgf@xa}{\the\pgf@ya}}% + \expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% + }% + % calculate second support: + {% + \pgf@x=\pgf@xb% + \pgf@y=\pgf@yb% + \advance\pgf@x by-\pgf@xc% + \advance\pgf@y by-\pgf@yc% + \advance\pgf@xc by 0.555\pgf@x% + \advance\pgf@yc by 0.555\pgf@y% + \edef\pgfprocess@addition{\noexpand\pgfsyssoftpath@curvetosupportbtoken{\the\pgf@xc}{\the\pgf@yc}}% + \expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% + }% + % add end: + \edef\pgfprocess@addition{\noexpand\pgfsyssoftpath@curvetotoken{\the\pgf@xc}{\the\pgf@yc}}% + \expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% + % + % continue! + % + \pgf@xa=#2% + \pgf@ya=#3% + \pgfprocess@continueafterrounding% +} + +\def\pgfprocess@specialroundcurveto#1#2#3#4#5#6{% + \pgfutil@g@addto@macro\pgfprocess@segment{#1{#2}{#3}#4{#5}{#6}}% supports + \pgf@xa=#5% + \pgf@ya=#6% + \pgfprocess@specialroundcope} + +\def\pgfprocess@specialroundclose{% + \let\next=\pgfprocess@round% + \ifx\pgfprocess@moveto\pgfutil@empty% + \else% + \ifx\pgfprocess@firstto\pgfutil@empty% + \else% + \expandafter\pgfprocess@@specialclosetarget\pgfprocess@firstto% + \let\pgfprocess@continueafterrounding=\pgfprocess@cleanupafterclose% + \edef\next{% + \noexpand\pgfprocess@@specialround% + \expandafter\expandafter\expandafter\noexpand\expandafter\pgfprocess@@specialclosemoveto\pgfprocess@moveto% + }% + \fi% + \fi% + \next% +} + +\def\pgfprocess@@specialclosetarget#1#2{% + \pgf@xc=#1% + \pgf@yc=#2% +} + +\def\pgfprocess@@specialclosemoveto#1#2#3{% + \pgfsyssoftpath@linetotoken{#2}{#3}% +} + + +\def\pgfprocess@cleanupafterclose#1#2#3{% + \edef\pgfprocess@moveto{\noexpand\pgfsyssoftpath@movetotoken{\the\pgf@xc}{\the\pgf@yc}}% + \edef\pgf@marshal{\noexpand\pgfprocess@round\noexpand\pgfsyssoftpath@closepathtoken{\the\pgf@xc}{\the\pgf@yc}}% + \pgf@marshal% +} + + +% Replace start and end coordinates of a path +% +% #1 = new start coordinate +% #2 = new end coordinate +% +% Description: +% +% This command will replace the first and last coordinates on a path +% by the given coordinates. +% +% Example: +% +% \pgfsyssoftpath@moveto{0}{0} +% \pgfsyssoftpath@lineto{10}{10} +% \pgfsyssoftpath@curveto{20}{20}{30}{10}{40}{0} +% \pgfsyssoftpath@getcurrentpath\mypath +% \pgfsetlinewidth{2pt} +% \pgfusepath{stroke} +% \pgfprocesspathextractpoints{\mypath} +% \pgfprocesspathreplacestartandend{\mypath} +% {\pgfpointlineatdistance{2pt}{\pgfpointfirstonpath}{\pgfpointsecondonpath}}% +% {\pgfpointlineatdistance{2pt}{\pgfpointlastonpath}{\pgfpointsecondlastonpath}}% +% \pgfsyssoftpath@setcurrentpath\mypath +% \pgfsetlinewidth{1pt} +% \color{red} +% \pgfusepath{stroke} + +\def\pgfprocesspathreplacestartandend#1#2#3{% + \ifx#1\pgfutil@empty% + \else% + {% + % We (mis)use the current path to store (in a buffered manner) the + % rest path. + \pgfsyssoftpath@getcurrentpath\pgf@replace@origpath% + \let\pgf@prepath=\pgfutil@empty% + \pgf@process{#3}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#2}% + \expandafter\pgf@replaceprocessfirst#1\pgf@stop% + \pgfsyssoftpath@getcurrentpath\pgf@restpath% + \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef% + \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter#1% + \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter\pgf@prepath% + \expandafter\pgf@newstart\pgf@restpath}% + % Restore current path + \pgfsyssoftpath@setcurrentpath\pgf@replace@origpath% + }% + \fi% +} + +\def\pgf@replaceprocessfirst#1#2#3#4{% + \def\pgf@origstart{#1{#2}{#3}}% + \edef\pgf@newstart{\noexpand#1{\the\pgf@x}{\the\pgf@y}}% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \ifx#4\pgf@stop% + \let\pgf@next=\pgfutil@gobble% + \else% + \let\pgf@next=\pgf@replaceprocessother% + \let\pgf@@next=\pgf@@replaceprocessother% + \fi% + \pgf@next#4% +} + +\def\pgf@replaceprocessother#1{% + \ifx#1\pgfsyssoftpath@movetotoken% + \pgf@replace@handle@move% + \fi% + \pgf@@next#1% +} +\def\pgf@@replaceprocessother#1#2#3#4{% + \ifx#4\pgf@stop% + \edef\pgf@restpathaddition{{\noexpand#1{\the\pgf@xa}{\the\pgf@ya}}}% + \expandafter\pgfsyssoftpath@addtocurrentpath\pgf@restpathaddition% + \let\pgf@next=\pgfutil@gobble% + \else% + \pgfsyssoftpath@addtocurrentpath{#1{#2}{#3}}% + \fi% + \pgf@next#4% +} + +\def\pgf@replace@handle@move{% + \pgfsyssoftpath@getcurrentpath\pgf@restpath% + % Arggghh! Must reset everything! + \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef% + \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\pgf@prepath% + \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter\pgf@prepath% + \expandafter\pgf@origstart\pgf@restpath}% + % Redo first. + \let\pgf@@next=\pgf@replaceprocessfirst% +} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage.code.tex new file mode 100644 index 00000000000..e14a4e44447 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage.code.tex @@ -0,0 +1,228 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorepathusage.code.tex,v 1.11 2008/01/23 13:15:28 tantau Exp $ + + +% Stroke/fill/clip/etc. the current path. Depending on the options, +% the current path will be stroked/filled/clipped/etc. If no options +% are given, the path is stroked. If multiple options are given, all +% of them are performed (in a sensible order). +% +% #1 = action(s) to be applied to the current path. Valid actions are: +% stroke - strokes the path. If no options are given, this is the +% default. +% draw - same as stroke. +% fill - fills the path. +% clip - clip the path. +% discard - Discards the path. Same effect as having an empty +% options list. +% +% Example: +% +% % Draws an edge. +% \pgfpathmoveto{\pgfxy(0,0)} +% \pgfpathlineto{\pgfxy(0,1)} +% \pgfpathlineto{\pgfxy(1,0)} +% \pgfusepath{stroke} + +\pgfkeys{ + /pgf/stroke/.code=\def\pgf@up@stroke{stroke}, + /pgf/draw/.code=\def\pgf@up@stroke{stroke}, + /pgf/fill/.code=\def\pgf@up@fill{fill}, + /pgf/clip/.code=\def\pgf@up@clip{clip}, + /pgf/discard/.code=, + /pgf/use as bounding box/.code=\def\pgf@up@bb{\pgf@relevantforpicturesizefalse} +} + +\def\pgfusepath#1{% + \let\pgf@up@stroke\pgfutil@empty% + \let\pgf@up@fill\pgfutil@empty% + \let\pgf@up@clip\pgfutil@empty% + \let\pgf@up@discard\pgfutil@empty% + \let\pgf@up@bb\pgfutil@empty% + \pgfset{#1}% + \expandafter\def\expandafter\pgf@up@action\expandafter{\csname pgfsys@\pgf@up@fill\pgf@up@stroke\endcsname}% + \ifx\pgf@up@stroke\pgfutil@empty% + \ifx\pgf@up@fill\pgfutil@empty% + \ifx\pgf@up@clip\pgfutil@empty% + \let\pgf@up@action=\pgfutil@empty% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \else% + % only clipping + \let\pgf@up@action=\pgfsys@discardpath% + \fi% + \fi% + \fi% + \pgfsyssoftpath@getcurrentpath\pgf@last@processed@path + \pgfprocessround{\pgf@last@processed@path}{\pgf@last@processed@path}% change the path + \pgfsyssoftpath@setcurrentpath\pgf@last@processed@path% + % + % Check whether the path is stroked. If so, add half the line width + % to the bounding box. + % + \ifpgf@relevantforpicturesize% + \ifx\pgf@up@stroke\pgfutil@empty% + \else% + \ifdim\pgf@picmaxx=-16000pt\relax% + \else% + \pgf@x=\pgf@pathminx\advance\pgf@x by-.5\pgflinewidth% + \ifdim\pgf@x<\pgf@picminx\global\pgf@picminx\pgf@x\fi% + \pgf@y=\pgf@pathminy\advance\pgf@y by-.5\pgflinewidth% + \ifdim\pgf@y<\pgf@picminy\global\pgf@picminy\pgf@y\fi% + \pgf@x=\pgf@pathmaxx\advance\pgf@x by.5\pgflinewidth% + \ifdim\pgf@x>\pgf@picmaxx\global\pgf@picmaxx\pgf@x\fi% + \pgf@y=\pgf@pathmaxy\advance\pgf@y by.5\pgflinewidth% + \ifdim\pgf@y>\pgf@picmaxy\global\pgf@picmaxy\pgf@y\fi% + \fi% + \fi% + \fi% + % + \ifx\pgf@up@clip\pgfutil@empty% + \ifx\pgf@up@stroke\pgfutil@empty% + \pgfsyssoftpath@invokecurrentpath% + \pgfsyssoftpath@getcurrentpath\pgf@last@used@path% + \pgf@up@action% + \else% + \pgf@check@for@arrows% + \ifpgf@drawarrows% + \pgf@shorten@path@as@needed% + \pgfsyssoftpath@invokecurrentpath% + \pgfsyssoftpath@getcurrentpath\pgf@last@used@path% + \pgf@up@action% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \pgf@add@arrows@as@needed% + \else% + \pgfsyssoftpath@invokecurrentpath% + \pgfsyssoftpath@getcurrentpath\pgf@last@used@path% + \pgf@up@action% + \fi% + \fi% + \else% + \pgfsyssoftpath@invokecurrentpath% + \pgfsyssoftpath@getcurrentpath\pgf@last@used@path% + \pgfsys@clipnext% + \pgf@up@action% + \pgf@relevantforpicturesizefalse% + \fi% + \pgf@up@bb% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \pgf@resetpathsizes% + \ignorespaces% +} + + +% Shorten start/end of paths by a certain amount. +% +% #1 = amount by which paths should be shortened. +% +% Example: +% +% \pgfpathmoveto{\pgfpointorigin} +% \pgfpathlineto{\pgfpoint{10pt}{0pt} +% +% % The following has the same effect: +% \pgfsetshortenstart{1pt} +% \pgfpathmoveto{\pgfpointorigin} +% \pgfpathlineto{\pgfpoint{11pt}{0pt} + +\def\pgfsetshortenstart#1{\pgfmathsetlength\pgf@shorten@start@additional{#1}} +\def\pgfsetshortenend#1{\pgfmathsetlength\pgf@shorten@end@additional{#1}} + +\newif\ifpgf@drawarrows + +\def\pgf@check@for@arrows{% + \pgf@drawarrowsfalse% + \ifx\pgf@startarrow\pgfutil@empty\else\pgf@drawarrowstrue\fi% + \ifx\pgf@endarrow\pgfutil@empty\else\pgf@drawarrowstrue\fi% + \ifdim\pgf@shorten@end@additional=0pt\relax\else\pgf@drawarrowstrue\fi% + \ifdim\pgf@shorten@start@additional=0pt\relax\else\pgf@drawarrowstrue\fi% + \ifpgf@drawarrows% + \pgfsyssoftpath@getcurrentpath\pgf@arrowpath% + \ifx\pgf@arrowpath\pgfutil@empty% + \pgf@drawarrowsfalse% + \else% + \pgfprocesscheckclosed{\pgf@arrowpath}{\pgf@drawarrowsfalse}% + \fi% + \fi% +} + +\newdimen\pgf@shorten@end@additional +\newdimen\pgf@shorten@start@additional + +\let\pgf@shorten@end=\pgfutil@empty +\let\pgf@shorten@start=\pgfutil@empty + +\def\pgf@shorten@path@as@needed{% + \pgfprocesspathextractpoints{\pgf@arrowpath}% + \let\pgf@arrow@next=\pgf@shorten@now% + \ifx\pgf@shorten@start\pgfutil@empty% + \ifx\pgf@shorten@end\pgfutil@empty% + \ifdim\pgf@shorten@end@additional=0pt\relax% + \ifdim\pgf@shorten@start@additional=0pt\relax% + \let\pgf@arrow@next=\relax% + \fi% + \fi% + \fi% + \fi% + \pgf@arrow@next% +} + +\def\pgf@shorten@now{% + {% + \pgf@x=0pt% + \pgf@shorten@start% + \advance\pgf@x by\pgf@shorten@start@additional% + \pgf@xc=\pgf@x% + \pgfpointlineatdistance{\pgf@xc}{\pgfpointfirstonpath}{\pgfpointsecondonpath}% + \global\pgf@xb=\pgf@x% + \global\pgf@yb=\pgf@y% + \pgf@process{\pgfpointsecondonpath}% + \global\advance\pgf@x by\pgf@xa% + \global\advance\pgf@y by\pgf@ya% + }% + \edef\pgfpointfirstonpath{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + \edef\pgfpointsecondonpath{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + {% + \pgf@x=0pt% + \pgf@shorten@end% + \advance\pgf@x by\pgf@shorten@end@additional% + \pgf@xc=\pgf@x% + \pgfpointlineatdistance{\pgf@xc}{\pgfpointlastonpath}{\pgfpointsecondlastonpath}% + \global\pgf@xb=\pgf@x% + \global\pgf@yb=\pgf@y% + \pgf@process{\pgfpointsecondlastonpath}% + \global\advance\pgf@x by\pgf@xa% + \global\advance\pgf@y by\pgf@ya% + }% + \edef\pgfpointlastonpath{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + \edef\pgfpointsecondlastonpath{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfprocesspathreplacestartandend{\pgf@arrowpath}{\pgfpointfirstonpath}{\pgfpointlastonpath}% + \pgfsyssoftpath@setcurrentpath\pgf@arrowpath% +} + +\def\pgf@add@arrows@as@needed{% + \ifx\pgf@startarrow\pgfutil@empty% + \else% + \pgflowlevelobj% + {\pgftransformarrow{\pgfpointsecondonpath}{\pgfpointfirstonpath}} + {\pgf@startarrow}% + \fi% + \ifx\pgf@endarrow\pgfutil@empty% + \else% + \pgflowlevelobj% + {\pgftransformarrow{\pgfpointsecondlastonpath}{\pgfpointlastonpath}} + {\pgf@endarrow}% + \fi% +} + +\let\pgf@startarrow=\pgfutil@empty +\let\pgf@endarrow=\pgfutil@empty + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.code.tex new file mode 100644 index 00000000000..3ab2b4e009b --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.code.tex @@ -0,0 +1,1173 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorepoints.code.tex,v 1.13 2008/02/03 19:37:26 tantau Exp $ + +\newdimen\pgf@picminx +\newdimen\pgf@picmaxx +\newdimen\pgf@picminy +\newdimen\pgf@picmaxy + +\newdimen\pgf@pathminx +\newdimen\pgf@pathmaxx +\newdimen\pgf@pathminy +\newdimen\pgf@pathmaxy + +\newif\ifpgf@relevantforpicturesize + +\def\pgf@process#1{{#1\global\pgf@x=\pgf@x\global\pgf@y=\pgf@y}} + +% Save a point. +% +% #1 = macro for storing point. +% #2 = code for point (should define x and y) +% +% Example: +% +% \pgfextract@process\mypoint{\pgf@x=10pt \pgf@y10pt} +% \pgfextract@process\myarcpoint{\pgfpointpolar{30}{5cm and 2cm}} + +\def\pgfextract@process#1#2{% + \pgf@process{#2}% + \edef#1{\noexpand\pgf@x\the\pgf@x\noexpand\pgf@y\the\pgf@y}% +} +% This needed until old shapes code changed. +\let\pgfsavepgf@process\pgfextract@process% + + +% Return a point +% +% #1 = x-coordinate of the point +% #2 = y-coordinate of the point +% +% x = #1 +% y = #2 +% +% Example: +% +% \pgfpathmoveto{\pgfpoint{2pt+3cm}{3cm}} + +\def\pgfpoint#1#2{% + \pgfmathsetlength\pgf@x{#1}% + \pgfmathsetlength\pgf@y{#2}\ignorespaces} + + +% Quickly a point +% +% #1 = x-coordinate of the point (no calculations done) +% #2 = y-coordinate of the point (no calculations done) +% +% x = #1 +% y = #2 +% +% Example: +% +% \pgfpathmoveto{\pgfqpoint{2pt}{3cm}} + +\def\pgfqpoint#1#2{\pgf@x=#1\pgf@y=#2} + + + +% Return the origin. +% +% x = 0 +% y = 0 +% +% Example: +% +% \pgfpathmoveto{\pgfpointorigin} + +\def\pgfpointorigin{\pgf@x=0pt\pgf@y=\pgf@x\ignorespaces} + + + +% Return a transformed point +% +% #1 = a point +% +% Description: +% +% This command applies pgf's current transformation matrix to the +% given point. Normally, this is done automatically by commands like +% lineto or moveto, but sometimes you may wish to access a transformed +% point yourself. In the below example, this command is used for a low level +% coordinate system shift. +% +% In addition to applying the transformation matrix to the given +% point, this function also applies the pre- and post-morphing +% macros. +% +% Example: +% +% \begin{pgflowleveltransformshiftscope}{\pgfpointtransformed{\pgfpointorigin}} +% \pgfbox[center,center]{Hi!} +% \end{pgflowleveltransformshiftscope} + +\def\pgfpointtransformed#1{% + \pgf@process{% + #1% + \pgfmorph@prelist% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \pgfmorph@postlist% + }% +} + + +% Return the difference vector of two points. +% +% #1 = start of vector +% #2 = end of vector +% +% x = x-component of difference +% y = y-component of difference +% +% Example: +% +% \pgfpathmoveto{\pgfpointdiff{\pgfpointxy{1}{1}}{\pgfpointxy{2}{3}}} + +\def\pgfpointdiff#1#2{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#2}% + \advance\pgf@x by-\pgf@xa\relax% + \advance\pgf@y by-\pgf@ya\relax\ignorespaces} + +% Add two vectors. +% +% #1 = first vector +% #2 = second vector +% +% x = x-component of addition +% y = y-component of addition +% +% Example: +% +% \pgfpathmoveto{\pgfpointadd{\pgfpointxy{0}{1}}{\pgfpointxy{2}{3}}} + +\def\pgfpointadd#1#2{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#2}% + \advance\pgf@x by\pgf@xa% + \advance\pgf@y by\pgf@ya} + + + +% Multiply a vector by a factor. +% +% #1 = factor +% #2 = vector +% +% Example: +% +% \pgfpointscale{2}{\pgfpointxy{0}{1}} + +\def\pgfpointscale#1#2{% + \pgf@process{#2}% + \pgf@x=#1\pgf@x% + \pgf@y=#1\pgf@y% +} + + +% The intersection of two lines +% +% #1 = point on first line +% #2 = another point on first line +% #3 = point on second line +% #4 = another point on second line +% +% Returns the intersection of the two lines. If there is no +% intersection or if the points #1 and #2 or the points #3 and #4 are +% identical, the behaviour is not specified. +% +% Example: +% +% \pgfpointintersectionoflines{\pgfpointxy{0}{1}}{\pgfpointxy{1}{0}}{\pgfpointxy{2}{2}}{\pgfpointxy{3}{4}} + +\def\pgfpointintersectionoflines#1#2#3#4{% + { + % + % Compute orthogonal vector to #1--#2 + % + \pgf@process{#2}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#1}% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + \pgf@ya=-\pgf@ya% + % Normalise a bit + \c@pgf@counta=\pgf@xa% + \ifnum\c@pgf@counta<0\relax% + \c@pgf@counta=-\c@pgf@counta\relax% + \fi% + \c@pgf@countb=\pgf@ya% + \ifnum\c@pgf@countb<0\relax% + \c@pgf@countb=-\c@pgf@countb\relax% + \fi% + \advance\c@pgf@counta by\c@pgf@countb\relax% + \divide\c@pgf@counta by 65536\relax% + \ifnum\c@pgf@counta>0\relax% + \divide\pgf@xa by\c@pgf@counta\relax% + \divide\pgf@ya by\c@pgf@counta\relax% + \fi% + % + % Compute projection + % + \pgf@xc=\pgf@sys@tonumber{\pgf@ya}\pgf@x% + \advance\pgf@xc by\pgf@sys@tonumber{\pgf@xa}\pgf@y% + % + % The orthogonal vector is (\pgf@ya,\pgf@xa) + % + % + % Compute orthogonal vector to #3--#4 + % + \pgf@process{#4}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@process{#3}% + \advance\pgf@xb by-\pgf@x% + \advance\pgf@yb by-\pgf@y% + \pgf@yb=-\pgf@yb% + % Normalise a bit + \c@pgf@counta=\pgf@xb% + \ifnum\c@pgf@counta<0\relax% + \c@pgf@counta=-\c@pgf@counta\relax% + \fi% + \c@pgf@countb=\pgf@yb% + \ifnum\c@pgf@countb<0\relax% + \c@pgf@countb=-\c@pgf@countb\relax% + \fi% + \advance\c@pgf@counta by\c@pgf@countb\relax% + \divide\c@pgf@counta by 65536\relax% + \ifnum\c@pgf@counta>0\relax% + \divide\pgf@xb by\c@pgf@counta\relax% + \divide\pgf@yb by\c@pgf@counta\relax% + \fi% + % + % Compute projection + % + \pgf@yc=\pgf@sys@tonumber{\pgf@yb}\pgf@x% + \advance\pgf@yc by\pgf@sys@tonumber{\pgf@xb}\pgf@y% + % + % The orthogonal vector is (\pgf@yb,\pgf@xb) + % + % Setup transformation matrx (this is just to use the matrix + % inversion) + % + \pgfsettransform{{\pgf@sys@tonumber\pgf@ya}{\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@xb}{0pt}{0pt}}% + \pgftransforminvert% + \pgf@process{\pgfpointtransformed{\pgfpoint{\pgf@xc}{\pgf@yc}}}% + }% +} + + +% The intersection of two circles +% +% #1 = center of first circle +% #2 = center of second circle +% #3 = radius of first circle +% #4 = radius of second circle +% #5 = solution number +% +% Returns the intersection of the two circles. If #5 is to "1", the +% first intersection is returned, otherwise the second. If the circles +% do not intersect, an error may occur. +% +% Example: +% +% \pgfpointintersectionofcircles{\pgfpointxy{0}{1}}{\pgfpointxy{1}{0}}{1cm}{1cm}{1} + +\def\pgfpointintersectionofcircles#1#2#3#4#5{% + {% + % Store first point in (xa,ya) and radius in xc. + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgfmathsetlength{\pgf@xc}{#3}% + % Store second point in (xb,yb) and radius in yc. + \pgf@process{#2}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgfmathsetlength{\pgf@yc}{#4}% + % + % Ok, now make numbers smaller, in case they are too large + % + \c@pgf@counta=1\relax% + \loop% + \pgf@scale@downfalse% + \ifdim\pgf@xc>50pt\relax% + \pgf@scale@downtrue% + \fi% + \ifdim\pgf@yc>50pt\relax% + \pgf@scale@downtrue% + \fi% + \ifpgf@scale@down% + \multiply\c@pgf@counta by2\relax% + \divide\pgf@xa by2\relax% + \divide\pgf@ya by2\relax% + \divide\pgf@xb by2\relax% + \divide\pgf@yb by2\relax% + \divide\pgf@xc by2\relax% + \divide\pgf@yc by2\relax% + \repeat% + % The following code is taken from the Dr. Math internet forum: + % + % Let the centers be: (a,b), (c,d) + % Let the radii be: r, s + % + % e = c - a [difference in x coordinates] + % f = d - b [difference in y coordinates] + % p = sqrt(e^2 + f^2) [distance between centers] + % k = (p^2 + r^2 - s^2)/(2p) [distance from center 1 to line + % joining points of intersection] + % x = a + ek/p + (f/p)sqrt(r^2 - k^2) + % y = b + fk/p - (e/p)sqrt(r^2 - k^2) + % OR + % x = a + ek/p - (f/p)sqrt(r^2 - k^2) + % y = b + fk/p + (e/p)sqrt(r^2 - k^2) + % + % Since we are running low on registers, use + % \dimen0 for e + % \dimen1 for f + % \dimen2 for p + % \dimen3 for p^2 + % \dimen4 for k + % \dimen5 for 1/p + % \dimen6 for sqrt(r^2 - k^2) + % \dimen7 for k^2 + % \dimen8 for k/p + % \dimen9 for sqrt(r^2 - k^2)/p + % Also note that: + % \pgf@xa for a + % \pgf@ya for b + % \pgf@xb for c + % \pgf@yb for d + % \pgf@xc for r + % \pgf@yc for s + % + % Now: + % e = c - a + \dimen0=\pgf@xb% + \advance\dimen0 by-\pgf@xa% + % f = d - b + \dimen1=\pgf@yb% + \advance\dimen1 by-\pgf@ya% + % p^2 = e^2 + f^2 + \pgf@x=\dimen0\relax% + \pgf@x=\pgf@sys@tonumber{\pgf@x}\pgf@x% + \dimen3=\pgf@x% + \pgf@x=\dimen1\relax% + \advance\dimen3 by\pgf@sys@tonumber{\pgf@x}\pgf@x% + % p = sqrt(p^2) + \pgfmathparse{sqrt(\the\dimen3)}% + \dimen2=\pgfmathresult pt% + % 1/p = 1/p + \pgfmathreciprocal@{\pgfmathresult}% + \dimen5=\pgfmathresult pt% + % k = (p^2 + r^2 - s^2)/(2p) + \dimen4=\dimen3\relax% + \pgf@x=\pgf@xc% + \advance\dimen4 by\pgf@sys@tonumber{\pgf@x}\pgf@x\relax% + \pgf@x=\pgf@yc% + \advance\dimen4 by-\pgf@sys@tonumber{\pgf@x}\pgf@x\relax% + \dimen4=.5\dimen4% + \dimen4=\pgf@sys@tonumber{\dimen5}\dimen4% + % dimen7 is k^2 + \dimen7=\pgf@sys@tonumber{\dimen4}\dimen4\relax% + % dimen6 is sqrt(r^2 - k^2) + \pgfmathparse{sqrt(\pgf@sys@tonumber{\pgf@xc}\pgf@xc-\the\dimen7)}% + \dimen6=\pgfmathresult pt% + % dimen8 is k/p + \dimen8=\pgf@sys@tonumber{\dimen4}\dimen5\relax% + % dimen9 is sqrt(r^2 - k^2)/p + \dimen9=\pgf@sys@tonumber{\dimen6}\dimen5\relax% + \ifnum#5=1\relax% + % x = a + ek/p + (f/p)sqrt(r^2 - k^2) + \pgf@x=\pgf@xa% + \advance\pgf@x by\pgf@sys@tonumber{\dimen0}\dimen8\relax% + \advance\pgf@x by\pgf@sys@tonumber{\dimen1}\dimen9\relax% + % y = b + fk/p - (e/p)sqrt(r^2 - k^2) + \pgf@y=\pgf@ya% + \advance\pgf@y by\pgf@sys@tonumber{\dimen1}\dimen8\relax% + %temp + \pgf@xb=\pgf@sys@tonumber{\dimen0}\dimen9% + \pgf@xb=-\pgf@xb% + \advance\pgf@y by\pgf@xb\relax% + \else% + % x = a + ek/p - (f/p)sqrt(r^2 - k^2) + \pgf@x=\pgf@xa% + \advance\pgf@x by\pgf@sys@tonumber{\dimen0}\dimen8\relax% + %temp + \pgf@xb=\pgf@sys@tonumber{\dimen1}\dimen9% + \pgf@xb=-\pgf@xb% + \advance\pgf@x by\pgf@xb\relax% + % y = b + fk/p + (e/p)sqrt(r^2 - k^2) + \pgf@y=\pgf@ya% + \advance\pgf@y by\pgf@sys@tonumber{\dimen1}\dimen8\relax% + \advance\pgf@y by\pgf@sys@tonumber{\dimen0}\dimen9\relax% + \fi% + \pgf@x=\c@pgf@counta\pgf@x% + \pgf@y=\c@pgf@counta\pgf@y% + \pgf@process{}% get results outside + }% +} +\newif\ifpgf@scale@down + + +% Returns point on a line from #2 to #3 at time #1. +% +% #1 = a time, where 0 is the start and 1 is the end +% #2 = start point +% #3 = end point +% +% x = x-component of #1*start + (1-#1)*end +% y = y-component of #1*start + (1-#1)*end +% +% Example: +% +% % Middle of (1,1) and (2,3) +% \pgfpathmoveto{\pgfpointlineattime{0.5}{\pgfpointxy{0}{1}}{\pgfpointxy{2}{3}}} + +\def\pgfpointlineattime#1#2#3{% + \pgf@process{#3}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#2}% + \advance\pgf@xa by-\pgf@x\relax% + \advance\pgf@ya by-\pgf@y\relax% + \advance\pgf@x by #1\pgf@xa\relax% + \advance\pgf@y by #1\pgf@ya\relax% + \ignorespaces} + + +% Move point #2 #1 many units in the direction of #3. +% +% #1 = a distance +% #2 = start point +% #3 = end point +% +% x = x-component of start + #1*(normalise(end-start)) +% y = y-component of start + #1*(normalise(end-start)) +% xa = #1*(normalise(end-start)) +% ya = #1*(normalise(end-start)) +% +% Example: +% +% +% \pgfpathmoveto{\pgfpointlineatdistance{2pt}{\pgfpointxy{0}{1}}{\pgfpointxy{2}{3}}} +% \pgfpathlineto{\pgfpointlineatdistance{3pt}{\pgfpointxy{2}{3}}{\pgfpointxy{0}{1}}} + +\def\pgfpointlineatdistance#1#2#3{% + \pgf@process{#2}% + \pgf@xb=\pgf@x\relax% xb/yb = start point + \pgf@yb=\pgf@y\relax% + \pgf@process{#3}% + \advance\pgf@x by-\pgf@xb\relax% + \advance\pgf@y by-\pgf@yb\relax% + \pgf@process{\pgfpointnormalised{}}% x/y = normalised vector + \pgfmathsetlength\pgf@xa{#1}% + \pgf@ya=\pgf@xa\relax% + \pgf@xa=\pgf@sys@tonumber{\pgf@x}\pgf@xa% + \pgf@ya=\pgf@sys@tonumber{\pgf@y}\pgf@ya% + \pgf@x=\pgf@xb\relax% + \pgf@y=\pgf@yb\relax% + \advance\pgf@x by\pgf@xa\relax% + \advance\pgf@y by\pgf@ya\relax% + \ignorespaces} + + +% Returns point on a curve from #2 to #5 with controls #3 and #4 at time #1. +% +% #1 = a time +% #2 = start point +% #3 = first control point +% #4 = second control point +% #5 = end point +% +% x = x-component of place on the curve at time t +% y = y-component of place on the curve at time t +% +% Additionally, (\pgf@xa,\pgf@ya) and (\pgf@xb,\pgf@yb) will be on a +% tangent to the point on the curve (this can be useful for computing +% a label rotation). +% +% Example: +% +% % Middle of (1,1) and (2,3) +% \pgfpathmoveto{\pgfpointcurveattime{0.5}{\pgfpointxy{0}{1}}{\pgfpointxy{1}{1}}{\pgfpointxy{1}{1}}{\pgfpointxy{2}{3}}} + +\def\pgfpointcurveattime#1#2#3#4#5{% + \pgfmathparse{#1}% + \let\pgf@time@s=\pgfmathresult% + \pgf@x=\pgfmathresult pt% + \pgf@x=-\pgf@x% + \advance\pgf@x by 1pt% + \edef\pgf@time@t{\pgf@sys@tonumber{\pgf@x}}% + \pgf@process{#5}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{#4}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@process{#3}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#2}% + % First iteration: + \pgf@x=\pgf@time@t\pgf@x\advance\pgf@x by\pgf@time@s\pgf@xa% + \pgf@y=\pgf@time@t\pgf@y\advance\pgf@y by\pgf@time@s\pgf@ya% + \pgf@xa=\pgf@time@t\pgf@xa\advance\pgf@xa by\pgf@time@s\pgf@xb% + \pgf@ya=\pgf@time@t\pgf@ya\advance\pgf@ya by\pgf@time@s\pgf@yb% + \pgf@xb=\pgf@time@t\pgf@xb\advance\pgf@xb by\pgf@time@s\pgf@xc% + \pgf@yb=\pgf@time@t\pgf@yb\advance\pgf@yb by\pgf@time@s\pgf@yc% + % Second iteration: + \pgf@x=\pgf@time@t\pgf@x\advance\pgf@x by\pgf@time@s\pgf@xa% + \pgf@y=\pgf@time@t\pgf@y\advance\pgf@y by\pgf@time@s\pgf@ya% + \pgf@xa=\pgf@time@t\pgf@xa\advance\pgf@xa by\pgf@time@s\pgf@xb% + \pgf@ya=\pgf@time@t\pgf@ya\advance\pgf@ya by\pgf@time@s\pgf@yb% + % Save x/y + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + % Third iteration: + \pgf@x=\pgf@time@t\pgf@x\advance\pgf@x by\pgf@time@s\pgf@xa% + \pgf@y=\pgf@time@t\pgf@y\advance\pgf@y by\pgf@time@s\pgf@ya% +} + + + + + + +% Internal registers +\newdimen\pgf@xx +\newdimen\pgf@xy +\newdimen\pgf@yx +\newdimen\pgf@yy +\newdimen\pgf@zx +\newdimen\pgf@zy + + + +% A polar coordinate +% +% #1 = a degree +% #2 = a radius -- either a dimension or two dimensions separated by +% " and ". +% +% x = (first dimension in #2) * cos(#1) +% y = (second dimension in #2) * sin(#2) +% +% Example: +% +% \pgfpathmoveto{\pgfpointpolar{30}{1cm}} +% \pgfpathlineto{\pgfpointpolar{30}{1cm and 2cm}} + +\def\pgfpointpolar#1#2{% + \pgfutil@in@{and }{#2}% + \ifpgfutil@in@% + \pgf@polar@#2\@@% + \else% + \pgf@polar@#2 and #2\@@% + \fi% + \pgfmathparse{#1}% + \let\pgfpoint@angle=\pgfmathresult% + \pgfmathcos@{\pgfpoint@angle}% + \pgf@x=\pgfmathresult\pgf@x% + \pgfmathsin@{\pgfpoint@angle}% + \pgf@y=\pgfmathresult\pgf@y% +} + +\def\pgf@polar@#1and #2\@@{% + \pgfmathsetlength{\pgf@y}{#2}% + \pgfmathsetlength{\pgf@x}{#1}% +} + +% Quick version of the polar coordinate method + +\def\pgfqpointpolar#1#2{% + \pgf@x=#2% + \pgf@y=\pgf@x% + \pgfmathcos@{#1}% + \pgf@x=\pgfmathresult\pgf@x% + \pgfmathsin@{#1}% + \pgf@y=\pgfmathresult\pgf@y\relax% +} + + + + +% A polar coordinate in the xy plane. +% +% #1 = a degree +% #2 = a radius given as a number or two radi +% +% result = (first dim in #2) * x-vector * cos(#1) + +% (second dim in #2) * y-vector * sin(#1) +% +% Example: +% +% \pgfpathmoveto{\pgfpointpolarxy{30}{2}} + +\def\pgfpointpolarxy#1#2{% + \pgfutil@in@{and }{#2}% + \ifpgfutil@in@% + \pgf@polarxy@#2\@@% + \else% + \pgf@polarxy@#2and #2\@@% + \fi% + \pgfmathparse{#1}% + \let\pgfpoint@angle=\pgfmathresult% + \pgfmathcos@{\pgfpoint@angle}% + \pgf@xa=\pgfmathresult\pgf@xa% + \pgfmathsin@{\pgfpoint@angle}% + \pgf@ya=\pgfmathresult\pgf@ya% + \pgf@x=\pgf@sys@tonumber{\pgf@xa}\pgf@xx% + \advance\pgf@x by \pgf@sys@tonumber{\pgf@ya}\pgf@yx% + \pgf@y=\pgf@sys@tonumber{\pgf@xa}\pgf@xy% + \advance\pgf@y by \pgf@sys@tonumber{\pgf@ya}\pgf@yy} + +\def\pgf@polarxy@#1and #2\@@{% + \pgfmathsetlength{\pgf@xa}{#1}% + \pgfmathsetlength{\pgf@ya}{#2}% +} + + + +% A cylindrical coordinate. +% +% #1 = a degree +% #2 = a radius given as a number +% #3 = a height given as a number +% +% result = #2*(x-vector * cos(#1) + y-vector * sin(#1)) + #3*z-vector +% +% Example: +% +% \pgfpathmoveto{\pgfpointcylindrical{30}{2}{1}} + +\def\pgfpointcylindrical#1#2#3{% + \pgfpointpolarxy{#1}{#2}% + \pgfmathparse{#3}% + \advance\pgf@x by \pgfmathresult\pgf@zx% + \advance\pgf@y by \pgfmathresult\pgf@zy} + + +% A spherical coordinate. +% +% #1 = a longitude +% #2 = a latitude +% #3 = a radius +% +% result = #3*(cos(#2)*(x-vector * cos(#1) + y-vector * sin(#1)) + sin(#2)*z-vector) +% +% Example: +% +% \pgfpathmoveto{\pgfpointspherical{30}{30}{2}} + +\def\pgfpointspherical#1#2#3{% + \pgfmathparse{#1}% + \let\pgfpoint@angle=\pgfmathresult% + \pgfmathsin@{\pgfpoint@angle}% + \pgf@xb=\pgfmathresult\pgf@xx% + \pgf@yb=\pgfmathresult\pgf@xy% + \pgfmathcos@{\pgfpoint@angle}% + \advance\pgf@xb by \pgfmathresult\pgf@yx% + \advance\pgf@yb by \pgfmathresult\pgf@yy% + % + \pgfmathparse{#2}% + \let\pgfpoint@angle=\pgfmathresult% + \pgfmathcos@{\pgfpoint@angle}% + \pgf@xc=\pgfmathresult\pgf@xb% + \pgf@yc=\pgfmathresult\pgf@yb% + \pgfmathsin@{\pgfpoint@angle}% + \advance\pgf@xc by \pgfmathresult\pgf@zx% + \advance\pgf@yc by \pgfmathresult\pgf@zy% + \pgfmathparse{#3}% + \pgf@x=\pgfmathresult\pgf@xc% + \pgf@y=\pgfmathresult\pgf@yc\relax% +} + + +% Store the vector #1 * x-vec + #2 * y-vec +% +% #1 = a factor for the x-vector +% #2 = a factor fot the y-vector +% +% x = x-component of result vector +% y = y-component of result vector +% +% Description: +% +% This command can be used to create a new coordinate system +% without using the rotate/translate/scale commands. This +% may be useful, if you do not want arrows and line width to +% be scaled/transformed together with the coordinate system. +% +% Example: +% +% % Create a slanted rectangle +% +% \pgfsetxvec{\pgfpoint{1cm}{1cm}} +% \pgfsetyvec{\pgfpoint{0cm}{1cm}} +% +% \pgfpathmoveto{\pgfpointxy{0}{0}} +% \pgfpathlineto{\pgfpointxy{1}{0}} +% \pgfpathlineto{\pgfpointxy{1}{1}} +% \pgfpathlineto{\pgfpointxy{0}{1}} +% \pgfclosestroke + +\def\pgfpointxy#1#2{% + \pgfmathparse{#1}% + \let\pgftemp@x=\pgfmathresult% + \pgfmathparse{#2}% + \let\pgftemp@y=\pgfmathresult% + \pgf@x=\pgftemp@x\pgf@xx% + \advance\pgf@x by \pgftemp@y\pgf@yx% + \pgf@y=\pgftemp@x\pgf@xy% + \advance\pgf@y by \pgftemp@y\pgf@yy} + + +% Store the vector #1 * x-vec + #2 * y-vec + #3 * z-vec +% +% #1 = a factor for the x-vector +% #2 = a factor fot the y-vector +% #3 = a factor fot the z-vector +% +% x = x-component of result vector +% y = y-component of result vector +% +% +% Description: +% +% This command allows you to use a 3d coordinate system. +% +% +% Example: +% +% % Draw a cubus +% +% \pgfline{\pgfpointxyz{0}{0}{0}}{\pgfpointxyz{0}{0}{1}} +% \pgfline{\pgfpointxyz{0}{1}{0}}{\pgfpointxyz{0}{1}{1}} +% \pgfline{\pgfpointxyz{1}{0}{0}}{\pgfpointxyz{1}{0}{1}} +% \pgfline{\pgfpointxyz{1}{1}{0}}{\pgfpointxyz{1}{1}{1}} +% \pgfline{\pgfpointxyz{0}{0}{0}}{\pgfpointxyz{0}{1}{0}} +% \pgfline{\pgfpointxyz{0}{0}{1}}{\pgfpointxyz{0}{1}{1}} +% \pgfline{\pgfpointxyz{1}{0}{0}}{\pgfpointxyz{1}{1}{0}} +% \pgfline{\pgfpointxyz{1}{0}{1}}{\pgfpointxyz{1}{1}{1}} +% \pgfline{\pgfpointxyz{0}{0}{0}}{\pgfpointxyz{1}{0}{0}} +% \pgfline{\pgfpointxyz{0}{0}{1}}{\pgfpointxyz{1}{0}{1}} +% \pgfline{\pgfpointxyz{0}{1}{0}}{\pgfpointxyz{1}{1}{0}} +% \pgfline{\pgfpointxyz{0}{1}{1}}{\pgfpointxyz{1}{1}{1}} + +\def\pgfpointxyz#1#2#3{% + \pgfmathparse{#1}% + \let\pgftemp@x=\pgfmathresult% + \pgfmathparse{#2}% + \let\pgftemp@y=\pgfmathresult% + \pgfmathparse{#3}% + \let\pgftemp@z=\pgfmathresult% + \pgf@x=\pgftemp@x\pgf@xx% + \advance\pgf@x by \pgftemp@y\pgf@yx% + \advance\pgf@x by \pgftemp@z\pgf@zx% + \pgf@y=\pgftemp@x\pgf@xy% + \advance\pgf@y by \pgftemp@y\pgf@yy% + \advance\pgf@y by \pgftemp@z\pgf@zy} + + + + +% Set the x-vector +% +% #1 = a point the is the new x-vector +% +% Example: +% +% \pgfsetxvec{\pgfpoint{1cm}{0cm}} + +\def\pgfsetxvec#1{% + \pgf@process{#1}% + \pgf@xx=\pgf@x% + \pgf@xy=\pgf@y% + \ignorespaces} + + +% Set the y-vector +% +% #1 = a point the is the new y-vector +% +% Example: +% +% \pgfsetyvec{\pgfpoint{0cm}{1cm}} + +\def\pgfsetyvec#1{% + \pgf@process{#1}% + \pgf@yx=\pgf@x% + \pgf@yy=\pgf@y% + \ignorespaces} + + +% Set the z-vector +% +% #1 = a point the is the new z-vector +% +% Example: +% +% \pgfsetzvec{\pgfpoint{-0.385cm}{-0.385cm}} + +\def\pgfsetzvec#1{% + \pgf@process{#1}% + \pgf@zx=\pgf@x% + \pgf@zy=\pgf@y% + \ignorespaces} + + + +% Default values +\pgfsetxvec{\pgfpoint{1cm}{0cm}} +\pgfsetyvec{\pgfpoint{0cm}{1cm}} +\pgfsetzvec{\pgfpoint{-0.385cm}{-0.385cm}} + + + + +% Normalise a point. +% +% #1 = point with coordinates (a,b) +% +% x = a/\sqrt(a*a+b*b) +% y = b/\sqrt(a*a+b*b) +% +% Example: +% +% \pgfpointnormalised{\pgfpointxy{2}{1}} + +\def\pgfpointnormalised#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \ifdim\pgf@x<0pt\relax% move into first quadrant + \pgf@x=-\pgf@x% + \fi% + \ifdim\pgf@y<0pt\relax% + \pgf@y=-\pgf@y% + \fi% + \ifdim\pgf@x>\pgf@y% x > y + % make point small + \c@pgf@counta=\pgf@x% + \divide\c@pgf@counta by 65536\relax% + \ifnum\c@pgf@counta=0\relax% + \c@pgf@counta=1\relax% + \fi% + \divide\pgf@x by\c@pgf@counta% + \divide\pgf@y by\c@pgf@counta% + \divide\pgf@xa by\c@pgf@counta% + \divide\pgf@ya by\c@pgf@counta% + % ok. + \pgf@x=.125\pgf@x% + \pgf@y=.125\pgf@y% + \c@pgf@counta=\pgf@x% + \c@pgf@countb=\pgf@y% + \multiply\c@pgf@countb by 100% + \ifnum\c@pgf@counta<64\relax% + \pgf@x=1pt\relax% + \pgf@y=0pt\relax% + \else% + \divide\c@pgf@countb by \c@pgf@counta% + \pgf@x=\csname pgf@cosfrac\the\c@pgf@countb\endcsname pt% + \pgf@xc=8192pt% + \divide\pgf@xc by\c@pgf@counta% + \pgf@y=\pgf@sys@tonumber{\pgf@xc}\pgf@ya% + \pgf@y=\pgf@sys@tonumber{\pgf@x}\pgf@y% + \fi% + \ifdim\pgf@xa<0pt% + \pgf@x=-\pgf@x% + \fi% + \else% x <= y + % make point small + \c@pgf@counta=\pgf@y% + \divide\c@pgf@counta by 65536\relax% + \ifnum\c@pgf@counta=0\relax% + \c@pgf@counta=1\relax% + \fi% + \divide\pgf@x by\c@pgf@counta% + \divide\pgf@y by\c@pgf@counta% + \divide\pgf@xa by\c@pgf@counta% + \divide\pgf@ya by\c@pgf@counta% + % ok. + \pgf@x=.125\pgf@x% + \pgf@y=.125\pgf@y% + \c@pgf@counta=\pgf@y% + \c@pgf@countb=\pgf@x% + \multiply\c@pgf@countb by 100% + \ifnum\c@pgf@counta<64\relax% + \pgf@y=1pt\relax% + \pgf@x=0pt\relax% + \else% + \divide\c@pgf@countb by \c@pgf@counta% + \pgf@y=\csname pgf@cosfrac\the\c@pgf@countb\endcsname pt% + \pgf@xc=8192pt% + \divide\pgf@xc by\c@pgf@counta% + \pgf@x=\pgf@sys@tonumber{\pgf@xc}\pgf@xa% + \pgf@x=\pgf@sys@tonumber{\pgf@y}\pgf@x% + \fi% + \ifdim\pgf@ya<0pt% + \pgf@y=-\pgf@y% + \fi% + \fi\ignorespaces% +} + + + + + +% A point on a rectangle in a certain direction. +% +% #1 = a point pointing in some direction (length should be about 1pt, +% but need not be exact) +% #2 = upper right corner of a rectangle centered at the origin +% +% Returns the intersection of a line starting at the origin going in +% the given direction and the rectangle's border. +% +% Example: +% +% \pgfpointborderrectangle{\pgfpointnormalised{\pgfpointxy{2}{1}} +% {\pgfpoint{1cm}{2cm}} + +\def\pgfpointborderrectangle#1#2{% + \pgf@process{#2}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@process{#1}% + % Ok, let's find out about the direction: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \ifnum\pgf@xa<0\relax% move into first quadrant + \pgf@x=-\pgf@x% + \fi% + \ifnum\pgf@ya<0\relax% + \pgf@y=-\pgf@y% + \fi% + \pgf@xc=.125\pgf@x% + \pgf@yc=.125\pgf@y% + \c@pgf@counta=\pgf@xc% + \c@pgf@countb=\pgf@yc% + \ifnum\c@pgf@countb<\c@pgf@counta% + \ifnum\c@pgf@counta<255\relax% + \pgf@y=\pgf@yb\relax% + \pgf@x=0pt\relax% + \else% + \pgf@xc=8192pt% + \divide\pgf@xc by\c@pgf@counta% \pgf@xc = 1/\pgf@x + \pgf@y=\pgf@sys@tonumber{\pgf@xc}\pgf@y% + \pgf@y=\pgf@sys@tonumber{\pgf@xb}\pgf@y% + \ifnum\pgf@y<\pgf@yb% + \pgf@x=\pgf@xb% + \else% rats, calculate intersection on upper side + \ifnum\c@pgf@countb<255\relax% + \pgf@x=\pgf@xb\relax% + \pgf@y=0pt\relax% + \else% + \pgf@yc=8192pt% + \divide\pgf@yc by\c@pgf@countb% \pgf@xc = 1/\pgf@x + \pgf@x=\pgf@sys@tonumber{\pgf@yc}\pgf@x% + \pgf@x=\pgf@sys@tonumber{\pgf@yb}\pgf@x% + \pgf@y=\pgf@yb% + \fi% + \fi% + \fi% + \else% + \ifnum\c@pgf@countb<255\relax% + \pgf@x=\pgf@xb\relax% + \pgf@y=0pt\relax% + \else% + \pgf@yc=8192pt% + \divide\pgf@yc by\c@pgf@countb% \pgf@xc = 1/\pgf@x + \pgf@x=\pgf@sys@tonumber{\pgf@yc}\pgf@x% + \pgf@x=\pgf@sys@tonumber{\pgf@yb}\pgf@x% + \ifnum\pgf@x<\pgf@xb% + \pgf@y=\pgf@yb% + \else% + \ifnum\c@pgf@counta<255\relax% + \pgf@y=\pgf@yb\relax% + \pgf@x=0pt\relax% + \else% + \pgf@xc=8192pt% + \divide\pgf@xc by\c@pgf@counta% \pgf@xc = 1/\pgf@x + \pgf@y=\pgf@sys@tonumber{\pgf@xc}\pgf@y% + \pgf@y=\pgf@sys@tonumber{\pgf@xb}\pgf@y% + \pgf@x=\pgf@xb% + \fi% + \fi% + \fi% + \fi% + \ifnum\pgf@xa<0\relax\pgf@x=-\pgf@x\fi% + \ifnum\pgf@ya<0\relax\pgf@y=-\pgf@y\fi% +} + + + + +% An approximation to a point on an ellipse in a certain +% direction. Will be exact only if the ellipse is a circle. +% +% #1 = a point pointing in some direction +% #2 = upper right corner of a bounding box for the ellipse +% +% Returns the intersection of a line starting at the origin going in +% the given direction and the ellipses border. +% +% Example: +% +% \pgfpointborderellipse{\pgfpointnormalised{\pgfpointxy{2}{1}} +% {\pgfpoint{1cm}{2cm}} + +\def\pgfpointborderellipse#1#2{% + \pgf@process{#2}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \ifdim\pgf@xa=\pgf@ya% circle. that's easy! + \pgf@process{\pgfpointnormalised{#1}}% + \pgf@x=\pgf@sys@tonumber{\pgf@xa}\pgf@x% + \pgf@y=\pgf@sys@tonumber{\pgf@xa}\pgf@y% + \else% + \ifdim\pgf@xa<\pgf@ya% + % Ok, first, let's compute x/y: + \c@pgf@countb=\pgf@ya% + \divide\c@pgf@countb by65536\relax% + \divide\pgf@x by\c@pgf@countb% + \divide\pgf@y by\c@pgf@countb% + \pgf@xc=\pgf@x% + \pgf@yc=8192pt% + \pgf@y=.125\pgf@y% + \c@pgf@countb=\pgf@y% + \divide\pgf@yc by\c@pgf@countb% + \pgf@process{#1}% + \pgf@y=\pgf@sys@tonumber{\pgf@yc}\pgf@y% + \pgf@y=\pgf@sys@tonumber{\pgf@xc}\pgf@y% + \pgf@process{\pgfpointnormalised{}}% + \pgf@x=\pgf@sys@tonumber{\pgf@xa}\pgf@x% + \pgf@y=\pgf@sys@tonumber{\pgf@ya}\pgf@y% + \else% + % Ok, now let's compute y/x: + \c@pgf@countb=\pgf@xa% + \divide\c@pgf@countb by65536\relax% + \divide\pgf@x by\c@pgf@countb% + \divide\pgf@y by\c@pgf@countb% + \pgf@yc=\pgf@y% + \pgf@xc=8192pt% + \pgf@x=.125\pgf@x% + \c@pgf@countb=\pgf@x% + \divide\pgf@xc by\c@pgf@countb% + \pgf@process{#1}% + \pgf@x=\pgf@sys@tonumber{\pgf@yc}\pgf@x% + \pgf@x=\pgf@sys@tonumber{\pgf@xc}\pgf@x% + \pgf@process{\pgfpointnormalised{}}% + \pgf@x=\pgf@sys@tonumber{\pgf@xa}\pgf@x% + \pgf@y=\pgf@sys@tonumber{\pgf@ya}\pgf@y% + \fi% + \fi% +} + + + + + +% Extract the x-coordinate of a point to a dimensions +% +% #1 = a TeX dimension +% #2 = a point +% +% Example: +% +% \newdimen\mydim +% \pgfextractx{\mydim}{\pgfpoint{2cm}{4pt}} +% % \mydim is now 2cm + +\def\pgfextractx#1#2{% + \pgf@process{#2}% + #1=\pgf@x\relax} + + +% Extract the y-coordinate of a point to a dimensions +% +% #1 = a TeX dimension +% #2 = a point +% +% Example: +% +% \newdimen\mydim +% \pgfextracty{\mydim}{\pgfpoint{2cm}{4pt}} +% % \mydim is now 4pt + +\def\pgfextracty#1#2{% + \pgf@process{#2}% + #1=\pgf@y\relax} + + + +\def\pgf@def#1#2#3{\expandafter\def\csname pgf@#1#2\endcsname{#3}} +\pgf@def{cosfrac}{0}{1} +\pgf@def{cosfrac}{1}{0.99995} \pgf@def{cosfrac}{2}{0.9998} +\pgf@def{cosfrac}{3}{0.99955} \pgf@def{cosfrac}{4}{0.999201} +\pgf@def{cosfrac}{5}{0.998752} \pgf@def{cosfrac}{6}{0.998205} +\pgf@def{cosfrac}{7}{0.997559} \pgf@def{cosfrac}{8}{0.996815} +\pgf@def{cosfrac}{9}{0.995974} \pgf@def{cosfrac}{10}{0.995037} +\pgf@def{cosfrac}{11}{0.994004} \pgf@def{cosfrac}{12}{0.992877} +\pgf@def{cosfrac}{13}{0.991656} \pgf@def{cosfrac}{14}{0.990342} +\pgf@def{cosfrac}{15}{0.988936} \pgf@def{cosfrac}{16}{0.987441} +\pgf@def{cosfrac}{17}{0.985856} \pgf@def{cosfrac}{18}{0.984183} +\pgf@def{cosfrac}{19}{0.982424} \pgf@def{cosfrac}{20}{0.980581} +\pgf@def{cosfrac}{21}{0.978653} \pgf@def{cosfrac}{22}{0.976644} +\pgf@def{cosfrac}{23}{0.974555} \pgf@def{cosfrac}{24}{0.972387} +\pgf@def{cosfrac}{25}{0.970143} \pgf@def{cosfrac}{26}{0.967823} +\pgf@def{cosfrac}{27}{0.965429} \pgf@def{cosfrac}{28}{0.962964} +\pgf@def{cosfrac}{29}{0.960429} \pgf@def{cosfrac}{30}{0.957826} +\pgf@def{cosfrac}{31}{0.955157} \pgf@def{cosfrac}{32}{0.952424} +\pgf@def{cosfrac}{33}{0.949629} \pgf@def{cosfrac}{34}{0.946773} +\pgf@def{cosfrac}{35}{0.943858} \pgf@def{cosfrac}{36}{0.940887} +\pgf@def{cosfrac}{37}{0.937862} \pgf@def{cosfrac}{38}{0.934784} +\pgf@def{cosfrac}{39}{0.931655} \pgf@def{cosfrac}{40}{0.928477} +\pgf@def{cosfrac}{41}{0.925252} \pgf@def{cosfrac}{42}{0.921982} +\pgf@def{cosfrac}{43}{0.918669} \pgf@def{cosfrac}{44}{0.915315} +\pgf@def{cosfrac}{45}{0.911922} \pgf@def{cosfrac}{46}{0.90849} +\pgf@def{cosfrac}{47}{0.905024} \pgf@def{cosfrac}{48}{0.901523} +\pgf@def{cosfrac}{49}{0.89799} \pgf@def{cosfrac}{50}{0.894427} +\pgf@def{cosfrac}{51}{0.890835} \pgf@def{cosfrac}{52}{0.887217} +\pgf@def{cosfrac}{53}{0.883573} \pgf@def{cosfrac}{54}{0.879905} +\pgf@def{cosfrac}{55}{0.876216} \pgf@def{cosfrac}{56}{0.872506} +\pgf@def{cosfrac}{57}{0.868777} \pgf@def{cosfrac}{58}{0.865031} +\pgf@def{cosfrac}{59}{0.861269} \pgf@def{cosfrac}{60}{0.857493} +\pgf@def{cosfrac}{61}{0.853704} \pgf@def{cosfrac}{62}{0.849903} +\pgf@def{cosfrac}{63}{0.846092} \pgf@def{cosfrac}{64}{0.842271} +\pgf@def{cosfrac}{65}{0.838444} \pgf@def{cosfrac}{66}{0.834609} +\pgf@def{cosfrac}{67}{0.83077} \pgf@def{cosfrac}{68}{0.826927} +\pgf@def{cosfrac}{69}{0.82308} \pgf@def{cosfrac}{70}{0.819232} +\pgf@def{cosfrac}{71}{0.815383} \pgf@def{cosfrac}{72}{0.811534} +\pgf@def{cosfrac}{73}{0.807687} \pgf@def{cosfrac}{74}{0.803842} +\pgf@def{cosfrac}{75}{0.8} \pgf@def{cosfrac}{76}{0.796162} +\pgf@def{cosfrac}{77}{0.792329} \pgf@def{cosfrac}{78}{0.788502} +\pgf@def{cosfrac}{79}{0.784682} \pgf@def{cosfrac}{80}{0.780869} +\pgf@def{cosfrac}{81}{0.777064} \pgf@def{cosfrac}{82}{0.773268} +\pgf@def{cosfrac}{83}{0.769481} \pgf@def{cosfrac}{84}{0.765705} +\pgf@def{cosfrac}{85}{0.761939} \pgf@def{cosfrac}{86}{0.758185} +\pgf@def{cosfrac}{87}{0.754443} \pgf@def{cosfrac}{88}{0.750714} +\pgf@def{cosfrac}{89}{0.746997} \pgf@def{cosfrac}{90}{0.743294} +\pgf@def{cosfrac}{91}{0.739605} \pgf@def{cosfrac}{92}{0.735931} +\pgf@def{cosfrac}{93}{0.732272} \pgf@def{cosfrac}{94}{0.728628} +\pgf@def{cosfrac}{95}{0.724999} \pgf@def{cosfrac}{96}{0.721387} +\pgf@def{cosfrac}{97}{0.717792} \pgf@def{cosfrac}{98}{0.714213} +\pgf@def{cosfrac}{99}{0.710651} \pgf@def{cosfrac}{100}{0.707107} + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.code.tex new file mode 100644 index 00000000000..84a432ceadb --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.code.tex @@ -0,0 +1,134 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorequick.code.tex,v 1.2 2006/10/11 15:22:25 tantau Exp $ + +% Quick version of basic drawing commands. Most high-level commands +% are not available if these commands are used. + +% Move current point to (#1,#2). +% +% #1 = x dimension of new current point +% #2 = y dimension of new current point +% +% Example: +% +% \pgfpathqmoveto{0pt}{0pt} +% \pgfpathqlineto{1pt}{1pt} +% \pgfpathqcurveto{2pt}{1pt}{2pt}{2pt}{3pt}{2pt} +% \pgfqstroke + +\def\pgfpathqmoveto#1#2{\pgfsyssoftpath@moveto{#1}{#2}} + + +% Append a line to (#1,#2) to the current path. +% +% #1 = x dimension of target +% #2 = y dimension of target +% +% Example: +% +% \pgfpathqmoveto{0pt}{0pt} +% \pgfpathqlineto{1pt}{1pt} +% \pgfpathqcurveto{2pt}{1pt}{2pt}{2pt}{3pt}{2pt} +% \pgfqstroke + +\def\pgfpathqlineto#1#2{\pgfsyssoftpath@lineto{#1}{#2}} + + +% Append a bezier spline to the current path. +% +% #1 = x dimension of first support point +% #2 = y dimension of first support point +% #3 = x dimension of second support point +% #4 = y dimension of second support point +% #5 = x dimension of target point +% #6 = y dimension of target point +% +% Example: +% +% \pgfpathqmoveto{0pt}{0pt} +% \pgfpathqlineto{1pt}{1pt} +% \pgfpathqcurveto{2pt}{1pt}{2pt}{2pt}{3pt}{2pt} +% \pgfqstroke + +\def\pgfpathqcurveto#1#2#3#4#5#6{\pgfsyssoftpath@curveto{#1}{#2}{#3}{#4}{#5}{#6}} + + + + +% Append a circle of the given radius around the origin. +% +% #1 = radius +% +% Example: +% +% \pgfpathqcircle{10pt} +% is quicker than +% \pgfpathcircle{\pgforigin}{10pt} + +\def\pgfpathqcircle#1{% + {% + \pgf@x=#1% + \pgf@y=0.555\pgf@x% + \pgfsyssoftpath@moveto{\the\pgf@x}{0pt}% + \pgfsyssoftpath@curveto{\the\pgf@x}{\the\pgf@y}{\the\pgf@y}{\the\pgf@x}{0pt}{\the\pgf@x}% + \pgfsyssoftpath@curveto{-\the\pgf@y}{\the\pgf@x}{-\the\pgf@x}{\the\pgf@y}{-\the\pgf@x}{0pt}% + \pgfsyssoftpath@curveto{-\the\pgf@x}{-\the\pgf@y}{-\the\pgf@y}{-\the\pgf@x}{0pt}{-\the\pgf@x}% + \pgfsyssoftpath@curveto{\the\pgf@y}{-\the\pgf@x}{\the\pgf@x}{-\the\pgf@y}{\the\pgf@x}{0pt}% + \pgfsyssoftpath@closepath% + }% +} + + + +% Stroke current path. No hooks called. +% +% Example: +% +% \pgfpathqmoveto{0cm}{0cm} +% \pgfpathqlineto{1cm}{1cm} +% \pgfpathqcurveto{2cm}{1cm}{2cm}{2cm}{3cm}{2cm} +% \pgfqstroke + +\def\pgfusepathqstroke{% + \pgfsyssoftpath@flushcurrentpath% + \pgfsys@stroke% + \pgf@resetpathsizes% +} + + +% Quickly fill current path. + +\def\pgfusepathqfill{% + \pgfsyssoftpath@flushcurrentpath% + \pgfsys@fill% + \pgf@resetpathsizes% +} + + +% Quickly fill and stroke current path. + +\def\pgfusepathqfillstroke{% + \pgfsyssoftpath@flushcurrentpath% + \pgfsys@fillstroke% + \pgf@resetpathsizes% +} + +% Quickly clip current path. + +\def\pgfusepathqclip{% + \pgfsyssoftpath@flushcurrentpath% + \pgfsys@clipnext% + \pgfsys@discardpath% + \pgf@resetpathsizes% +} + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.tex new file mode 100644 index 00000000000..b637ff10ded --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.tex @@ -0,0 +1,571 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorescopes.code.tex,v 1.26 2008/01/15 10:27:34 tantau Exp $ + +% Globals + +\newbox\pgfpic +\newbox\pgf@hbox + +\newbox\pgf@layerbox@main + +\newcount\pgf@picture@serial@count + + + +% This if decides whether the position of pictures on the page is +% protocolled or not. Normally, +% this is switched off as it works only with certain drivers and it +% causes external files to be written. When switched on, the position +% of pgfpictures are protocolled and can be referenced using +% \pgfsys@getposition{XXX} where XXX is the value of \pgfpictureid +% inside the picture. +\newif\ifpgfrememberpicturepositiononpage + + + +% Library files inclusion + + +% Include a library file. +% +% #1 = List of names of library file. +% +% Description: +% +% This command includes a list of library files. For each file X in the +% list, the file pgflibraryX.code.tex is included, provided this has +% not been done earlier. +% +% For the convenience of Context users, both round and square brackets +% are possible for the argument. +% +% Example: +% +% \usepgflibrary{arrows} +% \usepgflibrary[patterns,snakes] + +\def\usepgflibrary{\pgfutil@ifnextchar[{\use@pgflibrary}{\use@@pgflibrary}}%} +\def\use@pgflibrary[#1]{\use@@pgflibrary{#1}} +\def\use@@pgflibrary#1{% + \edef\pgf@list{#1}% + \pgfutil@for\pgf@temp:=\pgf@list\do{% + \expandafter\ifx\csname pgf@library@\pgf@temp @loaded\endcsname\relax% + \expandafter\let\csname pgf@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname pgf@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname pgf@library@#1@barcode\endcsname{\the\catcode`\|} + \catcode`\@=11 + \catcode`\|=12 + \input pgflibrary\pgf@temp.code.tex + \catcode`\@=\csname pgf@library@#1@atcode\endcsname + \catcode`\|=\csname pgf@library@#1@barcode\endcsname + \fi% + }% +} + + +% Include a module file. +% +% #1 = List of names of module files. +% +% Description: +% +% This command includes a list of module files. For each file X in the +% list, the file pgfmoduleX.code.tex is included, provided this has +% not been done earlier. +% +% For the convenience of Context users, both round and square brackets +% are possible for the argument. +% +% Example: +% +% \usepgfmodule{matrix} + +\def\usepgfmodule{\pgfutil@ifnextchar[{\use@pgfmodule}{\use@@pgfmodule}}%} +\def\use@pgfmodule[#1]{\use@@pgfmodule{#1}} +\def\use@@pgfmodule#1{% + \edef\pgf@list{#1}% + \pgfutil@for\pgf@temp:=\pgf@list\do{% + \expandafter\ifx\csname pgf@module@\pgf@temp @loaded\endcsname\relax% + \expandafter\let\csname pgf@module@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname pgf@module@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname pgf@module@#1@barcode\endcsname{\the\catcode`\|} + \catcode`\@=11 + \catcode`\|=12 + \input pgfmodule\pgf@temp.code.tex + \catcode`\@=\csname pgf@module@#1@atcode\endcsname + \catcode`\|=\csname pgf@module@#1@barcode\endcsname + \fi% + }% +} + + + +% Scopes + + +% Pgf scope environment. All changes of the graphic state are local to +% the scope. +% +% Example: +% +% \begin{pgfscope} +% \pgfsetlinewidth{3pt} +% \pgfline{\pgfxy(0,0)}{\pgfxy(3,3)} +% \end{pgfscope} + +\def\pgfscope{% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \pgfsys@beginscope% + \pgf@resetpathsizes% + \edef\pgfscope@linewidth{\the\pgflinewidth}% + \begingroup} +\def\endpgfscope{% + \endgroup% + \global\pgflinewidth=\pgfscope@linewidth% + \pgfsys@endscope} + + + + +% Quickly insert a box can contain normal TeX text at the origin. +% +% #1 = box of width/height and depth 0pt +% +% Example: +% +% \pgfqbox{\mybox} + +\def\pgfqbox#1{% + \pgfsys@hbox#1% +} + + +% Insert a box that can contain normal TeX text at the origin, but +% with the current coordinate transformation matrix synced with the +% low-level transformation matrix. +% +% #1 = box of width/height and depth 0pt +% +% In essence, this command does the same as if you first said +% \pgflowlevelsynccm and then \pgfqbox. However, pgf will use a +% ``TeX-translation'' for the translation part of the transformation +% cm. This will ensure that hyperlinks ``survive'' at least +% translations. +% +% Example: +% +% \pgfqboxsynced{\mybox} + +\def\pgfqboxsynced#1{% + \pgfsys@hboxsynced#1% +} + + +% Puts some text in a box and inserts it with the current +% transformations applied. +% +% #1 = List of optional positioning. Possible values are ``left'', ``right'', +% ``top'', ``bottom'' and ``base''. +% #2 = TeX text. May contain verbatims. +% +% Example: +% +% \pgftransformshift{\pgfpoint{1cm}{0cm}} +% \pgftext{Hello World!} + +\def\pgftext{\pgfutil@ifnextchar[\pgf@text{\pgf@text[]}}% +\def\pgf@text[#1]{% + \def\pgf@text@options{#1}% + \pgf@maketext\pgf@after@text} +\def\pgf@after@text{% + {% + \def\pgf@text@hshift{center}% + \def\pgf@text@vshift{center}% + \expandafter\pgf@text@setkeys\expandafter{\pgf@text@options}% + \csname pgf@halign\pgf@text@hshift\endcsname% + \csname pgf@valign\pgf@text@vshift\endcsname% + % Protocol sizes: + \pgf@process{\pgfpointtransformed{\pgfqpoint{0pt}{\dp\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfqpoint{\wd\pgf@hbox}{\dp\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfqpoint{0pt}{\ht\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfqpoint{\wd\pgf@hbox}{\ht\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgfqboxsynced{\pgf@hbox}% + }% +} +\def\pgf@text@setkeys{\pgfqkeys{/pgf/text}}% + +\pgfkeys{/pgf/text/left/.code=\def\pgf@text@hshift{left}} +\pgfkeys{/pgf/text/center/.code=} +\pgfkeys{/pgf/text/right/.code=\def\pgf@text@hshift{right}} +\pgfkeys{/pgf/text/top/.code=\def\pgf@text@vshift{top}} +\pgfkeys{/pgf/text/bottom/.code=\def\pgf@text@vshift{bottom}} +\pgfkeys{/pgf/text/base/.code=\def\pgf@text@vshift{base}} +\pgfkeys{/pgf/text/at/.cd,.code=\pgftransformshift{#1},.value required} +\pgfkeys{/pgf/text/x/.cd,.code=\pgftransformxshift{#1},.value required} +\pgfkeys{/pgf/text/y/.cd,.code=\pgftransformyshift{#1},.value required} +\pgfkeys{/pgf/text/rotate/.cd,.code=\pgftransformrotate{#1},.value required} + +\def\pgf@halignleft{}% do nothing +\def\pgf@haligncenter{\pgftransformxshift{+-.5\wd\pgf@hbox}} +\def\pgf@halignright{\pgftransformxshift{+-\wd\pgf@hbox}}% +\def\pgf@valignbase{}% do nothing +\def\pgf@valignbottom{\pgftransformyshift{+\dp\pgf@hbox}}% +\def\pgf@valigncenter{\pgftransformyshift{+.5\dp\pgf@hbox}\pgftransformyshift{+-.5\ht\pgf@hbox}}% +\def\pgf@valigntop{\pgftransformyshift{+-\ht\pgf@hbox}}% + + +% Internal function for creating a hbox. +\def\pgf@maketext#1{% + \def\pgf@@maketextafter{#1}% + \setbox\pgf@hbox=\hbox\bgroup% + \pgfinterruptpicture% + \bgroup% + \aftergroup\pgf@collectresetcolor% + \let\next=% +} +\def\pgf@collectresetcolor{% + \pgfutil@ifnextchar\reset@color% + {\reset@color\afterassignment\pgf@collectresetcolor\let\pgf@temp=}% + {\pgf@textdone}% +} +\def\pgf@textdone{% + \endpgfinterruptpicture% + \egroup% + \pgf@@maketextafter% +} + +\long\def\pgf@makehbox#1{% + \setbox\pgf@hbox=\hbox{{% + \pgfinterruptpicture% + #1% + \endpgfinterruptpicture% + }}} + + + +% Picture environment +% +% Example: +% +% \begin{pgfpicture} +% \pgfsetendarrow{\pgfarrowto} +% \pgfpathmoveto{\pgfpointxy{-0.9}{0.2}} +% \pgfpathlineto{\pgfpointxy{0.9}{0.4}} +% \pgfusepath{stroke} +% \end{pgfpicture} + +\newif\ifpgfpicture + +\def\pgfpicture{% + \begingroup% + \pgfpicturetrue% + \global\advance\pgf@picture@serial@count by1\relax% + \edef\pgfpictureid{pgfid\the\pgf@picture@serial@count}% + \let\pgf@nodecallback=\pgfutil@gobble% + \pgf@picmaxx=-16000pt\relax% + \pgf@picminx=16000pt\relax% + \pgf@picmaxy=-16000pt\relax% + \pgf@picminy=16000pt\relax% + \pgf@relevantforpicturesizetrue% + \pgf@resetpathsizes% + \pgfutil@ifnextchar\bgroup\pgf@oldpicture\pgf@picture} +\def\pgf@oldpicture#1#2#3#4{% + \pgfmathsetlength\pgf@picminx{#1}% + \pgfmathsetlength\pgf@picminy{#2}% + \pgfmathsetlength\pgf@picmaxx{#3}% + \pgfmathsetlength\pgf@picmaxy{#4}% + \pgf@relevantforpicturesizefalse% + \pgf@picture} + +\def\pgf@picture{% + \setbox\pgfpic\hbox to0pt\bgroup% + \begingroup% + \pgfsys@beginpicture% + \pgfsys@beginscope% + \begingroup% + \pgfsetcolor{.}% + \pgfsetlinewidth{0.4pt}% + \pgftransformreset% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \begingroup% + \let\pgf@setlengthorig=\setlength% + \let\pgf@addtolengthorig=\addtolength% + \let\pgf@selectfontorig=\selectfont% + \let\setlength=\pgf@setlength% + \let\addtolength=\pgf@addtolength% + \let\selectfont=\pgf@selectfont% + \nullfont\spaceskip\z@\xspaceskip\z@% + \setbox\pgf@layerbox@main\hbox to0pt\bgroup% + \begingroup% + } +\def\endpgfpicture{% + \ifpgfrememberpicturepositiononpage% + \hbox to0pt{\pgfsys@markposition{\pgfpictureid}}% + \fi% + % ok, now let's position the box + \ifdim\pgf@picmaxx=-16000pt\relax% + % empty picture. make size 0. + \global\pgf@picmaxx=0pt\relax% + \global\pgf@picminx=0pt\relax% + \global\pgf@picmaxy=0pt\relax% + \global\pgf@picminy=0pt\relax% + \fi% + % Shift baseline outside: + \pgf@relevantforpicturesizefalse% + \pgf@process{\pgf@baseline}% + \gdef\pgf@shift@baseline{\the\pgf@y}% + \endgroup% + \hss% + \egroup% + \pgf@insertlayers% + \endgroup% + \pgfsys@discardpath% + \endgroup% + \pgfsys@endscope% + \pgfsys@endpicture% + \endgroup% + \hss + \egroup% + \pgfsys@typesetpicturebox\pgfpic% + \endgroup% +} + +\def\pgf@insertlayers{% + \box\pgf@layerbox@main% +} + +\def\pgf@selectfont{\pgf@selectfontorig\nullfont} + +\def\pgf@setlength#1#2{% these will be used only when \nullfont is active + \begingroup% keep font setting local + \pgfutil@selectfont% restore font + \pgf@setlengthorig#1{#2}% calculate dimension (possibly using calc) + \expandafter% + \endgroup% + \expandafter#1\expandafter=\the#1\relax} +\def\pgf@addtolength#1#2{% + \begingroup% keep font setting local + \pgfutil@selectfont% restore font + \pgf@addtolengthorig#1{#2}% calculate dimension (possibly using calc) + \expandafter% + \endgroup% + \expandafter#1\expandafter=\the#1\relax} + + +% Sets the baseline at the y-coordinate of a given point +% +% #1 = point +% +% Sets the baseline of the picture to the y-coordinate of a given +% point. However, the point will be evaluated *at the end of the +% picture*. +% +% Example: +% +% \pgfsetbaselinepointlater{\pgfpointanchor{mynode}{base}} + +\def\pgfsetbaselinepointlater#1{\def\pgf@baseline{#1}} + + +% Sets the baseline at the y-coordinate of a given point, now +% +% #1 = point +% +% Sets the baseline of the picture to the y-coordinate of a given +% point. +% +% Example: +% +% \pgfsetbaselinepointnow{\pgfpoint{1cm}{2pt}} + +\def\pgfsetbaselinepointnow#1{% + \pgf@process{#1}% + \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfsetbaselinepointlater{\pgf@setter@baseline}% +} + + +% Sets the baseline +% +% #1 = baseline +% +% Sets the baseline of the picture. Default is the lower border, which +% is the same as \pgf@picminy +% +% Example: +% +% \pgfsetbaseline{1cm+2pt} + +\def\pgfsetbaseline#1{\pgfsetbaselinepointlater{\pgfpoint{0pt}{#1}}} +\pgfsetbaseline{\pgf@picminy} + + + + +% Interrupt path +% +% Description: +% +% The environment can be used to insert some drawing commands while +% constructing a path. The drawing commands inside the environment +% will not interfere with the path being constructed ``outside.'' +% However, you must ward against graphic state changes using a scope. +% +% Example: Draw two parallel lines +% +% \pgfmoveto{\pgfpoint{0cm}{0cm}} +% \begin{pgfinterruptpath} +% \pgfmoveto{\pgfpoint{1cm}{0cm}} +% \pgfmoveto{\pgfpoint{1cm}{1cm}} +% \pgfusepath{stroke} +% \end{pgfinterruptpath} +% \pgflineto{\pgfpoint{0cm}{1cm}} +% \pgfusepath{stroke} + +\def\pgfinterruptpath +{% + \begingroup% + % save all sorts of things... + \edef\pgf@interrupt@savex{\the\pgf@path@lastx}% + \edef\pgf@interrupt@savey{\the\pgf@path@lasty}% + \pgf@getpathsizes\pgf@interrupt@pathsizes% + \pgfsyssoftpath@getcurrentpath\pgf@interrupt@path% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \edef\pgfscope@linewidth{\the\pgflinewidth}% + \let\pgf@interrupt@lastmoveto=\pgfsyssoftpath@lastmoveto% + \begingroup% +} +\def\endpgfinterruptpath +{% + \endgroup% + \global\pgflinewidth=\pgfscope@linewidth% + \pgfsyssoftpath@setcurrentpath\pgf@interrupt@path% + \pgf@setpathsizes\pgf@interrupt@pathsizes% + \global\pgf@path@lastx=\pgf@interrupt@savex% + \global\pgf@path@lasty=\pgf@interrupt@savey% + \global\let\pgfsyssoftpath@lastmoveto=\pgf@interrupt@lastmoveto% + \endgroup% +} + + + +% Interrupt bounding box +% +% Description: +% +% The environment can be used to temporarily setup a new bounding box +% computation. The bounding box will be made empty at the beginning of +% the environment and will be reset to its old value after the +% environment. +% +% Example: +% +% \begin{pgfinterruptboundinbox} +% \pgfmoveto{\pgfpoint{1cm}{0cm}} +% \pgfmoveto{\pgfpoint{1cm}{1cm}} +% \pgfusepath{stroke} +% \end{pgfinterruptboundinbox} + +\def\pgfinterruptboundingbox +{% + \begingroup% + \edef\pgf@interrupt@savemaxx{\the\pgf@picmaxx}% + \edef\pgf@interrupt@saveminx{\the\pgf@picminx}% + \edef\pgf@interrupt@savemaxy{\the\pgf@picmaxy}% + \edef\pgf@interrupt@saveminy{\the\pgf@picminy}% + \pgf@picmaxx=-16000pt\relax% + \pgf@picminx=16000pt\relax% + \pgf@picmaxy=-16000pt\relax% + \pgf@picminy=16000pt\relax% +} +\def\endpgfinterruptboundingbox +{% + \global\pgf@picmaxx=\pgf@interrupt@savemaxx% + \global\pgf@picmaxy=\pgf@interrupt@savemaxy% + \global\pgf@picminx=\pgf@interrupt@saveminx% + \global\pgf@picminy=\pgf@interrupt@saveminy% + \endgroup% +} + + + + + +% Interrupts a picture +% +% Description: +% +% This environment interrupts a picture and temporarily returns to +% normal TeX mode. All sorts of things are saved and restored by this +% environment. +% +% WARNING: Using this environment in conjuction with low level +% transformations can *strongly* upset the typesetting. Typically, the +% contents of this environment should have size/height/depth 0pt in +% the end. +% +% WARNING: This environment should only be used inside typesetting a +% box and this box must in turn be inserted using \pgfqbox. +% +% Example: Draw two parallel lines +% +% \pgfmoveto{\pgfpoint{0cm}{0cm}} +% \setbox\mybox=\hbox{ +% \begin{pgfinterruptpicture} +% This is normal text. +% \begin{pgfpicture} % a subpicture +% \pgfmoveto{\pgfpoint{1cm}{0cm}} +% \pgfmoveto{\pgfpoint{1cm}{1cm}} +% \pgfusepath{stroke} +% \end{pgfpicture} +% More text. +% \end{pgfinterruptpicture} +% } +% \ht\mybox=0pt +% \wd\mybox=0pt +% \dp\mybox=0pt +% \pgfqbox{\mybox}% +% \pgfpathlineto{\pgfpoint{0cm}{1cm}} +% \pgfusepath{stroke} + +\def\pgfinterruptpicture +{% + \begingroup% + \pgfinterruptboundingbox% + \pgftransformreset% + \pgfinterruptpath% + \ifx\pgf@selectfontorig\@undefined% + \else% + \let\setlength\pgf@setlengthorig% + \let\addtolength\pgf@addtolengthorig% + \let\selectfont\pgf@selectfontorig% + \fi% + \pgfutil@selectfont% + \pgfpicturefalse% + \pgf@savelayers% +} +\def\endpgfinterruptpicture +{% + \pgf@restorelayers% + \endpgfinterruptpath% + \endpgfinterruptboundingbox% + \endgroup% +} + +\let\pgf@savelayers=\relax +\let\pgf@restorelayers=\relax + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.code.tex new file mode 100644 index 00000000000..e8225bb0225 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.code.tex @@ -0,0 +1,580 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreshade.code.tex,v 1.9 2007/12/10 13:19:32 tantau Exp $ + +% +% Parsing functions +% +\newdimen\pgf@max +\newcount\pgf@sys@shading@range@num +\def\pgf@parsefunc#1{% + \edef\temp{{#1}}% + \expandafter\pgf@convertrgbstring\temp% + \edef\temp{{\pgf@rgbconv}}% + \expandafter\pgf@@parsefunc\temp} +\def\pgf@@parsefunc#1{% + \let\pgf@bounds=\pgfutil@empty% + \let\pgf@funcs=\pgfutil@empty% + \let\pgf@psfuncs=\pgfutil@empty% + \let\pgf@encode=\pgfutil@empty% + \let\pgf@sys@shading@ranges=\pgfutil@empty% + \pgf@sys@shading@range@num=0\relax% + \pgf@parsefirst[#1; ]% + \pgf@parselastdom[#1; ]% + \pgf@parsemid[#1; ]% + \ifx\pgf@bounds\pgfutil@empty% + \edef\pgf@pdfparseddomain{0 1}% + \edef\pgf@pdfparsedfunction{\pgf@singlefunc\space}% + \else% + \edef\pgf@pdfparseddomain{\pgf@doma\space\pgf@domb}% + \edef\pgf@pdfparsedfunction{% + << /FunctionType 3 /Domain [\pgf@doma\space\pgf@domb] /Functions + [\pgf@funcs\space] /Bounds [\pgf@bounds] /Encode [0 1 \pgf@encode] + >> }% << + \fi% + \xdef\pgf@psfuncs{\pgf@psfuncs}% + } +\def\pgf@parsefirst[rgb(#1)=(#2,#3,#4)#5]{% + \pgfmathsetlength\pgf@x{#1}% + \edef\pgf@sys@shading@start@pos{\the\pgf@x}% + \pgf@sys@bp@correct\pgf@x% + \edef\pgf@doma{\pgf@sys@tonumber{\pgf@x}}% + \edef\pgf@prevx{\pgf@sys@tonumber{\pgf@x}}% + \pgf@getrgbtuplewithmixin{#2}{#3}{#4}% + \edef\pgf@sys@shading@start@rgb{\pgf@sys@rgb}% + \let\pgf@sys@prevcolor=\pgf@sys@shading@start@rgb% + \let\pgf@sys@prevpos=\pgf@sys@shading@start@pos% + \edef\pgf@prevcolor{\pgf@rgb}% + \edef\pgf@firstcolor{\pgf@rgb}} +\def\pgf@parselastdom[rgb(#1)=(#2,#3,#4); {% + \pgfutil@ifnextchar]{% + \pgfmathsetlength\pgf@x{#1}% + \edef\pgf@sys@shading@end@pos{\the\pgf@x}% + \pgf@max=\pgf@x\relax% + \pgf@sys@bp@correct\pgf@x% + \edef\pgf@domb{\pgf@sys@tonumber{\pgf@x}}% + \pgf@getrgbtuplewithmixin{#2}{#3}{#4}% + \edef\pgf@sys@shading@end@rgb{\pgf@sys@rgb}% + \pgfutil@gobble}{\pgf@parselastdom[}} +\def\pgf@parsemid[rgb(#1)=(#2,#3,#4); {\pgf@parserest[} +\def\pgf@parserest[rgb(#1)=(#2,#3,#4); {% + \advance\pgf@sys@shading@range@num by1\relax% + \pgfutil@ifnextchar]{% + \pgf@getrgbtuplewithmixin{#2}{#3}{#4}% + \edef\pgf@singlefunc{\space% + << /FunctionType 2 /Domain [0 1] /C0 + [\pgf@prevcolor] /C1 [\pgf@rgb] /N 1 >> }% << + \edef\pgf@funcs{\pgf@funcs\space% + << /FunctionType 2 /Domain [\pgf@doma\space\pgf@domb] /C0 + [\pgf@prevcolor] /C1 [\pgf@rgb] /N 1 >> }% << + \edef\pgf@psfuncs{\pgf@prevx\space \pgf@rgb\space \pgf@prevcolor\space pgfshade \pgf@psfuncs}% + \pgfmathsetlength\pgf@x{#1}% + \edef\pgf@sys@shading@ranges{\pgf@sys@shading@ranges{{\pgf@sys@prevpos}{\the\pgf@x}{\pgf@sys@prevcolor}{\pgf@sys@rgb}}}% + \edef\pgf@sys@prevpos{\the\pgf@x}% + \let\pgf@sys@prevcolor=\pgf@sys@rgb% + \pgfutil@gobble}{% + \pgfmathsetlength\pgf@x{#1}% + \pgf@getrgbtuplewithmixin{#2}{#3}{#4}% + \edef\pgf@sys@shading@ranges{\pgf@sys@shading@ranges{{\pgf@sys@prevpos}{\the\pgf@x}{\pgf@sys@prevcolor}{\pgf@sys@rgb}}}% + \edef\pgf@sys@prevpos{\the\pgf@x}% + \let\pgf@sys@prevcolor=\pgf@sys@rgb% + \edef\pgf@psfuncs{\pgf@prevx\space \pgf@rgb\space \pgf@prevcolor\space pgfshade \pgf@psfuncs}% + \pgf@sys@bp@correct\pgf@x% + \edef\pgf@prevx{\pgf@sys@tonumber{\pgf@x}}% + \edef\pgf@bounds{\pgf@bounds\space\pgf@sys@tonumber{\pgf@x}}% + \edef\pgf@encode{\pgf@encode\space0 1}% + \edef\pgf@singlefunc{\space% + << /FunctionType 2 /Domain [0 1] /C0 + [\pgf@prevcolor] /C1 [\pgf@rgb] /N 1 >> }% << + \edef\pgf@funcs{\pgf@funcs\space% + << /FunctionType 2 /Domain [\pgf@doma\space\pgf@domb] /C0 + [\pgf@prevcolor] /C1 [\pgf@rgb] /N 1 >> }% << + \edef\pgf@prevcolor{\pgf@rgb}% + \pgf@parserest[}} + +\def\pgf@getrgbtuplewithmixin#1#2#3{% + \pgfutil@definecolor{pgfshadetemp}{rgb}{#1,#2,#3}% + \pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgfshadetemp}}% + \pgfutil@extractcolorspec{pgfshadetemp}{\pgf@tempcolor}% + \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}% + \expandafter\pgf@getrgb@@\pgf@rgbcolor!} +\def\pgf@getrgb@@#1,#2,#3!{% + \def\pgf@rgb{#1 #2 #3}% + \def\pgf@sys@rgb{{#1}{#2}{#3}}% +} + + +\def\pgf@convertrgbstring#1{% + \def\pgf@rgbconv{}% + \pgf@converttorgb#1]% + } +\def\pgf@converttorgb{% + \pgfutil@ifnextchar]{\pgfutil@gobble}%done! + {% + \pgfutil@ifnextchar;{\pgf@grabsemicolor}% + {% + \pgfutil@ifnextchar r{\pgf@grabrgb}% + {% + \pgfutil@ifnextchar g{\pgf@grabgray}% + {% + \pgfutil@ifnextchar c{\pgf@grabcolor}% + {\PackageError{pgfshade}{Illformed shading + specification}{}\pgf@converttorgb}% + }% + }% + }% + }% +} +\def\pgf@grabsemicolor;{% + \edef\pgf@rgbconv{\pgf@rgbconv; }\pgf@converttorgb} +\def\pgf@grabrgb rgb(#1)=(#2,#3,#4){% + \edef\pgf@rgbconv{\pgf@rgbconv rgb(#1)=(#2,#3,#4)}\pgf@converttorgb} +\def\pgf@grabgray gray(#1)=(#2){% + \edef\pgf@rgbconv{\pgf@rgbconv rgb(#1)=(#2,#2,#2)}\pgf@converttorgb} +\def\pgf@grabcolor color(#1)=(#2){% + \pgfutil@colorlet{pgf@tempcol}{#2}% + \pgfutil@extractcolorspec{pgf@tempcol}{\pgf@tempcolor}% + \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}% + \expandafter\pgf@convgetrgb@\expandafter{\pgf@rgbcolor}{#1}% +} +\def\pgf@convgetrgb@#1#2{% + \edef\pgf@rgbconv{\pgf@rgbconv rgb(#2)=(#1)}\pgf@converttorgb} + + + + +% Declares a horizontal shading for later use. The shading is a +% horizontal bar that changes its color. +% +% #1 = optional dependencies +% #2 = name of the shading for later use +% #3 = height of the shading +% #4 = color specification in the following format: A list of colors +% that the bar should have at certain points. If the bar should +% be red at 1cm, this is specified as +% "rgb(1cm)=(1,0,0)". Multiple specifications are separated by a +% semicolon and a space. At least two specifications must be +% given. The specified positions must be given in increasing +% order. +% +% Description: +% +% The optional dependecies have the following effect: If present, it +% should consist of a list of colors, separated by commas. Each time +% the shading is used, these colors will be reevaluated. It will be +% checked whether the colors still have their "original meaning". If +% the colors have changed, a new shading will be created internally to +% reflect the changed color's values. +% +% Example: +% +% \pgfdeclarehorizontalshading{redtogreentoblue}{1cm}{% +% rgb(0cm)=(1,0,0); % red +% rgb(1cm)=(0,1,0); % green +% rgb(2cm)=(0,0,1)} +% +% \begin{document} +% The following bar is 2cm long: \pgfuseshading{redtogreentoblue}. +% \end{document} + +\def\pgfdeclarehorizontalshading{\pgfutil@ifnextchar[\pgf@declarehorizontalshading{\pgf@declarehorizontalshading[]}}% +\def\pgf@declarehorizontalshading[#1]#2#3#4{% + \expandafter\def\csname pgf@deps@pgfshading#2!\endcsname{#1}% + \expandafter\ifx\csname pgf@deps@pgfshading#2!\endcsname\pgfutil@empty% + \pgfsys@horishading{#2}{#3}{#4}% + \else% + \expandafter\def\csname pgf@func@pgfshading#2!\endcsname{\pgfsys@horishading}% + \expandafter\def\csname pgf@args@pgfshading#2!\endcsname{{#3}{#4}}% + \expandafter\let\csname @pgfshading#2!\endcsname=\pgfutil@empty% + \fi} + + +% Declares a vertical shading for later use. +% +% #1 = optinal dependecies +% #2 = name of the shading for later use +% #3 = height of the shading +% #4 = color specification +% +% Example: +% +% \pgfdeclareverticalshading{redtogreentoblue}{1cm}{% +% rgb(0cm)=(1,0,0); % red +% rgb(1cm)=(0,1,0); % green +% rgb(2cm)=(0,0,1)} +% +% \begin{document} +% The following bar is 2cm high: \pgfuseshading{redtogreentoblue}. +% \end{document} + +\def\pgfdeclareverticalshading{\pgfutil@ifnextchar[\pgf@declareverticalshading{\pgf@declareverticalshading[]}}% +\def\pgf@declareverticalshading[#1]#2#3#4{% + \expandafter\def\csname pgf@deps@pgfshading#2!\endcsname{#1}% + \expandafter\ifx\csname pgf@deps@pgfshading#2!\endcsname\pgfutil@empty% + \pgfsys@vertshading{#2}{#3}{#4}% + \else% + \expandafter\def\csname pgf@func@pgfshading#2!\endcsname{\pgfsys@vertshading}% + \expandafter\def\csname pgf@args@pgfshading#2!\endcsname{{#3}{#4}}% + \expandafter\let\csname @pgfshading#2!\endcsname=\pgfutil@empty% + \fi} + + +% Declares a radial shading for later use. +% +% #1 = optional dependencies +% #2 = name of the shading for later use +% #3 = center of inner circle +% #4 = color specification +% +% Description: +% +% A radial shading creates a smooth color transition between two +% circles. The center of the inner circle is at the give position. Its +% radius is the start of the color specification. The +% center of the outer circle is at the center of the whole shading, +% whose radius is the end of the color specification. For example, +% suppose the color specification is "rgb(1cm)=(1,1,1); rgb(2cm)=(0,0,0)". +% Then the shading would be 4cm times 4cm large. The inner circle would +% have diameter 1cm and the outer circle would have diameter 2cm. The +% outer circle would be centered in the middle of the shading, whereas +% the outer circle would be centered at the given position. +% +% Example: +% +% \pgfdeclareradialshading{redtogreentoblue}{\pgfpoint{2cm}{2cm}}{% +% rgb(10pt)=(1,0,0); % red +% rgb(2cm)=(0,1,0); % green +% rgb(3cm)=(0,0,1)} +% +% \begin{document} +% The following ball has diameter 3cm: \pgfuseshading{redtogreentoblue}. +% \end{document} + +\def\pgfdeclareradialshading{\pgfutil@ifnextchar[\pgf@declareradialshading{\pgf@declareradialshading[]}}% +\def\pgf@declareradialshading[#1]#2#3#4{% + \expandafter\def\csname pgf@deps@pgfshading#2!\endcsname{#1}% + \expandafter\ifx\csname pgf@deps@pgfshading#2!\endcsname\pgfutil@empty% + \pgfsys@radialshading{#2}{#3}{#4}% + \else% + \expandafter\def\csname pgf@func@pgfshading#2!\endcsname{\pgfsys@radialshading}% + \expandafter\def\csname pgf@args@pgfshading#2!\endcsname{{#3}{#4}}% + \expandafter\let\csname @pgfshading#2!\endcsname=\pgfutil@empty% + \fi} + + + + +% Declares a functional shading for later use. +% +% #1 = optional dependecies +% #2 = name of the shading for later use +% #3 = lower left corner of the shading as a pgfpoint. +% #4 = upper right corner of the shading as a pgfpoint. +% #5 = Preparation code +% #6 = a PDF type 4 function (restricted Postscript function), see the +% PDF-specification 1.7, section 3.9.4 +% +% Description: +% +% This command creates a so-called functional shading. For such a +% shading the color of each point is calculated by calling a function +% for each point that gets the coordinates as input and yields the +% color as an output. Note that the function is evaluated by the +% *renderer*, not by PGF or TeX or someone else at compile-time. This +% means that the evaluation of this function has to be done *extremely +% quickly* and the funciton should be *very simple*. For this reason, +% only a very restricted set of operations are possible in the +% function (see 3.9.4 of the PDF-spec 1.7). Also functions should be +% kept small. Any errors in the function will only be noticed by the +% renderer. +% +% The function gets the coordinates of a point as input (as bp). This +% input consists of the top two elements of an otherwise empty +% (virtual, PostScript) stack. The function should then replace these +% two values by three values, representing the red, green, and blue +% color of the point. The numbers should be real values, not integers +% since Apple's PDF renderer is broken in this regard (use cvr at the +% end if necessary). +% +% Conceptually, the function will be evaluated once for each point of +% the rectangle (#3) to (#4). A renderer may choose to evaluate the +% function at less points, but, in principle, the function will be +% evaluated for each pixel independently. +% +% Because of the rather difficult PostScript syntax, use this macro +% only *if you know what you are doing* (or if you are advanterous, of +% course). +% +% As for other shadings, the optional depencies argument is used to +% determine whether a shading needs to be recalculated when a color +% has changed. +% +% The code #5 is executed each time a shading is +% (re)calculated. Typically, it will contain code to extract +% coordinates from colors (see below). +% +% Inside the PostScript function #6 you cannot use colors +% directly. Rather, you must push the color components on the +% stack. For this, it is useful to call \pgfshadergb in the startup +% code #4. The macro takes a color name as input and stores the color's +% red/green/blue components real numbers between 0.0 and 1.0 separated +% by spaces (which is exactly what you need if you want to push it on +% a stack) in a macro. +% +% Example: +% +%\pgfdeclarefunctionalshading{twospots}{\pgfpointorigin}{\pgfpoint{200bp}{200bp}}{}{ +% 2 copy +% 90 sub dup mul exch +% 80 sub dup mul add sqrt +% dup mul neg 1.0005 exch exp 1.0 exch sub +% 3 1 roll +% 120 sub dup mul exch +% 100 sub dup mul add sqrt +% dup mul neg 1.002 exch exp 1.0 exch sub +% 1.0 +%} +% +% \pgfdeclarefunctionalshading[mycol]{sweep}{\pgfpointorigin}{\pgfpoint{100bp}{100bp}} +% {\pgfshadecolortorgb{mycol}{\myrgb}}{ +% add 150 div % not very useful... +% dup +% \myrgb % push mycol +% 5 4 roll % multiply all components by calculated value +% mul +% 3 1 roll +% 3 index +% mul +% 3 1 roll +% 4 3 roll +% mul +% 3 1 roll +% } +% +% \begin{document} +% Have a look at this: \pgfuseshading{twospots}. +% Here is \colorlet{mycol}{green!50}\pgfuseshading{sweep} in green +% and in \colorlet{mycol}{red!50!blue}\pgfuseshading{sweep} in red/blue. +% \end{document} + +\def\pgfdeclarefunctionalshading{\pgfutil@ifnextchar[\pgf@declarefunctionalshading{\pgf@declarefunctionalshading[]}}% +\def\pgf@declarefunctionalshading[#1]#2#3#4#5#6{% + \expandafter\def\csname pgf@deps@pgfshading#2!\endcsname{#1}% + \expandafter\ifx\csname pgf@deps@pgfshading#2!\endcsname\pgfutil@empty% + \pgfshade@functionaldo{#2}{#3}{#4}{#5}{#6}% + \else% + \expandafter\def\csname pgf@func@pgfshading#2!\endcsname{\pgfshade@functionaldo}% + \expandafter\def\csname pgf@args@pgfshading#2!\endcsname{{#3}{#4}{#5}{#6}}% + \expandafter\let\csname @pgfshading#2!\endcsname=\pgfutil@empty% + \fi} +\def\pgfshade@functionaldo#1#2#3#4#5{% + {% + #4% + \pgfsys@functionalshading{#1}{#2}{#3}{#5}% + }% +} + +\def\pgfshadecolortorgb#1#2{% + \pgfutil@colorlet{pgf@tempcol}{#1}% + \pgfutil@extractcolorspec{pgf@tempcol}{\pgf@tempcolor}% + \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}% + \expandafter\pgfshading@rgb\pgf@rgbcolor\relax% + \edef#2{\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@xc}\space}% +} +\def\pgfshading@rgb#1,#2,#3\relax{% + \pgf@xa=#1pt% + \pgf@xb=#2pt% + \pgf@xc=#3pt% +} + + + + +% Inserts a box into the text that contains a previously defined +% shading. +% +% #1 = Name of a shading +% +% Example: +% +% \pgfuseshading{redtogreentoblue} + +\def\pgfuseshading#1{% + \edef\pgf@shadingname{@pgfshading#1}% + \pgf@tryextensions{\pgf@shadingname}{\pgfalternateextension}% + \expandafter\pgfutil@ifundefined\expandafter{\pgf@shadingname}% + {\PackageError{pgfshade}{Undefined shading "#1"}{}}% + {% + {% + \pgfutil@globalcolorsfalse% + \def\pgf@shade@adds{}% + \pgfutil@ifundefined{pgf@deps\pgf@shadingname}% + {}% + {% + \edef\@list{\csname pgf@deps\pgf@shadingname\endcsname}% + \pgfutil@for\@temp:=\@list\do{% + {% + \pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{\@temp}}% + \pgfutil@extractcolorspec{\@temp}{\pgf@tempcolor}% + \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}% + \xdef\pgf@shade@adds{\pgf@shade@adds,\pgf@rgbcolor}% + }% + }% + }% + \expandafter\pgf@strip@shadename\pgf@shadingname!!% + \pgfutil@ifundefined{@pgfshading\pgf@basename\pgf@shade@adds!}% + {% + {% + \expandafter\def\expandafter\@temp\expandafter{\csname pgf@func\pgf@shadingname\endcsname}% + \edef\@args{{\pgf@basename\pgf@shade@adds}}% + \expandafter\expandafter\expandafter\def% + \expandafter\expandafter\expandafter\@@args% + \expandafter\expandafter\expandafter{\csname pgf@args\pgf@shadingname\endcsname}% + \expandafter\expandafter\expandafter\@temp\expandafter\@args\@@args% + % + }% + }% + {}% + \pgf@invokeshading{\csname @pgfshading\pgf@basename\pgf@shade@adds!\endcsname}% + }% + }% +} + +\def\pgf@strip@shadename @pgfshading#1!!!{\def\pgf@basename{#1}} + +\def\pgf@invokeshading#1{% + \ifpgfpicture% + \pgfsys@shadinginsidepgfpicture{#1}% + \else% + \pgfsys@shadingoutsidepgfpicture{#1}% + \fi% +} + + +% Create an alias name for a shading +% +% #1 = name of the alias +% #2 = name of the original +% +% Example: +% +% \pgfaliasshading{shading!25}{shadingshaded} + +\def\pgfaliasshading#1#2{% + \expandafter\let\expandafter\pgf@temp\expandafter=\csname @pgfshading#2!\endcsname% + \expandafter\let\csname @pgfshading#1!\endcsname=\pgf@temp% + \expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@deps@pgfshading#2!\endcsname% + \expandafter\let\csname pgf@deps@pgfshading#1!\endcsname=\pgf@temp% + \expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@func@pgfshading#2!\endcsname% + \expandafter\let\csname pgf@func@pgfshading#1!\endcsname=\pgf@temp% + \expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@args@pgfshading#2!\endcsname% + \expandafter\let\csname pgf@args@pgfshading#1!\endcsname=\pgf@temp% +} + + + + +% Shades the current path, but does not discard it. +% +% #1 - a shading (see below) +% #2 - an angle +% +% Description: +% +% \pgfshadepath ``tries'' to fill the +% current path with a shading. The shading's original size should +% completely cover the area between (0,0) and (100bp,100bp). The +% shading will be rotated by #2 and then rescaled so that it +% completely covers the path. Then the path will be used (locally) for +% clipping and the shading is drawn. +% +% In addition to the rotation, any transformation set by the +%\pgfsetadditionalshadetransform will also be applied. +% +% After all this, the path can still be used for the normal +% stroking/clipping operations. +% +% The shading is rotated around its middle. If no rotation occurs, the +% lower left corner of the path will lie on (25bp, 25bp), the upper +% right corner on (75bp, 75bp). +% +% Example: +% +% \pgfdeclareverticalshading{myshading}{100bp}{color(0pt)=(red); color(100bp)=(green)} +% +% \pgfpathmoveto{\pgforigin} +% \pgfpathlineto{\pgfxy(1,0)} +% \pgfpathlineto{\pgfxy(1,1)} +% \pgfshadepath{myshading}{0} +% \pgfusepath{stroke} + +\def\pgfshadepath#1#2{% + \ifdim\pgf@pathminx=16000pt% + \PackageWarning{pgfshade}{No path specified that can be filled}% + \else% + \begingroup% + \pgfsys@beginscope% + % Calculate center: + \pgf@xb=.5\pgf@pathmaxx% + \advance\pgf@xb by.5\pgf@pathminx% + \pgf@yb=.5\pgf@pathmaxy% + \advance\pgf@yb by.5\pgf@pathminy% + % Calculate scaling: + \pgf@xc=\pgf@pathmaxx% + \advance\pgf@xc by-\pgf@pathminx% + \pgf@yc=\pgf@pathmaxy% + \advance\pgf@yc by-\pgf@pathminy% + \pgf@xc=.02\pgf@xc% + \pgf@yc=.02\pgf@yc% + \pgfsyssoftpath@invokecurrentpath% + \pgfsys@clipnext% + \pgfsys@discardpath% + % Compute new transformation matrix: + \pgfsys@transformcm{1}{0}{0}{1}{\pgf@xb}{\pgf@yb}% + \pgfsys@transformcm% + {\pgf@sys@tonumber{\pgf@xc}}{0}% + {0}{\pgf@sys@tonumber{\pgf@yc}}{0pt}{0pt}% + \pgfmathparse{#2}% + \let\pgfshade@angle=\pgfmathresult% + \pgfmathsin@{\pgfshade@angle}% + \let\pgfshade@sin=\pgfmathresult% + \pgfmathcos@{\pgfshade@angle}% + \let\pgfshade@cos=\pgfmathresult% + \pgf@x=\pgfshade@sin pt% + \pgf@xa=-\pgf@x% + \pgfsys@transformcm{\pgfshade@cos}{\pgfshade@sin}{\pgf@sys@tonumber{\pgf@xa}}{\pgfshade@cos}{0pt}{0pt}% + \ifx\pgf@shade@extra@transform\pgfutil@empty% + \else% + \pgflowlevel{\pgf@shade@extra@transform}% + \fi% + \pgfuseshading{#1}% + \pgfsys@endscope% + \endgroup% + \fi% +} + + +% Additionally transform shade paths +% +% #1 = Transformation code that is used in addition to the normal +% shading transformation. +% +% Example: +% +% \pgfsetadditionalshadetransform{\pgftransformrotate{30}} + +\def\pgfsetadditionalshadetransform#1{\def\pgf@shade@extra@transform{#1}} +\let\pgf@shade@extra@transform=\pgfutil@empty + + + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransformations.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransformations.code.tex new file mode 100644 index 00000000000..caf5432b4d8 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransformations.code.tex @@ -0,0 +1,632 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 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 $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoretransformations.code.tex,v 1.10 2008/02/04 17:19:54 tantau Exp $ + + +% Position transformations + +\newdimen\pgf@pt@x +\newdimen\pgf@pt@y + +\newdimen\pgf@pt@temp + +\newif\ifpgf@pt@identity +\pgf@pt@identitytrue + +\def\pgf@pt@aa{1.0} \def\pgf@pt@ab{0.0} +\def\pgf@pt@ba{0.0} \def\pgf@pt@bb{1.0} + + + +% Store the current transformation matrix in a macro. +% +% #1 = macro name +% +% Example: +% +% \pgfgettransform\mytransform + +\def\pgfgettransform#1{% + \edef#1{{\pgf@pt@aa}{\pgf@pt@ab}{\pgf@pt@ba}{\pgf@pt@bb}{\the\pgf@pt@x}{\the\pgf@pt@y}} +} + + +% Restore the current transformation matrix from a macro. +% +% #1 = macro name, previously used with \pgfgettransform +% +% Example: +% +% \pgfsettransform\mytransform + +\def\pgfsettransform#1{% + \edef\pgf@temp{#1}% + \expandafter\pgf@settransform\pgf@temp% +} +\def\pgf@settransform#1#2#3#4#5#6{% + \def\pgf@pt@aa{#1}% + \def\pgf@pt@ab{#2}% + \def\pgf@pt@ba{#3}% + \def\pgf@pt@bb{#4}% + \pgf@pt@x=#5% + \pgf@pt@y=#6% + \edef\pgf@idtest{#1,#2,#3,#4}% + \ifx\pgf@idtest\pgf@idmatrixtext% + \pgf@pt@identitytrue% + \else% + \pgf@pt@identityfalse% + \fi% +} + +\def\pgf@idmatrixtext{1.0,0.0,0.0,1.0} +\def\pgf@zerozerotext{0.0,0.0} + +% Transformation command +% +% #1 = x dimension +% #2 = y dimension +% +% Description: +% +% Applies the pgfs transformation matrix to the point (#1,#2). The +% result is once more stored in the point. +% +% +% Example: +% +% \pgf@pos@transform{\pgf@x}{\pgf@y} + +\def\pgf@pos@transform#1#2{% + \ifpgf@pt@identity% + \else% + \pgf@pt@temp=#1% + #1=\pgf@pt@aa#1% + \advance#1 by\pgf@pt@ba#2% + #2=\pgf@pt@bb#2% + \advance#2 by\pgf@pt@ab\pgf@pt@temp% + \fi% + \advance#1 by\pgf@pt@x% + \advance#2 by\pgf@pt@y% +} + + +% Invert the current transformation matrix +% +% Description: +% +% This command replaces the current transformation matrix by its +% inverse. The inversion is not very exact if the matrix is nearly +% singular. +% +% Example: +% +% \pgftransforminvert + +\def\pgftransforminvert{% + % First, invert the shift. That's easy + \pgf@pt@x=-\pgf@pt@x + \pgf@pt@y=-\pgf@pt@y + \ifpgf@pt@identity% + \else% + % Sigh. Have to calculate the inverse of the matrix. + % Perhaps we are lucky and ba and bb are zero? + \edef\pgf@zerotest{\pgf@pt@ab,\pgf@pt@ba}% + \ifx\pgf@zerotest\pgf@zerozerotext% + % Ha! Just invert aa and bb + \pgfmathreciprocal@{\pgf@pt@aa}% + \let\pgf@pt@aa\pgfmathresult% + \pgfmathreciprocal@{\pgf@pt@bb}% + \let\pgf@pt@bb\pgfmathresult% + \else% + % Start with determinant + % Matrix = (aa ab + % ba bb) + {% + \pgfutil@tempdima=\pgf@pt@aa pt% + \pgfutil@tempdima=\pgf@pt@bb\pgfutil@tempdima% aa * bb + \pgfutil@tempdimb=\pgf@pt@ba pt% + \pgfutil@tempdimb=\pgf@pt@ab\pgfutil@tempdimb% ba * ab + \advance\pgfutil@tempdima by -\pgfutil@tempdimb% aa*bb - ba*ab + % Invert + \pgfmathreciprocal@{\pgf@sys@tonumber{\pgfutil@tempdima}}% + \pgfutil@tempdima=\pgfmathresult pt% + \pgf@x=\pgf@pt@bb\pgfutil@tempdima% bb/(det A) + \xdef\pgf@new@pt@aa{\pgf@sys@tonumber{\pgf@x}}% + \pgf@x=\pgf@pt@aa\pgfutil@tempdima% aa/(det A) + \xdef\pgf@new@pt@bb{\pgf@sys@tonumber{\pgf@x}}% + \pgfutil@tempdima=-\pgfutil@tempdima% + \pgf@x=\pgf@pt@ba\pgfutil@tempdima% -ba/(det A) + \xdef\pgf@new@pt@ba{\pgf@sys@tonumber{\pgf@x}}% + \pgf@x=\pgf@pt@ab\pgfutil@tempdima% -ab/(det A) + \xdef\pgf@new@pt@ab{\pgf@sys@tonumber{\pgf@x}}% + }% + \let\pgf@pt@aa\pgf@new@pt@aa% + \let\pgf@pt@ab\pgf@new@pt@ab% + \let\pgf@pt@ba\pgf@new@pt@ba% + \let\pgf@pt@bb\pgf@new@pt@bb% + \fi% + \pgf@pt@temp=\pgf@pt@x% + \pgf@pt@x=\pgf@pt@aa\pgf@pt@x% + \advance\pgf@pt@x by\pgf@pt@ba\pgf@pt@y% + \pgf@pt@y=\pgf@pt@bb\pgf@pt@y% + \advance\pgf@pt@y by\pgf@pt@ab\pgf@pt@temp% + \fi% +} + + + + +% PGF-Level concatenation of the transformation matrix with a given +% matrix. +% +% #1 - #5 = a concatenation matrix (see pdf spec). Entry #5 is a +% translation point. +% +% Description: +% +% All coordinates given to subsequent path construction commands will +% be transformed additionally by the given transformation matrix. If +% the command is followed by a 6th argument, the transformation is +% only applied to this argument. +% +% +% Example: +% +% \pgftransformcm{1}{0}{0}{1}{\pgfpoint{100pt}{0pt}} % 100pt to the right. +% +% \pgftransformcm{2}{0}{0}{2}{\pgfpointorigin} % double in in size +% \pgfpathmoveto{\pgfpoint{0cm}{0cm}} +% \pgfpathlineto{\pgflineto{1cm}{1cm}} % actually 2cm/2cm + +\def\pgftransformcm#1#2#3#4#5{% + \edef\pgf@marshal{\noexpand\pgf@transformcm{#1}{#2}{#3}{#4}}% + \pgf@marshal{#5}% +} +\def\pgf@transformcm#1#2#3#4#5{% + {% + \pgf@process{#5}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + % + \pgfmathsetlength\pgf@x{#1}% + \pgfmathsetlength\pgf@y{#2}% + % + \pgf@xa=\pgf@pt@aa\pgf@x% + \advance\pgf@xa by \pgf@pt@ba\pgf@y% + % + \pgf@ya=\pgf@pt@ab\pgf@x% + \advance\pgf@ya by \pgf@pt@bb\pgf@y% + % + \pgfmathsetlength\pgf@x{#3}% + \pgfmathsetlength\pgf@y{#4}% + % + \pgf@xb=\pgf@pt@aa\pgf@x% + \advance\pgf@xb by \pgf@pt@ba\pgf@y% + % + \pgf@yb=\pgf@pt@ab\pgf@x% + \advance\pgf@yb by \pgf@pt@bb\pgf@y% + % + \pgf@x=\pgf@pt@aa\pgf@xc% + \advance\pgf@x by\pgf@pt@ba\pgf@yc% + \advance\pgf@x by\pgf@pt@x% + % + \pgf@y=\pgf@pt@ab\pgf@xc% + \advance\pgf@y by\pgf@pt@bb\pgf@yc% + \advance\pgf@y by\pgf@pt@y% + % + \global\pgf@x=\pgf@x% + \global\pgf@y=\pgf@y% + \xdef\pgf@tempaa{\pgf@sys@tonumber{\pgf@xa}}% + \xdef\pgf@tempab{\pgf@sys@tonumber{\pgf@ya}}% + \xdef\pgf@tempba{\pgf@sys@tonumber{\pgf@xb}}% + \xdef\pgf@tempbb{\pgf@sys@tonumber{\pgf@yb}}% + }% + \pgf@pt@x=\pgf@x% + \pgf@pt@y=\pgf@y% + \let\pgf@pt@aa=\pgf@tempaa% + \let\pgf@pt@ba=\pgf@tempba% + \let\pgf@pt@ab=\pgf@tempab% + \let\pgf@pt@bb=\pgf@tempbb% + \edef\pgf@idtest{\pgf@pt@aa,\pgf@pt@ba,\pgf@pt@ab,\pgf@pt@bb}% + \ifx\pgf@idtest\pgf@idmatrixtext% + \pgf@pt@identitytrue% + \else% + \pgf@pt@identityfalse% + \fi% +} + + +% Add a pre-morph +% +% #1 = morphing code +% +% Description: +% +% This function adds code to the pre-morphing list. When a +% coordinate is transformed, the current pre-morphing code is +% called first. Then the transformation matrix is applied. Finally, all +% post-morphing code is called. The morphing list is local to the +% current TeX group. +% +% The job of the #1 macro is to modify the values of \pgf@x and +% \pgf@y. It should not have any other sideeffects. +% +% Example: +% +% \pgfmorphaddmorph{\advance\pgf@x by 1cm\relax} + +\def\pgfmorphaddpre#1{\expandafter\def\expandafter\pgfmorph@prelist\expandafter{\pgfmorph@prelist#1}} +\let\pgfmorph@prelist=\pgfutil@empty + + +% Add a post-morph +% +% #1 = morphing macro +% +% Description: +% +% The only difference to the pre-morphs is that post morphs are +% executed after the transformation matrix has been applied. + +\def\pgfmorphaddpost#1{\expandafter\def\expandafter\pgfmorph@postlist\expandafter{\pgfmorph@postlist#1}} +\let\pgfmorph@postlist=\pgfutil@empty + + +% Transformation into a given triangle. The three corners of the +% triangle are called "origin", "x" and "y" are given. After this +% transformation has been applied, the canvas origin is at "origin", +% the vector (1pt,0pt) lies at "x" and the vector (0pt,1pt) lies at +% "y". +% +% #1 = origin +% #2 = x +% #3 = y +% +% Example: +% +% \pgftransformtriangle{\pgfpointorigin}{\pgfpoint{1cm}{1cm}}{\pgfpoint{-1cm}{1cm}} + +\def\pgftransformtriangle#1#2#3{% + \pgf@process{#2}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#3}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@process{#1}% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + \advance\pgf@xb by-\pgf@x% + \advance\pgf@yb by-\pgf@y% + \pgftransformcm% + {\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@ya}% + {\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@yb}% + {\pgfpoint{\pgf@x}{\pgf@y}}% +} + + + +% Undo all transformations +% +% Example: +% +% \pgftansformreset + +\def\pgftransformreset{% + \pgf@pt@x=0pt% + \pgf@pt@y=0pt% + \def\pgf@pt@aa{1.0}% + \def\pgf@pt@ba{0.0}% + \def\pgf@pt@ab{0.0}% + \def\pgf@pt@bb{1.0}% + \pgf@pt@identitytrue% +} + + +% Undo all slanting/rotation, but not translations +% +% Example: +% +% \pgftansformreset + +\def\pgftransformresetnontranslations{% + \def\pgf@pt@aa{1.0}% + \def\pgf@pt@ba{0.0}% + \def\pgf@pt@ab{0.0}% + \def\pgf@pt@bb{1.0}% + \pgf@pt@identitytrue% +} + + + + +% Shifting command and environment +% +% #1 = vector by which all subsequent points should be moved. +% +% Example: +% +% \pgftansformshift{\pgfpoint{1cm}{1cm}} + +\def\pgftransformshift#1{\pgftransformcm{1.0}{0}{0}{1.0}{#1}} +\def\pgftransformxshift#1{\pgftransformcm{1.0}{0}{0}{1.0}{\pgfpoint{#1}{0pt}}} +\def\pgftransformyshift#1{\pgftransformcm{1.0}{0}{0}{1.0}{\pgfpoint{0pt}{#1}}} + + + + +% Scaling commands +% +% #1 = scaling for all subsequent points. +% +% Example: +% +% \pgftransformscale{2} +% \pgftransformxscale{2} +% \pgftransformyscale{2} + +\def\pgftransformscale#1{\pgftransformcm{#1}{0}{0}{#1}{\pgfpointorigin}} +\def\pgftransformxscale#1{\pgftransformcm{#1}{0}{0}{1.0}{\pgfpointorigin}} +\def\pgftransformyscale#1{\pgftransformcm{1.0}{0}{0}{#1}{\pgfpointorigin}} + + + +% Slanting commands +% +% #1 = slanting in x-direction. 1 means 45 degrees. +% +% Example: +% +% \pgftransformxslant{2} +% \pgftransformyslant{2} + +\def\pgftransformxslant#1{\pgftransformcm{1.0}{0}{#1}{1.0}{\pgfpointorigin}} +\def\pgftransformyslant#1{\pgftransformcm{1.0}{#1}{0}{1.0}{\pgfpointorigin}} + + + +% Rotation commands +% +% #1 = degrees for the rotation +% +% Example: +% +% \pgftransformrotate{30} + +\def\pgftransformrotate#1{% + \pgfmathparse{#1}% + \let\pgftransform@angle=\pgfmathresult% + \pgfmathsin@{\pgftransform@angle}% + \let\pgftransform@sin=\pgfmathresult% + \pgfmathcos@{\pgftransform@angle}% + \let\pgftransform@cos=\pgfmathresult% + \pgf@x=\pgftransform@sin pt% + \pgf@xa=-\pgf@x% + \pgftransformcm{\pgftransform@cos}{\pgftransform@sin}{\pgf@sys@tonumber{\pgf@xa}}{\pgftransform@cos}{\pgfpointorigin}% +} + + + +% The following if's have the following effect: +% +% \ifpgfslopedattime decides whether the coordinate system of an +% xxxattime transformation command should be rotated such that text +% drawn on the line should be tangent to the line +% +% \ifpgfallowupsidedowattime decides whether the transformation should +% be done in such a way that the text is always ``upright,'' that is, +% text drawn in this coordiante system is never upside-down. +% +% \ifpgfresetnontranslationattime decides whether the coordinate +% system of an xxxattime transformation command should be reset +% (concerning the non-translations) before a possible rotation is +% applied. This is useful, for example, if the main coordinate system +% is scaled by, say, a factor of 2 and you do not want that to apply +% to the text, but you do want the rotation to applyu. + +\newif\ifpgfslopedattime +\newif\ifpgfallowupsidedownattime +\newif\ifpgfresetnontranslationattime + + +% Transform to the coordinate system of a point on a line +% +% #1 = a time fraction of line where to put the label, where 0 means start, +% 1 means end, and for example 0.5 means the middle. +% #2 = start of line +% #3 = end of line +% +% Example: +% +% { +% \pgftransformlineattime{.5}{\pgfxy(0,0)}{\pgfxy(3,2)} +% \pgftext{Hi!} +% } +% +% { +% \pgftransformlineattime{.75}{\pgfxy(0,0)}{\pgfxy(3,2)} +% \pgftransformresetnontranslations +% \pgftext{Hi!} +% } +% +\def\pgftransformlineattime#1#2#3{% + \pgftransformshift{\pgfpointlineattime{#1}{#2}{#3}}% + \ifpgfresetnontranslationattime% + \pgftransformresetnontranslations% + \fi% + \ifpgfslopedattime% + \pgf@process{#2}% + \pgf@xa=\pgf@x% xb/yb = start point + \pgf@ya=\pgf@y% + \pgf@process{#3}% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@y by-\pgf@ya% + \ifpgfallowupsidedownattime% + \else% + \ifdim\pgf@x<0pt% + \pgf@x=-\pgf@x% + \pgf@y=-\pgf@y% + \fi% + \fi% + \pgfpointnormalised{}% x/y = normalised vector + \pgf@ya=-\pgf@y% + \pgftransformcm% + {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}% + {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}% + \fi% +} + + + + +% Transform to the coordinate system of a point on a curve +% +% #1 = a time fraction of line where to put the label, where 0 means start, +% 1 means end, and for example 0.5 means the middle. +% #2 = start of line +% #3 = first control +% #4 = second control +% #5 = end of line +% +% Example: +% +% { +% \pgftransformcurveattime{.5}{\pgfxy(0,0)}{\pgfxy(3,2)} +% \pgftext{Hi!} +% } +% +% { +% \pgftransformcurveattime{.75}{\pgfxy(0,0)}{\pgfxy(3,2)} +% \pgftransformresetnontranslations +% \pgftext{Hi!} +% } +% +\def\pgftransformcurveattime#1#2#3#4#5{% + \pgfpointcurveattime{#1}{#2}{#3}{#4}{#5}% + \pgftransformshift{\pgfqpoint{\pgf@x}{\pgf@y}}% + \ifpgfresetnontranslationattime% + \pgftransformresetnontranslations% + \fi% + \ifpgfslopedattime% + \pgf@x=\pgf@xa% + \pgf@y=\pgf@ya% + \advance\pgf@x by-\pgf@xb% + \advance\pgf@y by-\pgf@yb% + \ifpgfallowupsidedownattime% + \else% + \ifdim\pgf@x<0pt% + \pgf@x=-\pgf@x% + \pgf@y=-\pgf@y% + \fi% + \fi% + \pgfpointnormalised{}% x/y = normalised vector + \pgf@ya=-\pgf@y% + \pgftransformcm% + {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}% + {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}% + \fi% +} + + + + + +% Transform to the coordinate system of an arrow at the end of the +% line going from point #1 to point #2 with the correct rotation. +% +% #1 = a start point an (invisible) line +% #2 = an end point an (invisible) line +% +% Example: +% +% \pgftransformarrow{\pgfpointorigin}{\pgfpoint{1cm}{0cm}} + +\def\pgftransformarrow#1#2{% + \pgftransformshift{#2}% + \pgf@process{#2}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#1}% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + \pgf@x=\pgf@xa% + \pgf@y=\pgf@ya% + \pgfpointnormalised{}% + \pgf@ya=-\pgf@y% + \pgftransformcm% + {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}% + {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfqpoint{0pt}{0pt}}% +} + + + +% Low-level transformations + +% Causes the current high-level transformation command to be applied +% to the low-level. +% +% Description: +% +% All subsequent drawing will be transformed additionally by the +% current high-level transformation. Thus, the high-level +% transformation becomes the low-level transformation. The high-level +% transformation is reset at this point. + +\def\pgflowlevelsynccm{% + \pgfsys@transformcm% + {\pgf@pt@aa}{\pgf@pt@ab}% + {\pgf@pt@ba}{\pgf@pt@bb}% + {\pgf@pt@x}{\pgf@pt@y}% + \pgftransformreset% + \pgf@relevantforpicturesizefalse% +} + + + +% Causes a transformation command to be applied to the ``lowlevel'' +% transformation matrix. +% +% #1 - a high-level transformation command +% +% Description: +% +% All subsequent drawing will be transformed additionally by the given +% transformation matrix. Note that PGF will no longer be able to +% ``keep track'' of the coordinates. Also, transformations are applied +% to *everything*, including line thickness and line endings. Most +% often, this is not desirable. +% +% Example: +% +% \pgflowlevel{\pgftransformcm{1}{0}{0}{1}{\pgfpoint{100pt}{0pt}}} % 100bp to the right. +% +% \begin{pgflowlevelscope}{\pgftransformcm{2}{0}{0}{2}{\pgfpointorigin}} % double in in size +% \pgfmoveto{\pgfpoint{0cm}{0cm}} +% \pgflineto{\pgflineto{1cm}{1cm}} % actually 2cm/2cm +% \end{pgflowlevelscope} + +\def\pgflowlevel#1{% + {% + \pgftransformreset% + #1% + \pgflowlevelsynccm% + }% + \pgf@relevantforpicturesizefalse% +} + +\def\pgflowlevelscope#1{\pgfscope\pgflowlevel{#1}} +\def\endpgflowlevelscope{\endpgfscope} + +\long\def\pgflowlevelobj#1#2{\pgfscope{\pgflowlevel{#1}#2}\endpgfscope} + + + + +\endinput |