diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-12 23:46:03 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-12 23:46:03 +0000 |
commit | 873660d1a83ece926fe7206288dda9c36b349c1b (patch) | |
tree | a48f77125c309a355b5d0eb58d6b24446abe9d62 /Master/texmf-dist/tex/generic/pgf/basiclayer | |
parent | 2939242967231097459df0fc3150fabc2f639111 (diff) |
generic 1
git-svn-id: svn://tug.org/texlive/trunk@613 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/basiclayer')
18 files changed, 6818 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseimage.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseimage.code.tex new file mode 100644 index 00000000000..41597300e23 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseimage.code.tex @@ -0,0 +1,236 @@ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfbaseimage.code.tex,v 1.2 2005/07/06 15:58:57 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + + + +% Declare an image +% +% #1 = optional argument: width, height, page specification +% #2 = name of the image for later use +% #4 = filename without extension, automatic extensions are .pdf, +% .jpg, and .png for PDF and .ps, .eps, .epsi for postscript. +% +% Description: +% +% This command declares an image file for later use. Even if the image +% is used several times in the document, in PDF it will only be stored +% once. +% +% Example: +% +% \pgfdeclareimage[width=2cm,page=2]{myimage}{imagefilename} + +\def\pgfdeclareimage{\@ifnextchar[{\pgf@declareimage}{\pgf@declareimage[]}} +\def\pgf@declareimage[#1]#2#3{% + \setkeys{pgfimage}{height=,width=,page=,interpolate=false,mask=}% defaults + \setkeys{pgfimage}{#1}% + % Try to find the file + \gdef\pgf@filename{}% + % If page= parameter is not empty, try that file first: + \ifx\pgf@imagepage\@empty% + \else% + \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3.page\pgf@imagepage}% + \fi% + \ifx\pgf@filename\@empty% + \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3}% + \else% + \setkeys{pgfimage}{page=}% make page empty + \fi% + \ifx\pgf@filename\@empty% + \PackageWarning{pgf}% + {File "#3" not found when defining image "#2".\MessageBreak + Tried all extensions in "\pgfsys@imagesuffixlist"}% + \pgf@declaredraftimage{#2}% + \else% + \ifpgf@draftmode% + \pgf@declaredraftimage{#2}% + \else% + \pgfsys@defineimage% + \fi% + \fi% + \expandafter\global\expandafter\let\csname pgf@image@#2!\endcsname=\pgf@image% +} + +\define@key{pgfimage}{width}{\edef\pgf@imagewidth{#1}} +\define@key{pgfimage}{height}{\edef\pgf@imageheight{#1}} +\define@key{pgfimage}{page}{\edef\pgf@imagepage{#1}} +\define@key{pgfimage}{interpolate}[true]{\edef\pgf@imageinterpolate{/Interpolate #1}} +\define@key{pgfimage}{mask}{% + \edef\pgf@imagemask{#1}% + \ifx\pgf@imagemask\@empty% + \else% + \@ifundefined{pgf@mask@#1}% + {\PackageError{pgf}{Undefined mask "#1".}{}% + \edef\pgf@imagemask{}}% + {\edef\pgf@imagemask{\csname pgf@mask@#1\endcsname}% + \ifx\pgf@imagemask\@empty% + \else + \edef\pgf@imagemask{/SMask \pgf@imagemask\space 0 R}% + \fi}% + \fi} + +\def\pgf@findfile#1:#2+#3{% + \IfFileExists{#3.#1}% + {\xdef\pgf@filename{#3.#1}}% + {\def\pgf@mightbeempty{#2}% + \ifx\pgf@mightbeempty\@empty\else% + \pgf@findfile#2+{#3}% + \fi}} + +\def\pgf@declaredraftimage#1{% + \ifx\pgf@imagewidth\@empty% + \PackageWarning{pgf}{Missing width for image "#1" in draft mode.\MessageBreak Using 1cm instead}% + \edef\pgf@imagewidth{1cm}% + \fi% + \ifx\pgf@imageheight\@empty% + \PackageWarning{pgf}{Missing height for image "#1" in draft mode.\MessageBreak Using 1cm instead}% + \edef\pgf@imageheight{1cm}% + \fi% + \ifx\pgf@imagepage\@empty\else\edef\pgf@imagepagetext{ page \pgf@imagepage}\fi% + \edef\pgf@image{% + \hbox to \pgf@imagewidth{% + \vrule\kern-0.4pt% + \vbox to \pgf@imageheight{% + \hrule\vfil% + \hbox to \pgf@imagewidth{\hskip-10cm\hfil\noexpand\tiny#1\pgf@imagepage\hfil\hskip-10cm}% + \vfil\hrule}% + \kern-0.4pt\vrule}% + }% +} + + + +% Declare a soft mask +% +% #1 = optional argument: matte specification. default matte is +% white. +% #2 = name of the mask for later use +% #3 = filename without extension, automatic extensions are .pdf, +% .jpg, and .png for PDF. Postscript is not supported. +% +% Description: +% +% This command declares a soft mask for later masking an image. The +% declared mask should be used together with an image of exactly the +% same height/width if matte is defined. Matte should be the +% preblended background color (see pdf spec for details). +% +% Example: +% +% \pgfdeclaremask[matte=white]{maskname}{maskfilename} +% \pgfdeclareimage[mask=maskname]{image}{imagefilename} + +\def\pgfdeclaremask{\@ifnextchar[\pgf@declaremask{\pgf@declaremask[]}} +\def\pgf@declaremask[#1]#2#3{% + \setkeys{pgfmask}{matte={1 1 1}}% defaults + \setkeys{pgfmask}{#1}% + \def\pgf@mask{}% + % Try to find the file + \gdef\pgf@filename{}% + \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3}% + \ifx\pgf@filename\@empty% + \PackageWarning{pgf}% + {File "#3" not found when defining mask "#2".\MessageBreak + Tried all extensions in "\pgfsys@imagesuffixlist"}% + \else% + \pgfsys@definemask% + \fi% + \expandafter\global\expandafter\let\csname pgf@mask@#2\endcsname=\pgf@mask% +} + +\define@key{pgfmask}{matte}{\edef\pgf@maskmatte{#1}} + + + + +% Create an alias name for an image +% +% #1 = name of the alias +% #2 = name of the original +% +% Example: +% +% \pgfdeclareimage{image}{1cm}{1cm}{filename +% \pgfaliasimage{alias}{image} +% \pgfuseimage{alias} + +\def\pgfaliasimage#1#2{% + \expandafter\global\expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@image@#2!\endcsname% + \expandafter\global\expandafter\let\csname pgf@image@#1!\endcsname=\pgf@temp% + } + + +% Use an image +% +% #1 = name of a previously declared image +% +% Example: +% +% \pgfputat{\pgforigin}{\pgfbox[left,base]{\pgfuseimage{myimage}}} + +\def\pgfuseimage#1{% + \def\pgf@imagename{pgf@image@#1}% + \pgf@tryextensions{\pgf@imagename}{\pgfalternateextension}% + \expandafter\@ifundefined\expandafter{\pgf@imagename}% + {\PackageError{pgf}{Undefined image "#1"}{}}% + {{\leavevmode\csname\pgf@imagename\endcsname}}} + +\def\pgf@tryextensions#1#2{% + \edef\pgf@args{[#2!]}\expandafter\pgf@@tryextensions\pgf@args{#1}} +\def\pgf@@tryextensions[#1!#2]#3{% + \expandafter\@ifundefined\expandafter{#3.#1!#2}% + {\def\pgf@temp{#2}% + \ifx\pgf@temp\@empty% + \edef#3{#3!}% + \else% + \pgf@@tryextensions[#2]{#3}% + \fi}% + {\edef#3{#3.#1!#2}}} + + +% Alternate image +% +% Description: +% +% When an image is used, pgf first attempts to use the image with the +% alternate extension added. If this fails, the original image is +% used. If the alternate extension contains ``!'', then the text up to +% the ! is successively removed and the remainder is tried as an +% alternate extension. +% +% Example: +% +% \def\pgfalternateextension{20!white} + +\def\pgfalternateextension{} + + + +% Directly insert an image +% +% #1 = optional argument: width, height, page specification +% #2 = file name +% +% Description: +% +% Directly inserts an image without declaration. You can, however, +% still access this image using the name pgflastimage. By using +% pgfaliasimage, you can also save this image for later. +% +% Example: +% +% \pgfimage[height=2cm]{filename} + +\def\pgfimage{\@ifnextchar[\pgf@imagecom{\pgf@imagecom[]}} +\def\pgf@imagecom[#1]#2{% + \pgfdeclareimage[#1]{pgflastimage}{#2}% + \pgfuseimage{pgflastimage}} + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaselayers.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaselayers.code.tex new file mode 100644 index 00000000000..8e6e97b8017 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaselayers.code.tex @@ -0,0 +1,127 @@ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfbaselayers.code.tex,v 1.1 2005/08/13 18:59:56 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + +% Creates a new pgf layer +% +% #1 = layer name +% +% Declares a new layer for pgf. +% +% Example: +% +% \pgfdeclarelayer{background} + +\def\pgfdeclarelayer#1{% + \expandafter\newbox\csname pgf@layerbox@#1\endcsname% + \expandafter\newbox\csname pgf@layerboxsaved@#1\endcsname% +} + + +% Sets the layers that compose the picture +% +% #1 = List of layers +% +% Description: +% +% Sets the list of layers that make up the picture. The layers will be +% put on top of each other in the order given. +% +% Example: +% +% \pgfsetlayers{background,main} + +\def\pgfsetlayers#1{\edef\pgf@layerlist{#1}} +\pgfsetlayers{main} + + + +% Adds code to a layer +% +% #1 = layer name +% +% Note: +% +% You cannot anything to the ``main'' layer using this command. +% +% Example: +% +% \begin{pgfonlayer}{background} +% \fill[red] (0,0) -- (1,1); +% \end{pgfonlayer} + +\def\pgfonlayer#1{% + \expandafter\global\expandafter% + \setbox\csname pgf@layerbox@#1\endcsname=\hbox to 0pt% + \bgroup% + \expandafter\box\csname pgf@layerbox@#1\endcsname% + \begingroup% +} +\def\endpgfonlayer{% + \endgroup% + \hss + \egroup% +} + + + + +% Hooks into the scoping: + +\def\pgf@insertlayers{% + \expandafter\pgf@dolayer\pgf@layerlist,,\relax% +} +\def\pgf@maintext{main}% +\def\pgf@dolayer#1,#2,\relax{% + \def\pgf@test{#1}% + \ifx\pgf@test\pgf@maintext% + \box\pgf@layerbox@main% + \else% + \pgfsys@beginscope% + \expandafter\box\csname pgf@layerbox@#1\endcsname% + \pgfsys@endscope% + \fi% + \def\pgf@test{#2}% + \ifx\pgf@test\@empty% + \else% + \pgf@dolayer#2,\relax% + \fi% +} + +\def\pgf@savelayers{% + \expandafter\pgf@dosavelayer\pgf@layerlist,,\relax% +} +\def\pgf@dosavelayer#1,#2,\relax{% + \def\pgf@test{#1}% + \ifx\pgf@test\pgf@maintext% + \else% + \setbox\csname pgf@layerboxsaved@#1\endcsname=\box\csname pgf@layerbox@#1\endcsname% + \fi% + \def\pgf@test{#2}% + \ifx\pgf@test\@empty% + \else% + \pgf@dosavelayer#2,\relax% + \fi% +} + +\def\pgf@restorelayers{% + \expandafter\pgf@dorestorelayer\pgf@layerlist,,\relax% +} +\def\pgf@dorestorelayer#1,#2,\relax{% + \def\pgf@test{#1}% + \ifx\pgf@test\pgf@maintext% + \else% + \global\setbox\csname pgf@layerbox@#1\endcsname=\box\csname pgf@layerboxsaved@#1\endcsname% + \fi% + \def\pgf@test{#2}% + \ifx\pgf@test\@empty% + \else% + \pgf@dorestorelayer#2,\relax% + \fi% +} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseplot.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseplot.code.tex new file mode 100644 index 00000000000..f3d9e4f49a7 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseplot.code.tex @@ -0,0 +1,321 @@ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfbaseplot.code.tex,v 1.2 2005/07/06 15:58:57 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + + +% PGF's plotting interface works as follows: +% +% In order to plot something, two things need to be done. First, you +% need to provide the coordinates (obviously) of the points that +% should be plotted. The coordinates are given via a long stream of +% commands. These commands are \pgfplotstreamstart, which is +% given exactly once at the beginning, \pgfplotstreampoint, of which there +% are numerous in the middle, \pgfplotstreamspecial, of which there may be +% numerous in the middle, and \pgfplotstreamend, which must be given +% at the end. Between these commands arbitrary other commands may be +% given. Here is an example: +% +% ... +% \pgfplotstreamstart +% \pgfplotstreampoint{\pgfpointxy{0}{0}} +% \pgfplotstreampoint{\pgfpointxy{1}{1}} +% \pgfplotstreampoint{\pgfpointxy{2}{4}} +% \relax +% \pgfplotstreampoint{\pgfpointxy{3}{9}} +% \pgfplotstreamspecial{some handler-dependent special stuff} +% \pgfplotstreamend +% +% By themselves, the \pgfplotstreamxxxx commands do not do anything by +% default. Rather, the ``use'' such a stream, you must first install a +% stream handler. For example, the ``lineto'' handler will simply +% translate every \pgfplotstreampoint into a \pgfpathlineto. +% +% Example: +% +% \pgfpathmoveto{\pgfpointorigin} +% +% \pgfplothandlerlineto +% \pgfplotstreamstart +% \pgfplotstreampoint{\pgfpointxy{0}{0}} +% \pgfplotstreampoint{\pgfpointxy{1}{1}} +% \pgfplotstreampoint{\pgfpointxy{2}{4}} +% \relax +% \pgfplotstreampoint{\pgfpointxy{3}{9}} +% \pgfplotstreamend + + +% The stream commands actually call their ``internal'' versions, which +% are set by the handlers: +\def\pgfplotstreamstart{\pgf@plotstreamstart} +\def\pgfplotstreampoint#1{\gdef\pgfplotlastpoint{#1}\pgf@plotstreampoint{#1}} +\def\pgfplotstreamspecial{\pgf@plotstreamspecial} +\def\pgfplotstreamend{\pgf@plotstreamend} + + + + +% Sets the action taken for the first point of a plot to a lineto. +% +% Description: +% +% For certain handlers it makes sense either the start a plot by +% moving to the first point of the plot or to do a lineto to that +% first point. Using this command this action can be set to a lineto. +% +% Example: +% +% \pgfsetlinetofirstplotpoint + +\def\pgfsetlinetofirstplotpoint{\let\pgf@plot@first@action=\pgfpathlineto} + + +% Sets the action taken for the first point of a plot to a moveto. +% +% Example: +% +% \pgfsetmovetofirstplotpoint + +\def\pgfsetmovetofirstplotpoint{\let\pgf@plot@first@action=\pgfpathmoveto} + +\let\pgf@plot@first@action=\pgfpathmoveto + + + +% +% Handlers +% + + +% This handler converts each plot stream command into a lineto +% command, except for the first, which is converted to the action that +% has previously been specified using \pgfsetlinetofirstplotpoint or +% \pgfsetmovetofirstplotpoint. +% +% Example: +% +% \pgfplothandlerlineto +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerlineto{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@line@handler% + \global\let\pgf@plotstreamspecial=\@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} + +\def\pgf@plot@line@handler#1{% + \pgf@plot@first@action{#1}% + \global\let\pgf@plotstreampoint=\pgfpathlineto% +} + + + +% More handlers are defined in pgflibraryplothandlers + + + + + +% This handler discards the plot. +% +% Example: +% +% \pgfplothandlerdiscard +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerdiscard{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\@gobble% + \global\let\pgf@plotstreamspecial=\@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} + + + + +% This handler records each plot stream command to a macro. This is +% useful if plot commands are difficult to generate and need to be +% ``recylced'' later on. +% +% Example: +% +% \pgfplothandlerrecord{\myplot} +% \pgfplotxyfile{mytable} % stored in \myplot now +% \pgfplothandlerline +% \myplot +% \pgftransformxshift{1cm} +% \myplot + +\def\pgfplothandlerrecord#1{% + \def\pgf@plot@recordto{#1}% + \gdef#1{\pgfplotstreamstart}% + \def\pgf@plotstreamstart{% + \gdef\pgf@plotstreampoint####1{\expandafter\gdef\expandafter#1\expandafter{#1\pgfplotstreampoint{####1}}}% + \gdef\pgf@plotstreamspecial####1{\expandafter\gdef\expandafter#1\expandafter{#1\pgfplotstreamspecial{####1}}}% + \gdef\pgf@plotstreamend{\expandafter\gdef\expandafter#1\expandafter{#1\pgfplotstreamend}}% + }% +} + + + +% Read a plot stream from a file and plot it. +% +% #1 = file from which to read things +% +% File format: +% +% Each line of the file should begin with two numbers separated by a +% space. Such a line with number #1 and #2 is converted to a +% \pgfplotstreampoint{\pgfpointxy{#1}{#2}}. Extra characters following +% on the line are ignored. +% +% Lines starting with ``%'' and ``#'' are ignored. +% +% Example: +% +% \pgfplotxyfile{tableformgnuplot.dat} + +\def\pgfplotxyfile#1{% + \begingroup% + \pgfplotstreamstart% + \openin1=#1 + \ifeof1 + \PackageWarning{pgf}{Plot data file `#1' not found.} + \else + \catcode`\#=14 + \pgf@readxyfile% + \fi + \pgfplotstreamend% + \endgroup% +} + +\def\pgf@partext{\par} +\def\pgf@readxyfile{% + \read1 to \pgf@temp% + \let\par=\@@par% + \edef\pgf@temp{\pgf@temp}% + \ifx\pgf@temp\@empty% + \else\ifx\pgf@temp\pgf@partext% + \else% + \expandafter\pgf@parsexyline\pgf@temp\pgf@stop% + \fi\fi% + \ifeof1\else\expandafter\pgf@readxyfile\fi% +} + +\def\pgf@parsexyline#1 #2 #3\pgf@stop{% + \pgfplotstreampoint{\pgfpointxy{#1}{#2}}% +} + + + + + +% Read a plot stream from a file and plot it. +% +% #1 = file from which to read things +% +% File format: +% +% Like xy, except that each line contains three numbers, which are +% converted to xyz coordiantes. +% +% Example: +% +% \pgfplotxyfile{tableformgnuplot.dat} + +\def\pgfplotxyzfile#1{% + \begingroup% + \pgfplotstreamstart% + \openin1=#1 + \ifeof1 + \PackageWarning{pgf}{Plot data file `#1' not found.} + \else + \catcode`\#=14 + \pgf@readxyzfile% + \fi + \pgfplotstreamend% + \endgroup% +} + +\def\pgf@readxyzfile{% + \read1 to \pgf@temp% + \ifx\pgf@temp\@empty% + \else\ifx\pgf@temp\pgf@partext% + \else% + \expandafter\pgf@parsexyzline\pgf@temp\pgf@stop% + \fi\fi% + \ifeof1\else\expandafter\pgf@readxyzfile\fi% +} + +\def\pgf@parsexyzline#1 #2 #3 #4\pgf@stop{% + \pgfplotstreampoint{\pgfpointxyz{#1}{#2}{#3}}% +} + + + + +% Render a function using gnuplot. +% +% #1 = filename prefix for .gnuplot and .table files (optional, +% default is \jobname) +% #2 = gnuplot function text +% +% Description: +% +% This command will write a file called #1.gnuplot that sets up +% some gnuplot commands to write output to a file called +% #1.table. Then it calls gnuplot (using the \write18 mechanism) +% to execute the file. Then it reads #2.table using \pgfplotxyfile. +% +% Example: +% +% \pgfplothandlerlineto +% \pgfplotgnuplot[\jobname]{plot [x=0:5] x*sin(x)} + +{ + \catcode`\%=12 + \catcode`\"=12 + \xdef\pgf@gnuplot@head#1{set terminal table; set output "#1.table"; set format "%.5f"} +} + +\newwrite\pgf@plotwrite +\newif\ifpgf@resample@plot + +\def\pgfplotgnuplot{\@ifnextchar[{\pgf@plotgnuplot}{\pgf@plotgnuplot[\jobname]}}%} +\def\pgf@plotgnuplot[#1]#2{% + \pgf@resample@plottrue% + % Check, whether it is up-to-date + \openin\@inputcheck=#1.gnuplot + \ifeof\@inputcheck% + \else% + \read\@inputcheck to\pgf@temp% ignored + \read\@inputcheck to\pgf@plot@line% + \edef\pgf@plot@code{#2\space}% + \ifx\pgf@plot@code\pgf@plot@line% + \openin\@inputcheck=#1.table + \ifeof\@inputcheck% + \else% + \pgf@resample@plotfalse% + \fi% + \fi% + \fi + \ifpgf@resample@plot% + \immediate\openout\pgf@plotwrite=#1.gnuplot + \immediate\write\pgf@plotwrite{\pgf@gnuplot@head{#1}}% + \immediate\write\pgf@plotwrite{#2}% + \immediate\closeout\pgf@plotwrite% + \immediate\write18{gnuplot #1.gnuplot} + \fi% + \pgfplotxyfile{#1.table} +} + + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseshapes.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseshapes.code.tex new file mode 100644 index 00000000000..494f328994d --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbaseshapes.code.tex @@ -0,0 +1,824 @@ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfbaseshapes.code.tex,v 1.9 2005/10/13 10:12:31 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + + +\newbox\pgfnodeparttextbox + + +% Creates a node +% +% #1 = shape type +% #2 = anchor +% #3 = name for later reference +% #4 = path usage command +% +% Description: +% +% This command draws a shape that has previously been defined using +% \pgfdeclareshape. The shape is shifted such that the anchor is at +% the origin. In order to transform the whole shape, you should setup +% pgf's transformation matrix prior to calling this command. +% +% When this command is called, the shape-specific TeX boxes of the +% node must be have been setup correctly. +% +% Example: +% +% \pgftransformshift{\pgfpoint{1cm}{1cm}} +% \pgfmultipartnode{rectangle}{center}{Hello}{hellonode}{\pgfusepath{stroke}} + +\def\pgfmultipartnode#1#2#3#4{% + \@ifundefined{pgf@sh@s@#1}% + {\PackageError{pgf}{Unknown shape ``#1''}{}}% + {% + {% + \let\pgf@sh@savedpoints=\@empty% + \csname pgf@sh@s@#1\endcsname% + \pgf@sh@savedpoints% + \pgftransformshift{% + \pgf@sh@reanchor{#1}{#2}% + \pgf@x=-\pgf@x% + \pgf@y=-\pgf@y% + }% + % Save the saved points and the transformation matrix + \edef\pgf@test{#3}% + \ifx\pgf@test\@empty% + \else% + \expandafter\xdef\csname pgf@sh@ns@#3\endcsname{#1}% + \edef\pgf@sh@@temp{\noexpand\gdef\expandafter\noexpand\csname pgf@sh@np@#3\endcsname}% + \expandafter\pgf@sh@@temp\expandafter{\pgf@sh@savedpoints}% + \pgfgettransform\pgf@temp + \expandafter\xdef\csname pgf@sh@nt@#3\endcsname{\pgf@temp}% + \fi% + \@ifundefined{pgf@sh@bbg@#1}{} + {{\pgfscope\csname pgf@sh@bbg@#1\endcsname\endpgfscope}}% + \@ifundefined{pgf@sh@bg@#1}{}% + {\csname pgf@sh@bg@#1\endcsname#4}% + \@ifundefined{pgf@sh@fbg@#1}{} + {{\pgfscope\csname pgf@sh@fbg@#1\endcsname\endpgfscope}}% + {% + \expandafter\@for\expandafter\pgf@shape@com\expandafter:\expandafter=\csname pgf@sh@boxes@#1\endcsname\do{% + {% + \pgftransformshift{\pgf@sh@reanchor{#1}{\pgf@shape@com}}% + \expandafter\pgfqboxsynced\expandafter{\csname pgfnodepart\pgf@shape@com box\endcsname}% + }% + }% + }% + \@ifundefined{pgf@sh@bfg@#1}{}% + {{\pgfscope\csname pgf@sh@bfg@#1\endcsname\endpgfscope}}% + \@ifundefined{pgf@sh@fg@#1}{}% + {\csname pgf@sh@fg@#1\endcsname#4}% + \@ifundefined{pgf@sh@ffg@#1}{}% + {{\pgfscope\csname pgf@sh@ffg@#1\endcsname\endpgfscope}}% + }% + }% +} + + +% Creates a node +% +% #1 = shape type +% #2 = anchor +% #3 = normal TeX text +% #4 = name for later reference +% #5 = path usage command +% +% Description: +% +% This command draws a shape that has previously been defined using +% \pgfdeclareshape. The shape is shifted such that the anchor is at +% the origin. In order to transform the whole shape, you should setup +% pgf's transformation matrix prior to calling this command. +% +% Example: +% +% \pgftransformshift{\pgfpoint{1cm}{1cm}} +% \pgfnode{rectangle}{center}{Hello}{hellonode}{\pgfusepath{stroke}} + +\def\pgfnode#1#2#3#4#5{% + {% + \setbox\pgfnodeparttextbox=\hbox% + {% + \pgfinterruptpicture% + {#3}% + \endpgfinterruptpicture% + }% + \pgfmultipartnode{#1}{#2}{#4}{#5}% + } +} + +\def\pgf@sh@resavedanchor#1#2{% + \pgf@process{#2}% + \edef\pgf@sh@marshal{% + \noexpand\g@addto@macro\noexpand\pgf@sh@savedpoints{% + \noexpand\def\noexpand#1{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% + }}% + \pgf@sh@marshal% +} + + +\def\pgf@sh@resaveddimen#1#2{% + {#2\global\pgf@x=\pgf@x}% + \edef\pgf@sh@marshal{% + \noexpand\g@addto@macro\noexpand\pgf@sh@savedpoints{% + \noexpand\def\noexpand#1{\the\pgf@x}% + }}% + \pgf@sh@marshal% +} + +% Invoke an anchor +\def\pgf@sh@reanchor#1#2{% + \@ifundefined{pgf@anchor@#1@#2}% + {% + \setcounter{pgf@counta}{#2}% + \csname pgf@anchor@#1@border\endcsname{\pgfpointpolar{\c@pgf@counta}{1pt}}% + }% + {\csname pgf@anchor@#1@#2\endcsname}% +} + + + +% Retrieves an anchor of a shape +% +% #1 = name +% #2 = anchor or a number (corresponding to a degree) +% +% Description: +% +% This command yields a point at the anchor of the given named shape. +% +% Example: +% +% \pgfshape{rectangle}{center}{Hello}{hellonode}{\pgfusepath[stroke]} +% \pgfpathmoveto{\pgfpointanchor{hellonode}{center}} + +\def\pgfpointanchor#1#2{% + % Ok, check whether #1 is known! + \@ifundefined{pgf@sh@ns@#1} + {\PackageError{pgf}{No shape named #1 is known}{}% + \pgfpointorigin}% + {% + \pgf@process{% + % install special coordinates + \csname pgf@sh@np@#1\endcsname + \pgf@sh@reanchor{\csname pgf@sh@ns@#1\endcsname}{#2}% + {% + \pgfsettransform{\csname pgf@sh@nt@#1\endcsname}% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \global\pgf@x=\pgf@x% + \global\pgf@y=\pgf@y% + }% + % Undo current transformation + \pgftransforminvert% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + }% + }% +} + + + +% Retrieves a border point of a shape +% +% #1 = name +% #2 = another point +% +% Description: +% +% This command yields a point on the border of the shape that is on a +% straight line from the center to the point #2. +% +% Example: +% +% \pgfshape{rectangle}{center}{Hello}{hellonode}{\pgfusepath[stroke]} +% \pgfpathmoveto{\pgfpointshapeborder{hellonode}{\pgfpoint{2cm}{1cm}} +% \pgfpathlineto{\pgfpoint{2cm}{1cm}} +% \pgfusepath{stroke} + +\def\pgfpointshapeborder#1#2{% + % Ok, check whether #1 is known! + \@ifundefined{pgf@sh@ns@#1} + {\PackageError{pgf}{No shape named #1 is known}{}% + \pgfpointorigin}% + {% + \pgf@process{% + % install special coordinates + \csname pgf@sh@np@#1\endcsname% + {% + \pgf@process{\pgfpointtransformed{#2}}% + \pgfsettransform{\csname pgf@sh@nt@#1\endcsname}% + \pgftransforminvert% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\csname pgf@anchor@\csname pgf@sh@ns@#1\endcsname @center\endcsname}% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + \csname pgf@anchor@\csname pgf@sh@ns@#1\endcsname @border\endcsname{\pgfpoint{\pgf@xa}{\pgf@ya}}% + \pgfsettransform{\csname pgf@sh@nt@#1\endcsname}% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \global\pgf@x=\pgf@x% + \global\pgf@y=\pgf@y% + }% + % Undo current transformation + \pgftransforminvert% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + }% + }% +} + + + +% Declares a shape type +% +% #1 = shape type +% #2 = shape specification +% +% Description: +% +% This command declares a new shape type. The shape specification +% should contain the following commands: +% +% - \savedanchor +% This command takes two arguments: a name and some code. The point +% specified by the code (the \pgf@x and \pgf@y values resulting from +% executing the code, to be precise), will be stored under the given +% name. Whenever, later on, an anchor is invoked these stored points +% will be available. The \saveddimen works like \savedanchor, only a +% single dimension is stored (taken from \pgf@x). +% When a savedanchor is calculated, the height/width/depth of the +% boxes mentioned in \nodeparts can be used. +% +% - \anchor +% Specifies an anchor. This command takes two arguments: an anchor +% name and some code for computing the anchor. When the anchor +% computation starts, all shape points and shape dimension will be +% setup. +% +% - \anchorborder +% This command should compute a point on the border of the +% shape. When the code is called, \pgf@x and \pgf@y will have been +% preinitialised with a direction. +% +% - \behindbackgroundpath +% Some things to be draw behind everything. +% +% - \backgroundpath +% A path that is drawn behind the main box. How this path is used +% depends on how \pgfshape is called. +% +% - \beforebackgroundpath +% Some things to be draw before the background path, but behind the +% main box. +% +% - \behindforegroundpath +% Some things to be draw on top of the main box. +% +% - \foregroundpath +% A path that is drawn on top of all of the above. How this path is +% used depends on how \pgfshape is called. +% +% - \beforeforegroundpath +% Some things to be draw before everything. +% +% - \nodeparts +% List of node parts that make up the shape. For each entry XYZ in +% the list there must be a box named \pgfnodepartXYZbox (possibly +% ``redirected'' to some different box using \let). Each such box +% will be placed at the anchor XYZ. +% By default, \nodeparts is just {text}. Thus, there will be one +% node part box named \pgfnodeparttextbox and this node will be +% placed at the anchor text. +% +% +% Example: +% +% See the definition of rectangle, below. + +\long\def\pgfdeclareshape#1#2{% + { + \def\shape@name{#1} + \let\savedanchor=\pgf@sh@savedanchor + \let\saveddimen=\pgf@sh@saveddimen + \let\anchor=\pgf@sh@anchor + \let\anchorborder=\pgf@sh@anchorborder + \let\behindbackgroundpath=\pgf@sh@behindbgpath + \let\backgroundpath=\pgf@sh@bgpath + \let\beforebackgroundpath=\pgf@sh@beforebgpath + \let\behindforegroundpath=\pgf@sh@behindfgpath + \let\foregroundpath=\pgf@sh@fgpath + \let\beforeforegroundpath=\pgf@sh@beforefgpath + \let\nodeparts=\pgf@sh@boxes + \let\inheritsavedanchors=\pgf@sh@inheritsavedanchors + \let\inheritanchor=\pgf@sh@inheritanchor + \let\inheritanchorborder=\pgf@sh@inheritanchorborder + \let\inheritbehindbackgroundpath=\pgf@sh@inheritbehindbgpath + \let\inheritbackgroundpath=\pgf@sh@inheritbgpath + \let\inheritbeforebackgroundpath=\pgf@sh@inheritbeforebgpath + \let\inheritbehindforegroundpath=\pgf@sh@inheritbehindfgpath + \let\inheritforegroundpath=\pgf@sh@inheritfgpath + \let\inheritbeforeforegroundpath=\pgf@sh@inheritbeforefgpath + \let\inheritnodeparts=\pgf@sh@inheritboxes + \anchorborder{\csname pgf@anchor@#1@center\endcsname}% + \anchor{text}{\pgfpointorigin}% + \nodeparts{text}% + \expandafter\global\expandafter\let\csname pgf@sh@s@\shape@name\endcsname=\@empty% + #2 + } +} + +\def\pgf@sh@savedanchor#1#2{% + \expandafter\g@addto@macro\csname pgf@sh@s@\shape@name\endcsname{\pgf@sh@resavedanchor{#1}{#2}}} +\def\pgf@sh@saveddimen#1#2{% + \expandafter\g@addto@macro\csname pgf@sh@s@\shape@name\endcsname{\pgf@sh@resaveddimen{#1}{#2}}} +\def\pgf@sh@anchor#1#2{\expandafter\gdef\csname pgf@anchor@\shape@name @#1\endcsname{#2}} +\def\pgf@sh@anchorborder#1{\expandafter\gdef\csname pgf@anchor@\shape@name @border\endcsname##1{\pgf@process{##1}#1}} +\long\def\pgf@sh@behindbgpath#1{\expandafter\gdef\csname pgf@sh@bbg@\shape@name\endcsname{#1}} +\long\def\pgf@sh@bgpath#1{\expandafter\gdef\csname pgf@sh@bg@\shape@name\endcsname{#1}} +\long\def\pgf@sh@beforebgpath#1{\expandafter\gdef\csname pgf@sh@fbg@\shape@name\endcsname{#1}} +\long\def\pgf@sh@behindfgpath#1{\expandafter\gdef\csname pgf@sh@bfg@\shape@name\endcsname{#1}} +\long\def\pgf@sh@fgpath#1{\expandafter\gdef\csname pgf@sh@fg@\shape@name\endcsname{#1}} +\long\def\pgf@sh@beforefgpath#1{\expandafter\gdef\csname pgf@sg@ffg@\shape@name\endcsname{#1}} +\def\pgf@sh@boxes#1{\expandafter\gdef\csname pgf@sh@boxes@\shape@name\endcsname{#1}} + +\def\pgf@sh@inheritsavedanchors[from=#1]{% + \expandafter\g@addto@macro\csname pgf@sh@s@\shape@name\endcsname{\csname pgf@sh@s@#1\endcsname}} +\def\pgf@sh@inheritanchor[from=#1]#2{% + \edef\pgf@marshal{\global\let\expandafter\noexpand\csname + pgf@anchor@\shape@name @#2\endcsname=\expandafter\noexpand\csname + pgf@anchor@#1@#2\endcsname}% + \pgf@marshal% +} +\def\pgf@sh@inheritanchorborder[from=#1]{% + \edef\pgf@marshal{\global\let\expandafter\noexpand\csname + pgf@anchor@\shape@name @border\endcsname=\expandafter\noexpand\csname + pgf@anchor@#1@border\endcsname}% + \pgf@marshal% +} +\def\pgf@sh@inheritor#1#2{% + \edef\pgf@marshal{\global\let\expandafter\noexpand\csname + pgf@sh@#1@\shape@name\endcsname=\expandafter\noexpand\csname + pgf@sh@#1@#2\endcsname}% + \pgf@marshal% +} +\def\pgf@sh@inheritbehindbgpath[from=#1]{\pgf@sh@inheritor{bbg}{#1}} +\def\pgf@sh@inheritbgpath[from=#1]{\pgf@sh@inheritor{bg}{#1}} +\def\pgf@sh@inheritbeforebgpath[from=#1]{\pgf@sh@inheritor{fbg}{#1}} +\def\pgf@sh@inheritbehindfgpath[from=#1]{\pgf@sh@inheritor{bfg}{#1}} +\def\pgf@sh@inheritfgpath[from=#1]{\pgf@sh@inheritor{fg}{#1}} +\def\pgf@sh@inheritbeforefgpath[from=#1]{\pgf@sh@inheritor{ffg}{#1}} +\def\pgf@sh@inheritboxes[from=#1]{\pgf@sh@inheritor{boxes}{#1}} + + + +% +% Coordinate. This shape is special: It is only used to reference a +% point for later usage. Nothing is drawn, all anchors are identical +% to the center. +% + +\pgfdeclareshape{coordinate} +{ + \savedanchor\centerpoint{% + % x + \pgf@x=.5\wd\pgfnodeparttextbox% + % y + \pgf@y=.5\ht\pgfnodeparttextbox% + \advance\pgf@y by -.5\dp\pgfnodeparttextbox% + } + + \anchor{center}{\centerpoint} + \anchor{north}{\centerpoint} + \anchor{north west}{\centerpoint} + \anchor{north east}{\centerpoint} + \anchor{center}{\centerpoint} + \anchor{west}{\centerpoint} + \anchor{east}{\centerpoint} + \anchor{mid}{\centerpoint} + \anchor{mid west}{\centerpoint} + \anchor{mid east}{\centerpoint} + \anchor{base}{\centerpoint} + \anchor{base west}{\centerpoint} + \anchor{base east}{\centerpoint} + \anchor{south}{\centerpoint} + \anchor{south west}{\centerpoint} + \anchor{south east}{\centerpoint} + \anchorborder{\centerpoint} + + \nodeparts{}% no text +} + + +% Set the recommended inner x separation +% +% #1 = size +% +% Example: +% +% \pgfsetshapeinnerxsep{2pt} + +\def\pgfsetshapeinnerxsep#1{\def\pgfshapeinnerxsep{#1}} +\pgfsetshapeinnerxsep{.3333em} + + +% Set the recommended inner y separation +% +% #1 = size +% +% Example: +% +% \pgfsetshapeinnerxsep{2pt} + +\def\pgfsetshapeinnerysep#1{\def\pgfshapeinnerysep{#1}} +\pgfsetshapeinnerysep{.3333em} + + +% Set the recommended outer x separation +% +% #1 = size +% +% Example: +% +% \pgfsetshapeouterxsep{2pt} + +\def\pgfsetshapeouterxsep#1{\def\pgfshapeouterxsep{#1}} +\pgfsetshapeouterxsep{.5\pgflinewidth} + + +% Set the recommended outer y separation +% +% #1 = size +% +% Example: +% +% \pgfsetshapeouterxsep{2pt} + +\def\pgfsetshapeouterysep#1{\def\pgfshapeouterysep{#1}} +\pgfsetshapeouterysep{.5\pgflinewidth} + + +% Set the recommended minimum width +% +% #1 = size +% +% Example: +% +% \pgfsetshapeminwidth{1cm} + +\def\pgfsetshapeminwidth#1{\def\pgfshapeminwidth{#1}} +\pgfsetshapeminwidth{1pt} + + +% Set the recommended minimum height +% +% #1 = size +% +% Example: +% +% \pgfsetshapeminheight{1cm} + +\def\pgfsetshapeminheight#1{\def\pgfshapeminheight{#1}} +\pgfsetshapeminheight{1pt} + + +% +% Rectangle +% + +\pgfdeclareshape{rectangle} +{ + \savedanchor\northeast{% + % Calculate x + % + % First, is width < minimum width? + \pgf@x=\the\wd\pgfnodeparttextbox% + \setlength\pgf@xc{\pgfshapeinnerxsep}% + \advance\pgf@x by 2\pgf@xc% + \setlength\pgf@xb{\pgfshapeminwidth}% + \ifdim\pgf@x<\pgf@xb% + % yes, too small. Enlarge... + \pgf@x=\pgf@xb% + \fi% + % Now, calculate right border: .5\wd\pgfnodeparttextbox + .5 \pgf@x + outer sep + \pgf@x=.5\pgf@x% + \advance\pgf@x by.5\wd\pgfnodeparttextbox% + \setlength\pgf@xa{\pgfshapeouterxsep}% + \advance\pgf@x by\pgf@xa% + % Calculate y + % + % First, is height+depth < minimum height? + \pgf@y=\ht\pgfnodeparttextbox% + \advance\pgf@y by\dp\pgfnodeparttextbox% + \setlength\pgf@yc{\pgfshapeinnerysep}% + \advance\pgf@y by 2\pgf@yc% + \setlength\pgf@yb{\pgfshapeminheight}% + \ifdim\pgf@y<\pgf@yb% + % yes, too small. Enlarge... + \pgf@y=\pgf@yb% + \fi% + % Now, calculate upper border: .5\ht-.5\dp + .5 \pgf@y + outer sep + \pgf@y=.5\pgf@y% + \advance\pgf@y by-.5\dp\pgfnodeparttextbox% + \advance\pgf@y by.5\ht\pgfnodeparttextbox% + \setlength\pgf@ya{\pgfshapeouterysep}% + \advance\pgf@y by\pgf@ya% + } + + \savedanchor\southwest{% + % Calculate x + % + % First, is width < minimum width? + \pgf@x=\wd\pgfnodeparttextbox% + \setlength\pgf@xc{\pgfshapeinnerxsep}% + \advance\pgf@x by 2\pgf@xc% + \setlength\pgf@xb{\pgfshapeminwidth}% + \ifdim\pgf@x<\pgf@xb% + % yes, too small. Enlarge... + \pgf@x=\pgf@xb% + \fi% + % Now, calculate left border: .5\wd\pgfnodeparttextbox - .5 \pgf@x - outer sep + \pgf@x=-.5\pgf@x% + \advance\pgf@x by.5\wd\pgfnodeparttextbox% + \setlength\pgf@xa{\pgfshapeouterxsep}% + \advance\pgf@x by-\pgf@xa% + % Calculate y + % + % First, is height+depth < minimum height? + \pgf@y=\ht\pgfnodeparttextbox% + \advance\pgf@y by\dp\pgfnodeparttextbox% + \setlength\pgf@yc{\pgfshapeinnerysep}% + \advance\pgf@y by 2\pgf@yc% + \setlength\pgf@yb{\pgfshapeminheight}% + \ifdim\pgf@y<\pgf@yb% + % yes, too small. Enlarge... + \pgf@y=\pgf@yb% + \fi% + % Now, calculate upper border: .5\ht-.5\dp - .5 \pgf@y - outer sep + \pgf@y=-.5\pgf@y% + \advance\pgf@y by-.5\dp\pgfnodeparttextbox% + \advance\pgf@y by.5\ht\pgfnodeparttextbox% + \setlength\pgf@ya{\pgfshapeouterysep}% + \advance\pgf@y by-\pgf@ya% + } + + % + % Anchors + % + \anchor{center}{ + \pgf@process{\northeast}% + \pgf@xa=.5\pgf@x% + \pgf@ya=.5\pgf@y% + \pgf@process{\southwest}% + \pgf@x=.5\pgf@x% + \pgf@y=.5\pgf@y% + \advance\pgf@x by \pgf@xa% + \advance\pgf@y by \pgf@ya% + } + \anchor{mid}{\pgf@anchor@rectangle@center\setlength\pgf@y{.5ex}} + \anchor{base}{\pgf@anchor@rectangle@center\pgf@y=0pt} + \anchor{north}{ + \pgf@process{\southwest}% + \pgf@xa=.5\pgf@x% + \pgf@process{\northeast}% + \pgf@x=.5\pgf@x% + \advance\pgf@x by \pgf@xa% + } + \anchor{south}{ + \pgf@process{\northeast}% + \pgf@xa=.5\pgf@x% + \pgf@process{\southwest}% + \pgf@x=.5\pgf@x% + \advance\pgf@x by \pgf@xa% + } + \anchor{west}{ + \pgf@process{\northeast}% + \pgf@ya=.5\pgf@y% + \pgf@process{\southwest}% + \pgf@y=.5\pgf@y% + \advance\pgf@y by \pgf@ya% + } + \anchor{mid west}{\southwest\setlength\pgf@y{.5ex}} + \anchor{base west}{\southwest\pgf@y=0pt} + \anchor{north west}{ + \southwest + \pgf@xa=\pgf@x + \northeast + \pgf@x=\pgf@xa} + \anchor{south west}{\southwest} + \anchor{east}{% + \pgf@process{\southwest}% + \pgf@ya=.5\pgf@y% + \pgf@process{\northeast}% + \pgf@y=.5\pgf@y% + \advance\pgf@y by \pgf@ya% + } + \anchor{mid east}{\northeast\setlength\pgf@y{.5ex}} + \anchor{base east}{\northeast\pgf@y=0pt} + \anchor{north east}{\northeast} + \anchor{south east}{ + \northeast + \pgf@xa=\pgf@x + \southwest + \pgf@x=\pgf@xa + } + \anchorborder{% + \pgf@xb=\pgf@x% xb/yb is target + \pgf@yb=\pgf@y% + \southwest% + \pgf@xa=\pgf@x% xa/ya is se + \pgf@ya=\pgf@y% + \northeast% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@y by-\pgf@ya% + \pgf@xc=.5\pgf@x% x/y is half width/height + \pgf@yc=.5\pgf@y% + \advance\pgf@xa by\pgf@xc% xa/ya becomes center + \advance\pgf@ya by\pgf@yc% + \edef\pgf@marshal{% + \noexpand\pgfpointborderrectangle + {\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}} + {\noexpand\pgfpoint{\the\pgf@xc}{\the\pgf@yc}}% + }% + \pgf@process{\pgf@marshal}% + \advance\pgf@x by\pgf@xa% + \advance\pgf@y by\pgf@ya% + } + + % + % Background path + % + \backgroundpath{ + \pgfpathrectanglecorners + {\pgfpointadd{\southwest}{\pgfpoint{\pgfshapeouterxsep}{\pgfshapeouterysep}}} + {\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfshapeouterxsep}{\pgfshapeouterysep}}}} + } +} + + + +% Special current bounding box rectangle: +\expandafter\def\csname pgf@sh@ns@current bounding box\endcsname{rectangle} +\expandafter\def\csname pgf@sh@np@current bounding box\endcsname{% + \def\southwest{\pgfpoint{\pgf@picminx}{\pgf@picminy}}% + \def\northeast{\pgfpoint{\pgf@picmaxx}{\pgf@picmaxy}}% +} +\expandafter\def\csname pgf@sh@nt@current bounding box\endcsname{{1}{0}{0}{1}{0pt}{0pt}} + + + +% +% Circle +% + +\pgfdeclareshape{circle} +% +% Draws a circle around the text +% +{ + \savedanchor\centerpoint{% + \pgf@x=.5\wd\pgfnodeparttextbox% + \pgf@y=.5\ht\pgfnodeparttextbox% + \advance\pgf@y by-.5\dp\pgfnodeparttextbox% + } + + \saveddimen\radius{% + % + % Caculate ``height radius'' + % + \pgf@ya=.5\ht\pgfnodeparttextbox% + \advance\pgf@ya by.5\dp\pgfnodeparttextbox% + \setlength\pgf@yb{\pgfshapeinnerysep}% + \advance\pgf@ya by\pgf@yb% + % + % Caculate ``width radius'' + % + \pgf@xa=.5\wd\pgfnodeparttextbox% + \setlength\pgf@xb{\pgfshapeinnerxsep}% + \advance\pgf@xa by\pgf@xb% + % + % Calculate length of radius vector: + % + \pgf@process{\pgfpointnormalised{\pgfpoint{\pgf@xa}{\pgf@ya}}}% + \ifdim\pgf@x>\pgf@y% + \c@pgf@counta=\pgf@x% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@xa=16\pgf@xa\relax% + \divide\pgf@xa by\c@pgf@counta% + \pgf@xa=16\pgf@xa\relax% + \fi% + \else% + \c@pgf@counta=\pgf@y% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@ya=16\pgf@ya\relax% + \divide\pgf@ya by\c@pgf@counta% + \pgf@xa=16\pgf@ya\relax% + \fi% + \fi% + \pgf@x=\pgf@xa% + % + % If necessary, adjust radius so that the size requirements are + % met: + % + \setlength{\pgf@xb}{\pgfshapeminwidth}% + \setlength{\pgf@yb}{\pgfshapeminheight}% + \ifdim\pgf@x<.5\pgf@xb% + \pgf@x=.5\pgf@xb% + \fi% + \ifdim\pgf@x<.5\pgf@yb% + \pgf@x=.5\pgf@yb% + \fi% + % + % Now, add larger of outer sepearations. + % + \setlength{\pgf@xb}{\pgfshapeouterxsep}% + \setlength{\pgf@yb}{\pgfshapeouterysep}% + \ifdim\pgf@xb<\pgf@yb% + \advance\pgf@x by\pgf@yb% + \else% + \advance\pgf@x by\pgf@xb% + \fi% + } + + % + % Anchors + % + \anchor{center}{\centerpoint} + \anchor{mid}{\centerpoint\setlength\pgf@y{.5ex}} + \anchor{base}{\centerpoint\pgf@y=0pt} + \anchor{north}{\centerpoint\advance\pgf@y by\radius} + \anchor{south}{\centerpoint\advance\pgf@y by-\radius} + \anchor{west}{\centerpoint\advance\pgf@x by-\radius} + \anchor{east}{\centerpoint\advance\pgf@x by\radius} + \anchor{mid west}{\centerpoint\advance\pgf@x by-\radius\setlength\pgf@y{.5ex}} + \anchor{mid east}{\centerpoint\advance\pgf@x by\radius\setlength\pgf@y{.5ex}} + \anchor{base west}{\centerpoint\advance\pgf@x by-\radius\pgf@y=0pt} + \anchor{base east}{\centerpoint\advance\pgf@x by\radius\pgf@y=0pt} + \anchor{north west}{ + \centerpoint + \pgf@xa=\radius + \advance\pgf@x by-0.707107\pgf@xa + \advance\pgf@y by0.707107\pgf@xa + } + \anchor{south west}{ + \centerpoint + \pgf@xa=\radius + \advance\pgf@x by-0.707107\pgf@xa + \advance\pgf@y by-0.707107\pgf@xa + } + \anchor{north east}{ + \centerpoint + \pgf@xa=\radius + \advance\pgf@x by0.707107\pgf@xa + \advance\pgf@y by0.707107\pgf@xa + } + \anchor{south east}{ + \centerpoint + \pgf@xa=\radius + \advance\pgf@x by0.707107\pgf@xa + \advance\pgf@y by-0.707107\pgf@xa + } + \anchorborder{ + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \edef\pgf@marshal{% + \noexpand\pgfpointborderellipse + {\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}} + {\noexpand\pgfpoint{\radius}{\radius}}% + }% + \pgf@marshal% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \centerpoint% + \advance\pgf@x by\pgf@xa% + \advance\pgf@y by\pgf@ya% + } + + % + % Background path + % + \backgroundpath{ + \@tempdima=\radius% + \setlength{\pgf@xb}{\pgfshapeouterxsep}% + \setlength{\pgf@yb}{\pgfshapeouterysep}% + \ifdim\pgf@xb<\pgf@yb% + \advance\@tempdima by-\pgf@yb% + \else% + \advance\@tempdima by-\pgf@xb% + \fi% + \pgfpathcircle{\centerpoint}{\@tempdima}% + } +} + + + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbasesnakes.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbasesnakes.code.tex new file mode 100644 index 00000000000..7403f2a7b8e --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfbasesnakes.code.tex @@ -0,0 +1,346 @@ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfbasesnakes.code.tex,v 1.5 2005/10/10 08:38:29 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + +\newdimen\pgfsnakeremainingdistance +\newdimen\pgfsnakecompleteddistance + + +% Creates a new pgf snake +% +% #1 = snake name +% #1 = initial state +% #3= states of the snake +% +% +% This command declares a new snake for later use. The second +% parameter specifies the states of the snake, see also the +% description of pgfpathsnake. +% +% Inside the code of #3 the command \state may be used. This command +% will only be defined while #3 is executed. +% +% Example: +% +% \pgfdeclaresnake{zig zag}{one zig zag} +% { +% \state{one zig zag}[width=10pt] +% { +% \pgfpathlineto{\pgfpoint{2.5pt}{2.5pt}} +% \pgfpathlineto{\pgfpoint{7.5pt}{-2.5pt}} +% \pgfpathlineto{\pgfpoint{10pt}{0pt}} +% } +% \state{final} +% { +% \pgfpathlineto{\pgfpoint{\pgfsnakeremainingdistance}{0pt}} +% } +% } + +\long\def\pgfdeclaresnake#1#2#3{% + \def\pgf@snake@name{#1}% + \@namedef{pgf@snake@@#1@initial}{#2}% + \let\pgf@orig@state=\state% + \let\state=\pgf@snake@state + #3 + \let\state=\pgf@orig@state% +} + + +% Sets the additional transformation applied to every segment of a snake +% +% #1 = transformation +% +% Example: +% +% \pgfsetsnakesegmenttransformation{\pgftransformyshift{5pt}} + +\def\pgfsetsnakesegmenttransformation#1{\def\pgf@snakeadditionaltransform{#1}} +\pgfsetsnakesegmenttransformation{} + + +% Declares a new state +% +% #1 = state name +% #2 = options +% #3 = path element +% +% Description: +% +% When a snake is drawn and the current state is #1, the following +% happens. First, the options are executed, which will possible change +% the state. If that does not happen, the path element is added to the +% path and the coordinate system is translated by the path element's +% width (which is specified using the width option). +% +% Example: +% +% \state{initial}[width=10pt] +% { +% \pgfpathlineto{\pgfpoint{2.5pt}{2.5pt}} +% \pgfpathlineto{\pgfpoint{7.5pt}{-2.5pt}} +% \pgfpathlineto{\pgfpoint{10pt}{0pt}} +% } + +\def\pgf@snake@state#1{\@ifnextchar[{\pgf@@snake@start#1}{\pgf@@snake@start#1[]}}%} +\def\pgf@@snake@start#1[#2]#3{% + \@namedef{pgf@snake@@\pgf@snake@name @#1@options}{#2}% + \@namedef{pgf@snake@@\pgf@snake@name @#1@code}{#3}% +} + + + +% Use multiple snakes +% +% #1 = list of snake names/length pairs +% #2 = point to which the snake leads +% +% This operation uses the snakes in parameter #1 to get to the point +% #4. The parameter #1 should contain pairs consisting of a snake name +% and a length for which this snake should be used. When the length is +% computed, the dimensions \pgfsnakeremainingdistance and +% \pgfsnakecompleteddistance will have been set to the length of the +% total distance to #2 that has already been covered/that still needs +% to be covered. +% +% Example: +% +% \pgfpathsnakesto{{lineto}{1cm},{zig zag}{\pgfsnakeremainingdistance}}{\pgfpoint{2cm}{3cm}} + +\def\pgfpathsnakesto#1#2{% + \begingroup% + % compute target vector + \pgfpointtransformed{#2}% + \advance\pgf@x by-\pgf@path@lastx% + \advance\pgf@y by-\pgf@path@lasty% + % Ok, now normalize the vector... + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgfpointnormalised{}}% + % ok, now computer length (arghh...) + % In theory that's easy: divide the larger of the values x or y by + % the normalizes x or y. Well... + % + % First, make xa and ya positive: + \ifdim\pgf@xa<0pt% + \pgf@xa=-\pgf@xa% + \fi% + \ifdim\pgf@ya<0pt% + \pgf@ya=-\pgf@ya% + \fi% + % Now do division: + \ifdim\pgf@xa>\pgf@ya% + \c@pgf@counta=\pgf@x% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@xa=16\pgf@xa\relax% + \divide\pgf@xa by\c@pgf@counta% + \pgf@xa=16\pgf@xa\relax% + \fi% + \else% + \c@pgf@counta=\pgf@y% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@ya=16\pgf@ya\relax% + \divide\pgf@ya by\c@pgf@counta% + \pgf@xa=16\pgf@ya\relax% + \fi% + \fi% + % Make positive: + \ifdim\pgf@xa<0pt% + \pgf@xa=-\pgf@xa% + \fi% + % Ok, now we draw things... + \edef\pgf@list{#1}% + \pgfsnakeremainingdistance=\pgf@xa% + \pgfsnakecompleteddistance=0pt% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \@for\pgf@temp:=\pgf@list\do{% + \ifx\pgf@temp\@empty% + \else% + \expandafter\pgf@snake@invoke\pgf@temp% + \fi% + }% + \endgroup% +} + +\def\pgf@snake@invoke#1#2{% + \setlength\pgf@xa{#2}% + {% + \edef\pgf@marshal{\noexpand\pgfpathsnakealongvector{#1}{\the\pgf@xa}{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}}% + \pgf@marshal% + }% + \advance\pgfsnakecompleteddistance by\pgf@xa% + \advance\pgfsnakeremainingdistance by-\pgf@xa% +} + +% Use a snake +% +% #1 = snake name +% #2 = point to which the snake leads +% +% This operation mainly computes \pgfpathsnakealongvector for a vector +% appropriately choosen. See \pgfpathsnakealongvector for details. +% +% Example: +% +% \pgfpathsnaketo{zig zag}{\pgfpoint{2cm}{3cm}} + +\def\pgfpathsnaketo#1#2{\pgfpathsnakesto{{#1}{\pgfsnakeremainingdistance}}{#2}} + + + +% Use a snake +% +% #1 = snake name +% #2 = length of the snake +% #3 = vector along which the snake grows, should have unit length. +% +% This command draws a snake (more precisely, it adds a snake to the +% path). This works as follows: +% +% First, the coordinate system is transformed such that the vector #3 +% points to the right. +% +% Next, the state `initial' of the snake is entered. Unless the +% options of this state cause it to switch to another state, the path +% element is added to the path. Then, the coordinate system is +% translated by the width of the path element as specified in the +% width option of the path element. The dimensions +% \pgfsnakeremainingdistance and \pgfsnakecompleteddistance are +% updated. +% +% The process ends when the state `final' is entered. The code of the +% final state is executed and the process stops. +% +% Example: +% +% \pgfpathsnakealongvector{zig zag}{100pt}{\pgfpolar{30}{1pt}} + +\def\pgfpathsnakealongvector#1#2#3{% + \@ifundefined{pgf@snake@@#1@initial}{\PackageError{pgf}{Undefined snake ``#1''}{}} + { + \begingroup% keep things local + \pgftransformreset% + \pgf@pt@x=\pgf@path@lastx% evil trickery to transform to the last point + \pgf@pt@y=\pgf@path@lasty% + \pgf@process{#3}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@xb=-\pgf@y% + \pgf@yb=\pgf@x% + \pgftransformcm + {\pgf@sys@tonumber{\pgf@xa}}{\pgf@sys@tonumber{\pgf@ya}} + {\pgf@sys@tonumber{\pgf@xb}}{\pgf@sys@tonumber{\pgf@yb}} + {\pgfpointorigin}% + % Now, setup the automaton + \expandafter\let\expandafter\pgf@snake@current@state\expandafter=\csname pgf@snake@@#1@initial\endcsname% + \def\pgf@snake@name{#1}% + \pgfsnakecompleteddistance=0pt% + \setlength\pgfsnakeremainingdistance{#2}% + \pgf@snake@run% + % Last step: + {% + \pgftransformxshift{\pgfsnakecompleteddistance}% + \pgf@snakeadditionaltransform% + \csname pgf@snake@@#1@final@code\endcsname% + }% + \endgroup% + }% +} + +\def\pgf@final@text{final} + +\def\pgf@snake@run{% + \let\pgf@snake@next=\pgf@snake@do@state% + \ifx\pgf@snake@current@state\pgf@final@text% + \let\pgf@snake@next=\relax% + \fi% + \pgf@snake@next% +} + +\def\pgf@snake@do@state{% + \let\pgf@snake@next=\relax% + \let\pgf@snake@next@state=\pgf@snake@current@state% + % execute options + \def\pgf@marshal{\setkeys{pgfsnake}}% + \expandafter\expandafter\expandafter\pgf@marshal + \expandafter\expandafter\expandafter{\csname pgf@snake@@\pgf@snake@name @\pgf@snake@current@state @options\endcsname}% + \ifx\pgf@snake@next\relax% + \pgf@snake@next=\pgf@snake@do@code% + \fi% + \pgf@snake@next% +} + +\def\pgf@snake@do@code{% + % Ok, execute code: + {% + \pgftransformxshift{\pgfsnakecompleteddistance}% + \pgf@snakeadditionaltransform% + \csname pgf@snake@@\pgf@snake@name @\pgf@snake@current@state @code\endcsname% + }% + % next, do transformation and update + \setlength{\pgf@xa}{\pgf@snake@width}% + \advance\pgfsnakeremainingdistance by-\pgf@xa% + \advance\pgfsnakecompleteddistance by\pgf@xa% + % Next iteration: + \let\pgf@snake@current@state=\pgf@snake@next@state% + \pgf@snake@run +} + +\define@key{pgfsnake}{width}{% + \def\pgf@snake@width{#1}% + \pgf@snake@switch@if#1 to final\pgf@stop% +} +\define@key{pgfsnake}{switch if less than}{% + \pgf@snake@switch@if#1\pgf@stop% +} +\define@key{pgfsnake}{next state}{% + \def\pgf@snake@next@state{#1}% +} + +\def\pgf@snake@switch@if#1to #2\pgf@stop{% + \ifx\pgf@snake@next\relax% + \setlength\pgf@x{#1}% + \ifdim\pgfsnakeremainingdistance<\pgf@x% + \def\pgf@snake@current@state{#2}% + \let\pgf@snake@next=\pgf@snake@run% + \fi% + \fi% +} + + + +% lineto snake +% +% This snake simply adds a straight line. This snake is mainly useful +% in conjunction with other snakes. + +\pgfdeclaresnake{lineto}{final} +{ + \state{final} + { \pgfpathlineto{\pgfpoint{\pgfsnakeremainingdistance}{0pt}} } +} + + + +% moveto snake +% +% This snake simply jumps to the end. This snake, too, is mainly +% useful in conjunction with other snakes. + +\pgfdeclaresnake{moveto}{final} +{ + \state{final} + { \pgfpathmoveto{\pgfpoint{\pgfsnakeremainingdistance}{0pt}} } +} + + + +\endinput 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..3496b92cf6d --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex @@ -0,0 +1,23 @@ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcore.code.tex,v 1.2 2005/07/06 15:58:57 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + +\newif\ifpgf@draftmode + +\input pgfcoremath.code.tex +\input pgfcorepoints.code.tex +\input pgfcorepathconstruction.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 + +\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..0283f40c4d2 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.code.tex @@ -0,0 +1,510 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorearrows.code.tex,v 1.2 2005/07/10 20:11:23 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + + +% Sets the end arrow +% +% #1 = An arrow name +% +% Example: +% +% \pgfsetarrowsend{stealth} + +\def\pgfsetarrowsend#1{\pgf@arrowset{end}{#1}} +\def\pgf@arrowset#1#2{% + \@ifundefined{pgf@arrow@code@#2} + {\PackageError{pgf}{Arrow #1 type ``#2'' unknown}{}} + {% + \edef\pgf@arrow@temp{#2}% + \ifx\pgf@arrow@temp\@empty% ah. clear! + \expandafter\let\csname pgf@#1arrow\endcsname=\@empty% + \expandafter\let\csname pgf@shorten@#1\endcsname=\@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{% + \@ifundefined{pgf@arrow@code@#2}% + {% + \PackageError{pgf}{Arrow end type ``#2'' unknown}{}}% + {% + \@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{% + \@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\@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\xdef\csname pgf@arrow@prot@#1@\the\pgflinewidth\endcsname{% + \noexpand\pgfsys@invoke{\pgf@@arrow@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{\setlength\pgf@xa{#1}} +\def\pgfarrowsrightextend#1{\setlength\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{\@ifnextchar*{\pgfarrowsdeclarecombine@star}{\pgf@@arrowsdeclarecombine}} + +\def\pgf@@arrowsdeclarecombine{\@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\setlength\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{% + \setlength\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*{\@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\setlength\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{% + \setlength\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{\@ifnextchar[{\pgf@arrowsdeclaredouble}{\pgf@arrowsdeclaredouble[0pt]}} +\def\pgf@arrowsdeclaredouble[#1]#2#3#4#5{\pgfarrowsdeclarecombine[#1]{#2}{#3}{#4}{#5}{#4}{#5}} +\def\pgfarrowsdeclaretriple{\@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} +{ + \@tempdima=0.28pt% + \advance\@tempdima by.3\pgflinewidth% + \pgfarrowsleftextend{-3\@tempdima} + \pgfarrowsrightextend{5\@tempdima} +} +{ + \@tempdima=0.28pt% + \advance\@tempdima by.3\pgflinewidth% + \pgfpathmoveto{\pgfpoint{5\@tempdima}{0pt}} + \pgfpathlineto{\pgfpoint{-3\@tempdima}{4\@tempdima}} + \pgfpathlineto{\pgfpointorigin} + \pgfpathlineto{\pgfpoint{-3\@tempdima}{-4\@tempdima}} + \pgfusepathqfill +} + +\pgfarrowsdeclarereversed{stealth reversed}{stealth reversed}{stealth}{stealth} + + +% An arrow similar to the $\to$ arrow +% +% Example: +% +% \pgfsetarrow{-to} + +\pgfarrowsdeclare{to}{to} +{ + \@tempdima=-0.84pt% + \advance\@tempdima by-1.3\pgflinewidth% + \@tempdimb=0.21pt% + \advance\@tempdimb by.625\pgflinewidth% + \pgfarrowsleftextend{\@tempdima} + \pgfarrowsrightextend{\@tempdimb} +} +{ + \@tempdima=0.28pt% + \advance\@tempdima by.3\pgflinewidth% + \pgfsetlinewidth{0.8\pgflinewidth} + \pgfsetdash{}{0pt} + \pgfsetroundcap + \pgfsetroundjoin + \pgfpathmoveto{\pgfpoint{-3\@tempdima}{4\@tempdima}} + \pgfpathcurveto + {\pgfpoint{-2.75\@tempdima}{2.5\@tempdima}} + {\pgfpoint{0pt}{0.25\@tempdima}} + {\pgfpoint{0.75\@tempdima}{0pt}} + \pgfpathcurveto + {\pgfpoint{0pt}{-0.25\@tempdima}} + {\pgfpoint{-2.75\@tempdima}{-2.5\@tempdima}} + {\pgfpoint{-3\@tempdima}{-4\@tempdima}} + \pgfusepathqstroke +} + +\pgfarrowsdeclare{to reversed}{to reversed} +{ + \@tempdima=-0.21pt% + \advance\@tempdima by-0.475\pgflinewidth% + \@tempdimb=0.98pt% + \advance\@tempdimb by1.45\pgflinewidth% + \pgfarrowsleftextend{\@tempdima} + \pgfarrowsrightextend{\@tempdimb} +} +{ + \@tempdima=0.28pt% + \advance\@tempdima by.3\pgflinewidth% + \pgfsetlinewidth{0.8\pgflinewidth} + \pgfsetdash{}{0pt} + \pgfsetroundcap + \pgfsetroundjoin + \pgfpathmoveto{\pgfpoint{3.5\@tempdima}{4\@tempdima}} + \pgfpathcurveto + {\pgfpoint{3.25\@tempdima}{2.5\@tempdima}} + {\pgfpoint{0.5\@tempdima}{0.25\@tempdima}} + {\pgfpoint{-0.25\@tempdima}{0\@tempdima}} + \pgfpathcurveto + {\pgfpoint{0.5\@tempdima}{-0.25\@tempdima}} + {\pgfpoint{3.25\@tempdima}{-2.5\@tempdima}} + {\pgfpoint{3.5\@tempdima}{-4\@tempdima}} + \pgfusepathqstroke +} + + + +% LaTeX's orginal arrow type +% +% Example: +% +% \pgfsetarrows{-latex} + +\pgfarrowsdeclare{latex}{latex} +{ + \@tempdima=0.28pt% + \advance\@tempdima by.3\pgflinewidth% + \pgfarrowsleftextend{-1\@tempdima} + \pgfarrowsrightextend{9\@tempdima} +} +{ + \@tempdima=0.28pt% + \advance\@tempdima by.3\pgflinewidth% + \pgfpathmoveto{\pgfpoint{9\@tempdima}{0pt}} + \pgfpathcurveto + {\pgfpoint{6.3333\@tempdima}{.5\@tempdima}} + {\pgfpoint{2\@tempdima}{2\@tempdima}} + {\pgfpoint{-1\@tempdima}{3.75\@tempdima}} + \pgfpathlineto{\pgfpoint{-1\@tempdima}{-3.75\@tempdima}} + \pgfpathcurveto + {\pgfpoint{2\@tempdima}{-2\@tempdima}} + {\pgfpoint{6.3333\@tempdima}{-.5\@tempdima}} + {\pgfpoint{9\@tempdima}{0pt}} + \pgfusepathqfill +} +\pgfarrowsdeclarereversed{latex reversed}{latex reversed}{latex}{latex} + + + +% A bar shaped arrow +% +% Example: +% +% \pgfsetarrows{-|} + +\pgfarrowsdeclare{|}{|} +{ + \pgfarrowsleftextend{-0.25\pgflinewidth} + \pgfarrowsrightextend{.75\pgflinewidth} +} +{ + \@tempdima=2pt% + \advance\@tempdima by1.5\pgflinewidth% + \pgfsetdash{}{0pt} + \pgfsetrectcap + \pgfpathmoveto{\pgfpoint{0.25\pgflinewidth}{-\@tempdima}} + \pgfpathlineto{\pgfpoint{0.25\pgflinewidth}{\@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..f417efcab54 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicstate.code.tex @@ -0,0 +1,254 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoregraphicstate.code.tex,v 1.3 2005/09/21 00:05:34 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + +% Globals + +\newdimen\pgflinewidth + + +% Set the line width to #1. +% +% #1 = new line width. +% +% Example: +% +% \pgfsetlinewidth{3pt} + +\def\pgfsetlinewidth#1{% + \setlength\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}% + \setlength\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% + \setlength\pgf@x{#1}% + \ifx\pgf@temp\@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{% + \colorlet{pgf@tempcolor}{#1}% + \@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\@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{% + \colorlet{pgf@tempcolor}{#1}% + \@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{% + \colorlet{pgf@tempcolor}{#1}% + \@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} + + +% Sets the opacity of stroking operations. +% +% #1 = opacity, where 1 means fully opaque and 0 means fully +% transparent. +% +% Example: +% +% \pgfsetstrokeopacity{0.5} + +\def\pgfsetstrokeopacity#1{% + \edef\pgf@temp{{#1}}% + \expandafter\pgfsys@stroke@opacity\pgf@temp} + + +% Sets the opacity of stroking operations. +% +% #1 = opacity, where 1 means fully opaque and 0 means fully +% transparent. +% +% Example: +% +% \pgfsetfillopacity{0.5} + +\def\pgfsetfillopacity#1{% + \edef\pgf@temp{{#1}}% + \expandafter\pgfsys@fill@opacity\pgf@temp} + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoremath.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoremath.code.tex new file mode 100644 index 00000000000..a05d934f12b --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoremath.code.tex @@ -0,0 +1,262 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoremath.code.tex,v 1.1.1.1 2005/06/29 12:14:04 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + +% Mathematical stuff + + +% Internal registers +\newcounter{pgf@counta} +\newcounter{pgf@countb} +\newcounter{pgf@countc} +\newcounter{pgf@countd} + +% Internal setting function +\def\pgf@setmath#1#2{\edef\pgf@temp{#2pt}\csname pgf@#1\endcsname=\pgf@temp} + + +% Calculate sin of a degree +% +% #1 = degree +% +% x = sin of #1 +% +% Example: +% +% \pgfsin{30} + +\def\pgfsin#1{% + \pgf@setcounter{pgf@counta}{#1}\relax% + \c@pgf@countb=90% + \advance\c@pgf@countb by-\c@pgf@counta% + \ifnum\c@pgf@countb>179% + \advance\c@pgf@countb by-360% + \else% + \ifnum\c@pgf@countb<-179% + \advance\c@pgf@countb by360% + \fi\fi% + \ifnum\c@pgf@countb<0\relax% + \c@pgf@countb=-\c@pgf@countb% + \fi% + \pgf@setmath{x}{\csname pgf@cos\the\c@pgf@countb\endcsname}} + + +% Calculate cos of a degree +% +% #1 = degree +% +% x = cos of #1 +% +% Example: +% +% \pgfcos{30} + +\def\pgfcos#1{% + \pgf@setcounter{pgf@counta}{#1}% + \ifnum\c@pgf@counta>179% + \advance\c@pgf@counta by-360% + \else% + \ifnum\c@pgf@counta<-179% + \advance\c@pgf@counta by360% + \fi\fi% + \ifnum\c@pgf@counta<0\relax% + \c@pgf@counta=-\c@pgf@counta% + \fi% + \pgf@setmath{x}{\csname pgf@cos\the\c@pgf@counta\endcsname}} + + + +% Calculate sin and cos of a degree +% +% #1 = degree +% +% x = cos of #1 +% y = sin of #1 +% +% Example: +% +% \pgfcos{30} + +\def\pgfsincos#1{% + \pgf@setcounter{pgf@counta}{#1}% + \ifnum\c@pgf@counta>179% + \advance\c@pgf@counta by-360% + \else% + \ifnum\c@pgf@counta<-179% + \advance\c@pgf@counta by360% + \fi\fi\relax% + \c@pgf@countb=\c@pgf@counta\relax% + \ifnum\c@pgf@counta<0\relax% + \c@pgf@counta=-\c@pgf@counta% + \fi\relax% + \pgf@setmath{y}{\csname pgf@cos\the\c@pgf@counta\endcsname}% + \c@pgf@counta=90% + \advance\c@pgf@counta by-\c@pgf@countb\relax% + \ifnum\c@pgf@counta>179% + \advance\c@pgf@counta by-360% + \else% + \ifnum\c@pgf@counta<-179% + \advance\c@pgf@counta by360% + \fi\fi\relax% + \ifnum\c@pgf@counta<0\relax% + \c@pgf@counta=-\c@pgf@counta% + \fi\relax% + \pgf@setmath{x}{\csname pgf@cos\the\c@pgf@counta\endcsname}} + + +% Internal tables + +\def\pgf@def#1#2#3{\expandafter\def\csname pgf@#1#2\endcsname{#3}} +\pgf@def{cos}{0}{1} \pgf@def{cos}{1}{0.999848} +\pgf@def{cos}{2}{0.999391} \pgf@def{cos}{3}{0.99863} +\pgf@def{cos}{4}{0.997564} \pgf@def{cos}{5}{0.996195} +\pgf@def{cos}{6}{0.994522} \pgf@def{cos}{7}{0.992546} +\pgf@def{cos}{8}{0.990268} \pgf@def{cos}{9}{0.987688} +\pgf@def{cos}{10}{0.984808} \pgf@def{cos}{11}{0.981627} +\pgf@def{cos}{12}{0.978148} \pgf@def{cos}{13}{0.97437} +\pgf@def{cos}{14}{0.970296} \pgf@def{cos}{15}{0.965926} +\pgf@def{cos}{16}{0.961262} \pgf@def{cos}{17}{0.956305} +\pgf@def{cos}{18}{0.951057} \pgf@def{cos}{19}{0.945519} +\pgf@def{cos}{20}{0.939693} \pgf@def{cos}{21}{0.93358} +\pgf@def{cos}{22}{0.927184} \pgf@def{cos}{23}{0.920505} +\pgf@def{cos}{24}{0.913545} \pgf@def{cos}{25}{0.906308} +\pgf@def{cos}{26}{0.898794} \pgf@def{cos}{27}{0.891007} +\pgf@def{cos}{28}{0.882948} \pgf@def{cos}{29}{0.87462} +\pgf@def{cos}{30}{0.866025} \pgf@def{cos}{31}{0.857167} +\pgf@def{cos}{32}{0.848048} \pgf@def{cos}{33}{0.838671} +\pgf@def{cos}{34}{0.829038} \pgf@def{cos}{35}{0.819152} +\pgf@def{cos}{36}{0.809017} \pgf@def{cos}{37}{0.798636} +\pgf@def{cos}{38}{0.788011} \pgf@def{cos}{39}{0.777146} +\pgf@def{cos}{40}{0.766044} \pgf@def{cos}{41}{0.75471} +\pgf@def{cos}{42}{0.743145} \pgf@def{cos}{43}{0.731354} +\pgf@def{cos}{44}{0.71934} \pgf@def{cos}{45}{0.707107} +\pgf@def{cos}{46}{0.694658} \pgf@def{cos}{47}{0.681998} +\pgf@def{cos}{48}{0.669131} \pgf@def{cos}{49}{0.656059} +\pgf@def{cos}{50}{0.642788} \pgf@def{cos}{51}{0.62932} +\pgf@def{cos}{52}{0.615661} \pgf@def{cos}{53}{0.601815} +\pgf@def{cos}{54}{0.587785} \pgf@def{cos}{55}{0.573576} +\pgf@def{cos}{56}{0.559193} \pgf@def{cos}{57}{0.544639} +\pgf@def{cos}{58}{0.529919} \pgf@def{cos}{59}{0.515038} +\pgf@def{cos}{60}{0.5} \pgf@def{cos}{61}{0.48481} +\pgf@def{cos}{62}{0.469472} \pgf@def{cos}{63}{0.45399} +\pgf@def{cos}{64}{0.438371} \pgf@def{cos}{65}{0.422618} +\pgf@def{cos}{66}{0.406737} \pgf@def{cos}{67}{0.390731} +\pgf@def{cos}{68}{0.374607} \pgf@def{cos}{69}{0.358368} +\pgf@def{cos}{70}{0.34202} \pgf@def{cos}{71}{0.325568} +\pgf@def{cos}{72}{0.309017} \pgf@def{cos}{73}{0.292372} +\pgf@def{cos}{74}{0.275637} \pgf@def{cos}{75}{0.258819} +\pgf@def{cos}{76}{0.241922} \pgf@def{cos}{77}{0.224951} +\pgf@def{cos}{78}{0.207912} \pgf@def{cos}{79}{0.190809} +\pgf@def{cos}{80}{0.173648} \pgf@def{cos}{81}{0.156434} +\pgf@def{cos}{82}{0.139173} \pgf@def{cos}{83}{0.121869} +\pgf@def{cos}{84}{0.104528} \pgf@def{cos}{85}{0.0871557} +\pgf@def{cos}{86}{0.0697565} \pgf@def{cos}{87}{0.052336} +\pgf@def{cos}{88}{0.0348995} \pgf@def{cos}{89}{0.0174524} +\pgf@def{cos}{90}{0} \pgf@def{cos}{91}{-0.0174524} +\pgf@def{cos}{92}{-0.0348995} \pgf@def{cos}{93}{-0.052336} +\pgf@def{cos}{94}{-0.0697565} \pgf@def{cos}{95}{-0.0871557} +\pgf@def{cos}{96}{-0.104528} \pgf@def{cos}{97}{-0.121869} +\pgf@def{cos}{98}{-0.139173} \pgf@def{cos}{99}{-0.156434} +\pgf@def{cos}{100}{-0.173648} \pgf@def{cos}{101}{-0.190809} +\pgf@def{cos}{102}{-0.207912} \pgf@def{cos}{103}{-0.224951} +\pgf@def{cos}{104}{-0.241922} \pgf@def{cos}{105}{-0.258819} +\pgf@def{cos}{106}{-0.275637} \pgf@def{cos}{107}{-0.292372} +\pgf@def{cos}{108}{-0.309017} \pgf@def{cos}{109}{-0.325568} +\pgf@def{cos}{110}{-0.34202} \pgf@def{cos}{111}{-0.358368} +\pgf@def{cos}{112}{-0.374607} \pgf@def{cos}{113}{-0.390731} +\pgf@def{cos}{114}{-0.406737} \pgf@def{cos}{115}{-0.422618} +\pgf@def{cos}{116}{-0.438371} \pgf@def{cos}{117}{-0.45399} +\pgf@def{cos}{118}{-0.469472} \pgf@def{cos}{119}{-0.48481} +\pgf@def{cos}{120}{-0.5} \pgf@def{cos}{121}{-0.515038} +\pgf@def{cos}{122}{-0.529919} \pgf@def{cos}{123}{-0.544639} +\pgf@def{cos}{124}{-0.559193} \pgf@def{cos}{125}{-0.573576} +\pgf@def{cos}{126}{-0.587785} \pgf@def{cos}{127}{-0.601815} +\pgf@def{cos}{128}{-0.615661} \pgf@def{cos}{129}{-0.62932} +\pgf@def{cos}{130}{-0.642788} \pgf@def{cos}{131}{-0.656059} +\pgf@def{cos}{132}{-0.669131} \pgf@def{cos}{133}{-0.681998} +\pgf@def{cos}{134}{-0.694658} \pgf@def{cos}{135}{-0.707107} +\pgf@def{cos}{136}{-0.71934} \pgf@def{cos}{137}{-0.731354} +\pgf@def{cos}{138}{-0.743145} \pgf@def{cos}{139}{-0.75471} +\pgf@def{cos}{140}{-0.766044} \pgf@def{cos}{141}{-0.777146} +\pgf@def{cos}{142}{-0.788011} \pgf@def{cos}{143}{-0.798636} +\pgf@def{cos}{144}{-0.809017} \pgf@def{cos}{145}{-0.819152} +\pgf@def{cos}{146}{-0.829038} \pgf@def{cos}{147}{-0.838671} +\pgf@def{cos}{148}{-0.848048} \pgf@def{cos}{149}{-0.857167} +\pgf@def{cos}{150}{-0.866025} \pgf@def{cos}{151}{-0.87462} +\pgf@def{cos}{152}{-0.882948} \pgf@def{cos}{153}{-0.891007} +\pgf@def{cos}{154}{-0.898794} \pgf@def{cos}{155}{-0.906308} +\pgf@def{cos}{156}{-0.913545} \pgf@def{cos}{157}{-0.920505} +\pgf@def{cos}{158}{-0.927184} \pgf@def{cos}{159}{-0.93358} +\pgf@def{cos}{160}{-0.939693} \pgf@def{cos}{161}{-0.945519} +\pgf@def{cos}{162}{-0.951057} \pgf@def{cos}{163}{-0.956305} +\pgf@def{cos}{164}{-0.961262} \pgf@def{cos}{165}{-0.965926} +\pgf@def{cos}{166}{-0.970296} \pgf@def{cos}{167}{-0.97437} +\pgf@def{cos}{168}{-0.978148} \pgf@def{cos}{169}{-0.981627} +\pgf@def{cos}{170}{-0.984808} \pgf@def{cos}{171}{-0.987688} +\pgf@def{cos}{172}{-0.990268} \pgf@def{cos}{173}{-0.992546} +\pgf@def{cos}{174}{-0.994522} \pgf@def{cos}{175}{-0.996195} +\pgf@def{cos}{176}{-0.997564} \pgf@def{cos}{177}{-0.99863} +\pgf@def{cos}{178}{-0.999391} \pgf@def{cos}{179}{-0.999848} +\pgf@def{cos}{180}{-1} + + + +\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/pgfcoreobjects.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex new file mode 100644 index 00000000000..fd12c5d9146 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex @@ -0,0 +1,97 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreobjects.code.tex,v 1.1.1.1 2005/06/29 12:14:04 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + +% 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/pgfcorepathconstruction.code.tex b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruction.code.tex new file mode 100644 index 00000000000..b96bf719320 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruction.code.tex @@ -0,0 +1,826 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorepathconstruction.code.tex,v 1.2 2005/09/30 07:14:03 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + +\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% +} + + +\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{% + \pgf@setcounter{pgf@countc}{#1}% + \pgf@setcounter{pgf@countd}{#2}% + \ifnum\c@pgf@countc>360\relax% + \advance\c@pgf@countc by-360\relax% + \fi% + \ifnum\c@pgf@countc<-360\relax% + \advance\c@pgf@countc by360\relax% + \fi% + \ifnum\c@pgf@countd>360\relax% + \advance\c@pgf@countd by-360\relax% + \fi% + \ifnum\c@pgf@countd<-360\relax% + \advance\c@pgf@countd by360\relax% + \fi% + \loop% + \@tempcnta=\c@pgf@countc\relax% + \advance\@tempcnta by-\c@pgf@countd\relax% + \ifnum\@tempcnta<0\relax% + \@tempcnta=-\@tempcnta\relax% + \fi% + \ifnum\@tempcnta>90\relax% + \ifnum\c@pgf@countd>\c@pgf@countc\relax% + \@tempcnta=\c@pgf@countc\relax% + \advance\@tempcnta by 90\relax% + \expandafter\pgf@arc\expandafter{\expandafter\c@pgf@countc\expandafter}\expandafter{\the\@tempcnta}{#3}% + \advance\c@pgf@countc by 90\relax% + \else + \@tempcnta=\c@pgf@countc\relax% + \advance\@tempcnta by -90\relax% + \expandafter\pgf@arc\expandafter{\expandafter\c@pgf@countc\expandafter}\expandafter{\the\@tempcnta}{#3}% + \advance\c@pgf@countc by -90\relax% + \fi% + \repeat% + \pgf@roundcornerifneeded% + \pgf@arc{\c@pgf@countc}{\c@pgf@countd}{#3}% +} + +\def\pgf@arc#1#2#3{% + \in@/{#3}% + \ifin@% + \pgf@@arc{#1}{#2}#3\@@% + \else + \pgf@@arc{#1}{#2}#3/#3\@@% + \fi% +} + +\def\pgf@@arc#1#2#3/#4\@@{% + \setlength{\@tempdima}{#3}% + \setlength{\@tempdimb}{#4}% + \@tempcnta=#1\relax% + \@tempcntb=#2\relax% + \advance\@tempcntb by-\@tempcnta\relax% + \ifnum\@tempcntb<0\relax% + \@tempcntb=-\@tempcntb\relax% + \fi% + \ifnum\@tempcntb>85\relax% hackery to correct the control points + \@tempdima=0.0555\@tempdima\relax% + \@tempdimb=0.0555\@tempdimb\relax% + \else% + \ifnum\@tempcntb>75\relax% + \@tempdima=0.055\@tempdima\relax% + \@tempdimb=0.055\@tempdimb\relax% + \else% + \ifnum\@tempcntb>60\relax% + \@tempdima=0.0545\@tempdima\relax% + \@tempdimb=0.0545\@tempdimb\relax% + \else% + \@tempdima=0.054\@tempdima\relax% + \@tempdimb=0.054\@tempdimb\relax% + \fi% + \fi% + \fi + \@tempdima=\@tempcntb\@tempdima\relax% + \divide\@tempdima by 9\relax% + \@tempdimb=\@tempcntb\@tempdimb\relax% + \divide\@tempdimb by 9\relax% + %.. controls +(\@tempcnta+90:\@tempdima) and +(\@tempcntb-90:\@tempdima) .. +(-(#1:#3)+(#2:#3))% + % store first support vector in xa/ya: + \@tempcnta=#1\relax% + \ifnum#2>#1\relax% + \advance\@tempcnta by 90\relax% + \else% + \advance\@tempcnta by -90\relax% + \fi% + \pgfpointtransformed{\pgfpointpolar{\@tempcnta}{\@tempdima/\@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: + \@tempcnta=#1\relax% + \pgfpointtransformed{\pgfpointpolar{\@tempcnta}{#3/#4}}% + \pgf@xb=\pgf@path@lastx% + \pgf@yb=\pgf@path@lasty% + \advance\pgf@xb by -\pgf@x% + \advance\pgf@yb by -\pgf@y% + \@tempcnta=#2\relax% + \pgfpointtransformed{\pgfpointpolar{\@tempcnta}{#3/#4}}% + \advance\pgf@xb by \pgf@x% + \advance\pgf@yb by \pgf@y% + % store second support xc/yc: + \@tempcnta=#2\relax% + \ifnum#2>#1\relax% + \advance\@tempcnta by -90\relax% + \else% + \advance\@tempcnta by 90\relax% + \fi% + \pgfpointtransformed{\pgfpointpolar{\@tempcnta}{\@tempdima/\@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 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{\pgfpoint{\pgf@xa}{\pgf@ya}}% + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}% + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}% + \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathclose% + \pgfpathmoveto{\pgfpoint{\pgf@xb}{\pgf@xb}}% +} + +% 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}{\pgfpoint{\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)} + +\define@key{pgfbase}{stepx}{\setlength{\pgf@x}{#1}\relax} +\define@key{pgfbase}{stepy}{\setlength{\pgf@y}{#1}\relax} +\define@key{pgfbase}{step}{\pgf@process{#1}} + +\def\pgfpathgrid{\@ifnextchar[{\pgf@pathgrid}{\pgf@pathgrid[]}} +\def\pgf@pathgrid[#1]#2#3{% + \setkeys{pgfbase}{stepx=1cm,stepy=1cm}% + \setkeys{pgfbase}{#1}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \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% + \@tempswatrue% + \ifdim\pgf@xb=0pt\relax% + \ifdim\pgf@yb=0pt\relax% + \@tempswafalse% + \fi% + \fi% + {% + \if@tempswa% + \pgf@arccornersfalse + \else% + \fi% + \@tempswatrue% + \ifdim\pgf@xc=0pt\relax% + \ifdim\pgf@yc=0pt\relax% + \@tempswafalse% + \fi% + \fi% + \if@tempswa + {% + \pgf@pt@x=\pgf@path@lastx% + \pgf@pt@y=\pgf@path@lasty% + \pgfpathcurveto% + {\pgfpoint{.1125\pgf@xc}{.225\pgf@yc}}% found by trial and error + {\pgfpoint{.5\pgf@xc}{\pgf@yc}}% found by trial and error + {\pgfpoint{\pgf@xc}{\pgf@yc}}% + }% + \fi% + }% + \if@tempswa% + \pgf@xc=\pgf@xb% + \pgf@yc=\pgf@yb% + {% + \pgf@pt@x=\pgf@path@lastx% + \pgf@pt@y=\pgf@path@lasty% + \pgfpathcurveto% + {\pgfpoint{.5\pgf@xc}{0\pgf@yc}}% found by trial and error + {\pgfpoint{.8875\pgf@xc}{.775\pgf@yc}}% found by trial and error + {\pgfpoint{\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% + {\pgfpoint{.31830988618\pgf@xc}{.5\pgf@yc}}% found by trial and error + {\pgfpoint{.63502822294\pgf@xc}{\pgf@yc}}% found by trial and error + {\pgfpoint{\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% + {\pgfpoint{.36497177706\pgf@xc}{0pt}}% found by trial and error + {\pgfpoint{.68169011382\pgf@xc}{.5\pgf@yc}}% found by trial and error + {\pgfpoint{\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..db2a9d7c068 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathprocessing.code.tex @@ -0,0 +1,502 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorepathprocessing.code.tex,v 1.2 2005/10/03 15:52:27 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + + +% Cleanup path +% +% #1 = a macro name that stores a path +% +% Description: +% +% This command will remove superfluous parts from a path. Movetos with +% a moveto following are removed. +% +% Example: +% +% \pgfsyssoftpath@moveto{0}{0} +% \pgfsyssoftpath@moveto{10}{10} +% \pgfsyssoftpath@lineto{0}{0} +% \pgfsyssoftpath@getcurrentpath\mypath +% \pgfprocesspathcleanup\mypath + +\def\pgfprocesspathcleanup#1{% + {% + \let\pgf@newpath=\@empty% + \expandafter\pgf@cleanupprocessor#1\pgf@stop% + }% + \let#1=\pgf@newpath% +} + +\def\pgf@cleanupprocessor#1{% + \ifx#1\pgf@stop% + \let\next=\@gobble% ok, done + \else% + \ifx#1\pgfsyssoftpath@movetotoken% + \let\next=\pgf@cleanupmoveto% + \else% + \let\next=\pgf@cleanupredo% + \fi% + \fi% + \next#1% +} + +\def\pgf@cleanupredo#1#2#3{% + \g@addto@macro\pgf@newpath{#1{#2}{#3}}% + \pgf@cleanupprocessor% +} + +\def\pgf@cleanupmoveto#1#2#3#4{% + \ifx#4\pgfsyssoftpath@movetotoken% + % Ok, skip + \else% + \g@addto@macro\pgf@newpath{#1{#2}{#3}}% + \fi% + \pgf@cleanupprocessor#4% +} + + + +% 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\@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{\pgfpoint{#2}{#3}}% + \ifx#4\pgf@stop% + % pretty short path... + \let\pgfpointsecondonpath=\pgfpointfirstonpath% + \let\pgfpointsecondlastonpath=\pgfpointfirstonpath% + \let\pgfpointlastonpath=\pgfpointfirstonpath% + \let\next=\@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{\pgfpoint{#2}{#3}}% + \let\pgfpointsecondlastonpath=\pgfpointfirstonpath% + \let\pgfpointlastonpath=\pgfpointsecondonpath% + \ifx#4\pgf@stop% + % short path... + \let\next=\@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{\pgfpoint{#2}{#3}}% + \ifx#4\pgf@stop% + % end! + \let\next=\@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=\@gobbletwo% + \let\pgfsyssoftpath@linetotoken=\@gobbletwo% + \let\pgfsyssoftpath@curvetosupportatoken=\@gobbletwo% + \let\pgfsyssoftpath@curvetosupportbtoken=\@gobbletwo% + \let\pgfsyssoftpath@curvetotoken=\@gobbletwo% + \def\pgfsyssoftpath@rectcornertoken{\gdef\pgf@proc@todo{#2}\@gobbletwo}% + \def\pgfsyssoftpath@rectsizetoken{\gdef\pgf@proc@todo{#2}\@gobbletwo}% + \def\pgfsyssoftpath@closepathtoken{\gdef\pgf@proc@todo{#2}\@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\@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\@empty% + \let\pgfprocess@moveto\@empty% + \let\pgfprocess@firstto\@empty% + \let\pgfprocess@segment\@empty% + \pgf@xa=0pt% + \pgf@ya=0pt% + \expandafter\pgfprocess@round#1\pgf@stop{0pt}{0pt}% + \expandafter\g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@moveto}% + \expandafter\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\@empty% + \def\pgfprocess@firstto{{#2}{#3}}% + \fi% + \pgf@xa=#2% + \pgf@ya=#3% + \ifx#1\pgfsyssoftpath@movetotoken% + % ok, move old segment to newpath + \expandafter\g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@moveto}% + \expandafter\g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@segment}% + \def\pgfprocess@moveto{#1{#2}{#3}}% + \let\pgfprocess@firstto=\@empty% + \let\pgfprocess@segment=\@empty% + \else% + \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\@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{% + \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\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}% + {\noexpand\pgfpoint{\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\g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% + % + % now add curve + % + \edef\pgf@marshal% + {\noexpand\pgfpointlineatdistance{\pgfprocess@savey}% + {\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}% + {\noexpand\pgfpoint{\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\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\g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% + }% + % add end: + \edef\pgfprocess@addition{\noexpand\pgfsyssoftpath@curvetotoken{\the\pgf@xc}{\the\pgf@yc}}% + \expandafter\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{% + \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\@empty% + \else% + \ifx\pgfprocess@firstto\@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{% + {% + \let\pgf@newpath=\@empty% + \let\pgf@prepath=\@empty% + \ifx#1\@empty% + \else% + \pgf@process{#3}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#2}% + \expandafter\pgf@replaceprocessfirst#1\pgf@stop% + \fi% + \expandafter\expandafter\expandafter\def + \expandafter\expandafter\expandafter\pgf@newpath + \expandafter\expandafter\expandafter{\expandafter\pgf@prepath\pgf@newpath}% + \global\let#1=\pgf@newpath% + }% +} + +\def\pgf@replaceprocessfirst#1#2#3#4{% + \def\pgf@temppath{#1{#2}{#3}}% + \edef\pgf@newpath{\noexpand#1{\the\pgf@x}{\the\pgf@y}}% + \ifx#4\pgf@stop% + \let\next=\@gobble% + \else% + \let\next=\pgf@replaceprocessother% + \fi% + \next#4% +} + +\def\pgf@replaceprocessother#1{% + \ifx#1\pgfsyssoftpath@movetotoken% + % Arggghh! Must reset everything! + \expandafter\expandafter\expandafter\def + \expandafter\expandafter\expandafter\pgf@prepath + \expandafter\expandafter\expandafter{\expandafter\pgf@prepath\pgf@temppath}% + % Redo first. + \let\pgf@next=\pgf@replaceprocessfirst% + \else% + \let\pgf@next=\pgf@@replaceprocessother% + \fi% + \pgf@next#1% +} +\def\pgf@@replaceprocessother#1#2#3#4{% + \ifx#4\pgf@stop% + \edef\pgf@newpathaddition{{\noexpand#1{\the\pgf@xa}{\the\pgf@ya}}}% + \expandafter\g@addto@macro\expandafter\pgf@newpath\pgf@newpathaddition% + \let\next=\@gobble% + \else% + \g@addto@macro\pgf@temppath{#1{#2}{#3}}% + \g@addto@macro\pgf@newpath{#1{#2}{#3}}% + \let\next=\pgf@replaceprocessother% + \fi% + \next#4% +} + +\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..38bbdf07bba --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage.code.tex @@ -0,0 +1,209 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorepathusage.code.tex,v 1.2 2005/07/17 22:34:19 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + +% 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} + +\define@key{pgfup}{stroke}[]{\def\pgf@up@stroke{stroke}} +\define@key{pgfup}{draw}[]{\def\pgf@up@stroke{stroke}} +\define@key{pgfup}{fill}[]{\def\pgf@up@fill{fill}} +\define@key{pgfup}{clip}[]{\def\pgf@up@clip{clip}} +\define@key{pgfup}{discard}[]{} +\define@key{pgfup}{use as bounding box}[]{\def\pgf@up@bb{\pgf@relevantforpicturesizefalse}} + +\def\pgfusepath#1{% + \let\pgf@up@stroke\@empty% + \let\pgf@up@fill\@empty% + \let\pgf@up@clip\@empty% + \let\pgf@up@discard\@empty% + \let\pgf@up@bb\@empty% + \setkeys{pgfup}{#1}% + \expandafter\def\expandafter\pgf@up@action\expandafter{\csname pgfsys@\pgf@up@fill\pgf@up@stroke\endcsname}% + \ifx\pgf@up@stroke\@empty% + \ifx\pgf@up@fill\@empty% + \ifx\pgf@up@clip\@empty% + \let\pgf@up@action=\@empty% + \pgfsyssoftpath@setcurrentpath\@empty% + \else% + % only clipping + \let\pgf@up@action=\pgfsys@discardpath% + \fi% + \fi% + \fi% + \pgfprocessround{\pgfsyssoftpath@currentpath}{\pgfsyssoftpath@currentpath}% change the current path + % + % Check whether the path is stroked. If so, add half the path width + % to the bounding box. + % + \ifpgf@relevantforpicturesize% + \ifx\pgf@up@stroke\@empty% + \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% + % + \ifx\pgf@up@clip\@empty% + \ifx\pgf@up@stroke\@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\@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\@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{\setlength\pgf@shorten@start@additional{#1}} +\def\pgfsetshortenend#1{\setlength\pgf@shorten@end@additional{#1}} + +\newif\ifpgf@drawarrows + +\def\pgf@check@for@arrows{% + \pgf@drawarrowsfalse% + \ifx\pgf@startarrow\@empty\else\pgf@drawarrowstrue\fi% + \ifx\pgf@endarrow\@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\@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=\@empty +\let\pgf@shorten@start=\@empty + +\def\pgf@shorten@path@as@needed{% + \pgfprocesspathextractpoints{\pgf@arrowpath}% + \let\pgf@arrow@next=\pgf@shorten@now% + \ifx\pgf@shorten@start\@empty% + \ifx\pgf@shorten@end\@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% + \pgf@process{\pgfpointlineatdistance{\pgf@xc}{\pgfpointfirstonpath}{\pgfpointsecondonpath}}% + \global\pgf@x=\pgf@x% + \global\pgf@y=\pgf@y% + }% + \edef\pgfpointfirstonpath{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% + {% + \pgf@x=0pt% + \pgf@shorten@end% + \advance\pgf@x by\pgf@shorten@end@additional% + \pgf@xc=\pgf@x% + \pgf@process{\pgfpointlineatdistance{\pgf@xc}{\pgfpointlastonpath}{\pgfpointsecondlastonpath}}% + \global\pgf@x=\pgf@x% + \global\pgf@y=\pgf@y% + }% + \edef\pgfpointlastonpath{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfprocesspathreplacestartandend{\pgf@arrowpath}{\pgfpointfirstonpath}{\pgfpointlastonpath}% + \pgfsyssoftpath@setcurrentpath\pgf@arrowpath% +} + +\def\pgf@add@arrows@as@needed{% + \ifx\pgf@startarrow\@empty% + \else% + \pgflowlevelobj% + {\pgftransformarrow{\pgfpointsecondonpath}{\pgfpointfirstonpath}} + {\pgf@startarrow}% + \fi% + \ifx\pgf@endarrow\@empty% + \else% + \pgflowlevelobj% + {\pgftransformarrow{\pgfpointsecondlastonpath}{\pgfpointlastonpath}} + {\pgf@endarrow}% + \fi% +} + +\let\pgf@startarrow=\@empty +\let\pgf@endarrow=\@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..26e63666e02 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.code.tex @@ -0,0 +1,822 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorepoints.code.tex,v 1.1.1.1 2005/06/29 12:14:04 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + +\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}} + +\newdimen\pgf@tempdim +\def\pgf@setlength#1#2{% these will be used only when \nullfont is active + \begingroup% keep font setting local + \pgf@selectfontorig% restore font + \pgf@setlengthorig\pgf@tempdim{#2}% calculate dimension (possibly using calc) + \global\pgf@tempdim\pgf@tempdim% make dimension global + \endgroup% + #1=\pgf@tempdim\relax} +\def\pgf@addtolength#1#2{% + \begingroup% keep font setting local + \pgf@selectfontorig% restore font + \pgf@tempdim#1\relax% + \pgf@addtolengthorig\pgf@tempdim{#2}% calculate dimension (possibly using calc) + \global\pgf@tempdim\pgf@tempdim% make dimension global + \endgroup% + #1=\pgf@tempdim\relax} +\newcounter{pgf@tempcount} +\def\pgf@setcounter#1#2{% + \setcounter{pgf@tempcount}{#2}% makes change global! + \csname c@#1\endcsname=\c@pgf@tempcount\relax} +\def\pgf@selectfont{\pgf@selectfontorig\nullfont} + + + +% Return a point +% +% #1 = x-coordinate of the point +% #2 = y-coordinate of the point +% +% x = #1 +% y = #2 +% +% Example: +% +% \pgfpathmoveto{\pgfpoint{2pt}{3cm}} + +\def\pgfpoint#1#2{% + \setlength\pgf@x{#1}% + \setlength\pgf@y{#2}\ignorespaces} + +% Return the origin. +% +% x = 0 +% y = 0 +% +% Example: +% +% \pgfpathmoveto{\pgfpointorigin} + +\def\pgfpointorigin{\pgfpoint{0pt}{0pt}\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. For example, this command is useful for a low level +% coordinate system shift: +% +% Example: +% +% \begin{pgflowleveltransformshiftscope}{\pgfpointtransformed{\pgfpointorigin}} +% \pgfbox[center,center]{Hi!} +% \end{pgflowleveltransformshiftscope} + +\def\pgfpointtransformed#1{% + \pgf@process{% + #1% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + }% +} + + +% 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}}}% + }% +} + + +% 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)) +% +% 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 + \setlength\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{% + \def\pgf@time@s{#1}% + \pgf@x=#1pt% + \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 + + + +% Store a value in polar-coordinates +% +% #1 = a degree +% #2 = a radius +% +% x = #2 * cos(#1) +% y = #2 * sin(#2) +% +% Example: +% +% % Create a slanted rectangle +% +% \pgfpathmoveto{\pgfpointpolar{30}{1cm}} + +\def\pgfpointpolar#1#2{% + \pgfsincos{#1}% + \in@/{#2}% + \ifin@% + \pgf@polar@#2\@@% + \else% + \pgf@polar@#2/#2\@@% + \fi% + \pgf@xa=\pgf@sys@tonumber{\pgf@x}\pgf@xa% + \pgf@ya=\pgf@sys@tonumber{\pgf@y}\pgf@ya% + \pgf@y=\pgf@xa\relax% + \pgf@x=\pgf@ya\ignorespaces} + +\def\pgf@polar@#1/#2\@@{% + \setlength{\pgf@xa}{#2}% + \setlength{\pgf@ya}{#1}% +} + + + +% 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{\pgf@x=#1\pgf@xx% + \advance\pgf@x by #2\pgf@yx% + \pgf@y=#1\pgf@xy% + \advance\pgf@y by #2\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{% + \pgf@x=#1\pgf@xx% + \advance\pgf@x by #2\pgf@yx% + \advance\pgf@x by #3\pgf@zx% + \pgf@y=#1\pgf@xy% + \advance\pgf@y by #2\pgf@yy% + \advance\pgf@y by #3\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@setmath{x}{\csname pgf@cosfrac\the\c@pgf@countb\endcsname}% + \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@setmath{y}{\csname pgf@cosfrac\the\c@pgf@countb\endcsname}% + \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=1.00374\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=1.00374\pgf@y\relax} + + +\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..50c63ac22c7 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.code.tex @@ -0,0 +1,131 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorequick.code.tex,v 1.1.1.1 2005/06/29 12:14:04 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + +% 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..2f68e256038 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.tex @@ -0,0 +1,379 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorescopes.code.tex,v 1.9 2005/10/14 13:13:23 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + +% Globals + +\newbox\pgfpic +\newbox\pgf@hbox + +\newbox\pgf@layerbox@main + + +% 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\@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{\@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}% + \def\pgf@marshal{\setkeys{pgfbox}}% + \expandafter\pgf@marshal\expandafter{\pgf@text@options}% + \csname pgf@halign\pgf@text@hshift\endcsname% + \csname pgf@valign\pgf@text@vshift\endcsname% + % Protocol sizes: + \pgf@process{\pgfpointtransformed{\pgfpoint{0pt}{\dp\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfpoint{\wd\pgf@hbox}{\dp\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfpoint{0pt}{\ht\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfpoint{\wd\pgf@hbox}{\ht\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgfqboxsynced{\pgf@hbox}% + }% +} + +\define@key{pgfbox}{left}[]{\def\pgf@text@hshift{left}} +\define@key{pgfbox}{center}[]{} +\define@key{pgfbox}{right}[]{\def\pgf@text@hshift{right}} +\define@key{pgfbox}{top}[]{\def\pgf@text@vshift{top}} +\define@key{pgfbox}{bottom}[]{\def\pgf@text@vshift{bottom}} +\define@key{pgfbox}{base}[]{\def\pgf@text@vshift{base}} +\define@key{pgfbox}{at}{\pgftransformshift{#1}} +\define@key{pgfbox}{x}{\pgftransformxshift{#1}} +\define@key{pgfbox}{y}{\pgftransformyshift{#1}} +\define@key{pgfbox}{rotate}{\pgftransformrotate{#1}} + +\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{% + \@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% + \pgf@picmaxx=-16000pt\relax% + \pgf@picminx=16000pt\relax% + \pgf@picmaxy=-16000pt\relax% + \pgf@picminy=16000pt\relax% + \pgf@relevantforpicturesizetrue% + \pgf@resetpathsizes% + \@ifnextchar\bgroup\pgf@oldpicture\pgf@picture} +\def\pgf@oldpicture#1#2#3#4{% + \setlength\pgf@picminx{#1}% + \setlength\pgf@picminy{#2}% + \setlength\pgf@picmaxx{#3}% + \setlength\pgf@picmaxy{#4}% + \pgf@relevantforpicturesizefalse% + \pgf@picture} + +\def\pgf@picture{% + \setbox\pgfpic\hbox to0pt\bgroup% + \begingroup% + \color{.}% + \pgfsys@beginpicture% + \pgfsys@beginscope% + \pgfsetlinewidth{0.4pt}% + \pgftransformreset% + \pgfsyssoftpath@setcurrentpath\@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{% + % Shift baseline outside: + \global\let\pgf@shift@baseline=\pgf@baseline% + \endgroup% + \egroup% + \pgf@insertlayers% + \endgroup% + \pgfsys@discardpath\pgfsys@endscope% + \pgfsys@endpicture% + \endgroup% + \hss + \egroup% + % ok, now let's position the box + \ifdim\pgf@picmaxx=-16000pt\relax% + % empty picture. make size 0. + \pgf@picmaxx=0pt\relax% + \pgf@picminx=0pt\relax% + \pgf@picmaxy=0pt\relax% + \pgf@picminy=0pt\relax% + \fi% + \pgfsys@typesetpicturebox\pgfpic% + \endgroup% +} + +\def\pgf@insertlayers{% + \box\pgf@layerbox@main% +} + + +% 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{\def\pgf@baseline{#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\@empty% + \edef\pgfscope@linewidth{\the\pgflinewidth}% + \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% + \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% + \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}% + \pgftransformreset% + \pgfinterruptpath% + \ifx\pgf@setlengthorig\@undefined% + \else% + \let\setlength\pgf@setlengthorig% + \let\addtolength\pgf@addtolengthorig% + \let\selectfont\pgf@selectfontorig% + \fi% + \selectfont% + \pgfpicturefalse% + \pgf@savelayers% +} +\def\endpgfinterruptpicture +{% + \pgf@restorelayers% + \endpgfinterruptpath% + \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% +} + +\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..707c1708789 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.code.tex @@ -0,0 +1,409 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreshade.code.tex,v 1.3 2005/07/17 22:34:19 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + +% +% 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=\@empty% + \let\pgf@funcs=\@empty% + \let\pgf@psfuncs=\@empty% + \let\pgf@encode=\@empty% + \let\pgf@sys@shading@ranges=\@empty% + \pgf@sys@shading@range@num=0\relax% + \pgf@parsefirst[#1; ]% + \pgf@parselastdom[#1; ]% + \pgf@parsemid[#1; ]% + \ifx\pgf@bounds\@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]{% + \setlength\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); {% + \@ifnextchar]{% + \setlength\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}% + \@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% + \@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}% + \setlength\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% + \@gobble}{% + \setlength\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{% + \definecolor{pgfshadetemp}{rgb}{#1,#2,#3}% + \@ifundefined{applycolormixins}{}{\applycolormixins{pgfshadetemp}}% + \extractcolorspec{pgfshadetemp}{\pgf@tempcolor}% + \expandafter\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{% + \@ifnextchar]{\@gobble}%done! + {% + \@ifnextchar;{\pgf@grabsemicolor}% + {% + \@ifnextchar r{\pgf@grabrgb}% + {% + \@ifnextchar g{\pgf@grabgray}% + {% + \@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){% + \colorlet{pgf@tempcol}{#2}% + \extractcolorspec{pgf@tempcol}{\pgf@tempcolor}% + \expandafter\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 = name of the shading for later use +% #2 = height of the shading +% #3 = 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. +% +% 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{\@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\@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=\@empty% + \fi} + + +% Declares a vertical shading for later use. +% +% #1 = name of the shading for later use +% #2 = height of the shading +% #3 = 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{\@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\@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=\@empty% + \fi} + + +% Declares a radial shading for later use. +% +% #1 = name of the shading for later use +% #2 = center of inner circle +% #3 = 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{\@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\@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=\@empty% + \fi} + + +% 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\@ifundefined\expandafter{\pgf@shadingname}% + {\PackageError{pgfshade}{Undefined shading "#1"}{}}% + {% + {% + \globalcolorsfalse% + \def\pgf@shade@adds{}% + \@ifundefined{pgf@deps\pgf@shadingname}% + {}% + {% + \edef\@list{\csname pgf@deps\pgf@shadingname\endcsname}% + \@for\@temp:=\@list\do{% + {% + \@ifundefined{applycolormixins}{}{\applycolormixins{\@temp}}% + \extractcolorspec{\@temp}{\pgf@tempcolor}% + \expandafter\convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}% + \xdef\pgf@shade@adds{\pgf@shade@adds,\pgf@rgbcolor}% + }% + }% + }% + \expandafter\pgf@strip@shadename\pgf@shadingname!!% + \@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. +% +% 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: + \pgf@process{\pgfsincos{#2}}% + \pgf@xa=-\pgf@x% + \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}% + \pgfsys@transformcm% + {\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@x}}% + {\pgf@sys@tonumber{\pgf@xa}}{\pgf@sys@tonumber{\pgf@y}}{0pt}{0pt}% + \pgfuseshading{#1}% + \pgfsys@endscope% + \endgroup% + \fi% +} + +\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..b9c1e51cff0 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransformations.code.tex @@ -0,0 +1,540 @@ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoretransformations.code.tex,v 1.1.1.1 2005/06/29 12:14:04 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + + + +% 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} + + +% 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. + % Start with determinant + % Matrix = (aa ab + % ba bb) + {% + \@tempdima=\pgf@pt@aa pt% + \@tempdima=\pgf@pt@bb\@tempdima% aa * bb + \@tempdimb=\pgf@pt@ba pt% + \@tempdimb=\pgf@pt@ab\@tempdimb% ba * ab + \advance\@tempdima by -\@tempdimb% aa*bb - ba*ab + % Invert + \@tempdima=.125\@tempdima% + \c@pgf@counta=\@tempdima\relax% 8192*determinant + \@tempdima=8192pt% + \divide\@tempdima by\c@pgf@counta% + \pgf@x=\pgf@pt@bb\@tempdima% bb/(det A) + \xdef\pgf@new@pt@aa{\pgf@sys@tonumber{\pgf@x}}% + \pgf@x=\pgf@pt@aa\@tempdima% aa/(det A) + \xdef\pgf@new@pt@bb{\pgf@sys@tonumber{\pgf@x}}% + \@tempdima=-\@tempdima% + \pgf@x=\pgf@pt@ba\@tempdima% -ba/(det A) + \xdef\pgf@new@pt@ba{\pgf@sys@tonumber{\pgf@x}}% + \pgf@x=\pgf@pt@ab\@tempdima% -ab/(det A) + \xdef\pgf@new@pt@ab{\pgf@sys@tonumber{\pgf@x}}% + }% + \expandafter\def\expandafter\pgf@pt@aa\expandafter{\pgf@new@pt@aa}% + \expandafter\def\expandafter\pgf@pt@ab\expandafter{\pgf@new@pt@ab}% + \expandafter\def\expandafter\pgf@pt@ba\expandafter{\pgf@new@pt@ba}% + \expandafter\def\expandafter\pgf@pt@bb\expandafter{\pgf@new@pt@bb}% + \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% + % + \pgf@x=#1pt% + \pgf@y=#2pt% + % + \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% + % + \pgf@x=#3pt% + \pgf@y=#4pt% + % + \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% + \def\pgf@trans@idtest{#1,#2,#3,#4}% + \ifx\pgf@trans@idtest\pgf@trans@idtext% + \else% + \pgf@pt@identityfalse% + \fi% +} +\def\pgf@trans@idtext{1.0,0,0,1.0} + + + + + + +% 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{% + \pgfsincos{#1}% + \pgf@xa=-\pgf@x% + \pgftransformcm% + {\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@x}}% + {\pgf@sys@tonumber{\pgf@xa}}{\pgf@sys@tonumber{\pgf@y}}{\pgfpointorigin}% +} + + + +% The following two 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 +% +% \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\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% + \ifdim\pgf@x<0pt% + \pgf@x=-\pgf@x% + \pgf@y=-\pgf@y% + \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: +% +% { +% \pgftransformlabel{.5}{\pgfxy(0,0)}{\pgfxy(3,2)} +% \pgftext{Hi!} +% } +% +% { +% \pgftransformlabel{.75}{\pgfxy(0,0)}{\pgfxy(3,2)} +% \pgftransformresetnontranslations +% \pgftext{Hi!} +% } +% +\def\pgftransformcurveattime#1#2#3#4#5{% + \pgfpointcurveattime{#1}{#2}{#3}{#4}{#5}% + \pgftransformshift{\pgfpoint{\pgf@x}{\pgf@y}}% + \ifpgfresetnontranslationattime% + \pgftransformresetnontranslations% + \fi% + \ifpgfslopedattime% + \pgf@x=\pgf@xb% + \pgf@y=\pgf@yb% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@y by-\pgf@ya% + \ifdim\pgf@x<0pt% + \pgf@x=-\pgf@x% + \pgf@y=-\pgf@y% + \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}}{\pgfpoint{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 |