diff options
author | Karl Berry <karl@freefriends.org> | 2010-10-29 00:31:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-10-29 00:31:31 +0000 |
commit | 6bc1f5497cfb2f56d65c80a4c36ea3bad6dc046c (patch) | |
tree | f7751da75030fb1e06653eeb44e579fcee09c65f /Master/texmf-dist/tex/generic/pgf/libraries | |
parent | ed0c7c756e441b2d2ba3633da233fc24361ac0d3 (diff) |
pgf 2.10 (28oct10)
git-svn-id: svn://tug.org/texlive/trunk@20236 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/libraries')
36 files changed, 10247 insertions, 2540 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.barcharts.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.barcharts.code.tex new file mode 100644 index 00000000000..7eb1b719329 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.barcharts.code.tex @@ -0,0 +1,135 @@ +% Copyright 2008 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.barcharts.code.tex,v 1.3 2008/11/12 23:39:37 tantau Exp $ + +\usepgfmodule{datavisualization} + + +% +% This file defines additional data visualization classes. +% + + +\pgfooclass{candle stick visualizer} +{ + \attribute attribute; + \attribute offset; + \attribute use path rise=\pgfsetfillcolor{white}\pgfusepath{fill,stroke}; + \attribute use path fall=\pgfsetfillcolor{black}\pgfusepath{fill,stroke}; + \attribute use path wick=\pgfusepath{stroke}; + + \method candle stick visualizer(#1) { + \pgfooeset{attribute}{#1} + \pgfoothis.set stick width(4pt) + } + + \method default connects() { + \pgfoothis.get handle(\pgf@dv@me) + \pgfkeysvalueof{/pgf/data visualization/obj}.connect(\pgf@dv@me,visualize,visualize datapoint signal) + } + + \method set stick width(#1) { + \pgfmathparse{#1} + \pgfmathdivide{\pgfmathresult}{2} + \let\pgf@dv@lib@w=\pgfmathresult + % Compute the normalized vector: + \pgfkeyssetvalue{/data point/\pgfoovalueof{attribute}}{1} + \pgfcanvaspositionofdatapoint% + \pgfsettocanvasposition\pgf@dv@lib@lower% + \pgfkeyssetvalue{/data point/\pgfoovalueof{attribute}}{10} + \pgfcanvaspositionofdatapoint% + \pgfsettocanvasposition\pgf@dv@lib@upper% + \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@dv@lib@upper}{\pgf@dv@lib@lower}}}% + % Rotate by 90 degrees + \pgf@xa=\pgf@x% + \pgf@x=-\pgf@dv@lib@w\pgf@y% + \pgf@y=\pgf@dv@lib@w\pgf@xa% + \edef\pgf@dv@lib@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfoolet{offset}\pgf@dv@lib@temp + } + + \method set use path rise(#1) { + \pgfooset{use path rise}{#1} + } + + \method set use path fall(#1) { + \pgfooset{use path fall}{#1} + } + + \method visualize() { + { + \pgfooget{attribute}\pgf@lib@attribute% + \pgfkeysgetvalue{/data point/\pgf@lib@attribute/low}\pgf@lib@low + \pgfkeysgetvalue{/data point/\pgf@lib@attribute/high}\pgf@lib@high + \pgfkeysgetvalue{/data point/\pgf@lib@attribute/entry}\pgf@lib@entry + \pgfkeysgetvalue{/data point/\pgf@lib@attribute/exit}\pgf@lib@exit + \ifx\pgf@lib@low\pgfutil@empty\pgf@dv@lib@cs@skiptrue\fi + \ifx\pgf@lib@low\relax\pgf@dv@lib@cs@skiptrue\fi + \ifx\pgf@lib@high\pgfutil@empty\pgf@dv@lib@cs@skiptrue\fi + \ifx\pgf@lib@high\relax\pgf@dv@lib@cs@skiptrue\fi + \ifx\pgf@lib@entry\pgfutil@empty\pgf@dv@lib@cs@skiptrue\fi + \ifx\pgf@lib@entry\relax\pgf@dv@lib@cs@skiptrue\fi + \ifx\pgf@lib@exit\pgfutil@empty\pgf@dv@lib@cs@skiptrue\fi + \ifx\pgf@lib@exit\relax\pgf@dv@lib@cs@skiptrue\fi + \ifpgf@dv@lib@cs@skip% + \else% + \begin{pgfscope} + % Ok, compute low point + \pgfkeyssetvalue{/data point/\pgf@lib@attribute}\pgf@lib@low + \pgfcanvaspositionofdatapoint% + \pgfsettocanvasposition\pgf@dv@lib@lowpoint% + % Ok, compute hight point + \pgfkeyssetvalue{/data point/\pgf@lib@attribute}\pgf@lib@high + \pgfcanvaspositionofdatapoint% + \pgfsettocanvasposition\pgf@dv@lib@highpoint% + % Compute entry and exit + \pgfkeyssetvalue{/data point/\pgf@lib@attribute}\pgf@lib@entry + \pgfcanvaspositionofdatapoint% + \pgfsettocanvasposition\pgf@dv@lib@entrypoint% + \pgfkeyssetvalue{/data point/\pgf@lib@attribute}\pgf@lib@exit + \pgfcanvaspositionofdatapoint% + \pgfsettocanvasposition\pgf@dv@lib@exitpoint% + \ifdim\pgf@lib@entry pt<\pgf@lib@exit pt\relax% + \pgf@dv@lib@risetrue% + \fi% + \ifpgf@dv@lib@rise + \let\pgf@dv@lib@a=\pgf@dv@lib@entrypoint + \let\pgf@dv@lib@b=\pgf@dv@lib@exitpoint + \else + \let\pgf@dv@lib@a=\pgf@dv@lib@exitpoint + \let\pgf@dv@lib@b=\pgf@dv@lib@entrypoint + \fi + % Start drawing... + \pgfpathmoveto{\pgf@dv@lib@lowpoint} + \pgfpathlineto{\pgf@dv@lib@a} + \pgfpathmoveto{\pgf@dv@lib@highpoint} + \pgfpathlineto{\pgf@dv@lib@b} + \pgfoovalueof{use path wick} + \pgfpathmoveto{\pgfpointadd{\pgf@dv@lib@a}{\pgfoovalueof{offset}}} + \pgfpathlineto{\pgfpointadd{\pgf@dv@lib@b}{\pgfoovalueof{offset}}} + \pgfpathlineto{\pgfpointadd{\pgf@dv@lib@b}{\pgfpointscale{-1}{\pgfoovalueof{offset}}}} + \pgfpathlineto{\pgfpointadd{\pgf@dv@lib@a}{\pgfpointscale{-1}{\pgfoovalueof{offset}}}} + \pgfpathclose + \ifpgf@dv@lib@rise + \pgfoovalueof{use path rise} + \else + \pgfoovalueof{use path fall} + \fi + \end{pgfscope} + \fi + } + } + + \newif\ifpgf@dv@lib@cs@skip + \newif\ifpgf@dv@lib@rise +} + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.formats.functions.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.formats.functions.code.tex new file mode 100644 index 00000000000..a5af1c95e17 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.formats.functions.code.tex @@ -0,0 +1,197 @@ +% Copyright 2008 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.formats.functions.code.tex,v 1.3 2008/12/09 00:12:10 tantau Exp $ + +\usepgfmodule{datavisualization} + + + + +% Function evaluator +% +% (This uses TeX evaluation and is slow. *You have been warned*.) +% +% Description: +% +% The data contains the description of variables and functions. +% +% The format for the variables is +% +% var <name> : interval "["<start>:<end>"]" [ step <steps> | samples <samples>]; +% +% (The first two [ and ] are "real", the second pair means "optional", +% see the examples.) +% +% +% The format for the functions is +% +% func <name> = <body>; +% +% Additionally, the variables and functions stored in the keys +% /pgf/data/vars and /pgf/data/funcs will also be used, the format for +% them is the same as above. +% +% The <name> is always the name of a (data point) attribute. Inside +% the <body> it can be accessed using the \value macro, which is +% defined locally, here. +% +% Newlines are not importants, everything is gathered into a single +% line, the semicolons are used to detect the beginnings and ends of +% declarations. +% +% With everything setup in this way, for each variable, the variable +% ranges throught the values between start and end, either with the +% given step or the given number of samples. If neither is given, the +% current value of /pgf/data visualization/samples is used. If there +% are multiple variables, they all range over their respective +% intervals independently. Thus, "var x = [0,1]; var y = [0:1];", +% assuming samples=25, gives you 625 data points. +% +% As the variables range over their respective values, the functions +% are evaluated using the function stored in /pgf/data/evaluator. By +% default this is set to \pgfmathparse, but +% you can use a different parser, if you like. +% +% Example: +% +% data [format=function] { +% +% % This is a parametric plot with the parameter called t. +% var t : interval [0:360] samples 60; +% +% % Let's draw a circle: +% func x = sin(\value t); +% func y = cos(\value t); +% } +% +% data [format=function] { +% +% % This a surface plot data... +% var x : interval [0:1]; +% var y : interval [0:1]; +% +% % Let's draw a circle: +% func height = \value x*\value x + \value y*\value y; +% } + +\pgfdeclaredataformat{function} +{ % no catcode code +} +{ % Startup + % Init collectors + \let\value=\relax% avoid expansion + \pgfkeysgetvalue{/pgf/data/vars}\pgf@lib@dv@collector +} +{% Line arguments + #1% +} +{ % Line action + \edef\pgf@lib@dv@collector{\pgf@lib@dv@collector\space #1}% +} +{% Ignore empty lines +} +{% + \edef\pgf@lib@dv@collector{\pgf@lib@dv@collector\space \pgfkeysvalueof{/pgf/data/funcs}}% + \let\pgf@lib@dv@parsed\pgfutil@empty% + % launch parser on the result + \expandafter\pgf@lib@dv@func@parse \pgf@lib@dv@collector\pgf@stop% + \let\value\pgf@lib@dv@getval + \pgf@lib@dv@parsed\pgfdatapoint\pgfutil@gobble\pgf@stop% +} + +\pgfkeys{ + /pgf/data/vars/.initial=, + /pgf/data/funcs/.initial=, + /pgf/data/evaluator/.initial=\pgfmathparse, + /pgf/data/samples/.initial=25} + +\def\pgf@lib@dv@getval#1{\pgfkeysvalueof{/data point/#1}} + +\def\pgf@lib@dv@func@parse{% + \pgfutil@ifnextchar\pgf@stop{% done + \pgfutil@gobble% + } + {% + \pgfutil@ifnextchar v{% variable + \pgf@lib@dv@var% + }{% + \pgf@lib@dv@func% + }% + }% +} + +\def\pgf@lib@dv@func func #1 =#2;{% + \expandafter\def\expandafter\pgf@lib@dv@parsed\expandafter{\pgf@lib@dv@parsed\pgf@lib@dv@eval@func{#1}{#2}} + \pgf@lib@dv@func@parse% +} +\def\pgf@lib@dv@var var #1 :#2interval#3[#4:#5]{% + \pgfutil@ifnextchar s{% + \pgf@lib@dv@samplesorsteps{#1}{#4}{#5}% + }{% + \expandafter\def\expandafter\pgf@lib@dv@parsed\expandafter{% + \pgf@lib@dv@parsed\pgf@lib@dv@samples@var{#1}{#4}{#5}{\pgfkeysvalueof{/pgf/data/samples}}}% + \expandafter\pgf@lib@dv@func@parse\pgfutil@gobble% + } +} +\def\pgf@lib@dv@samplesorsteps#1#2#3s{% + \pgfutil@ifnextchar t{% step + \pgf@lib@dv@step{#1}{#2}{#3}% + }{% sample + \pgf@lib@dv@samples{#1}{#2}{#3}% + }% +} +\def\pgf@lib@dv@step#1#2#3tep#4;{% + \expandafter\def\expandafter\pgf@lib@dv@parsed\expandafter{\pgf@lib@dv@parsed\pgf@lib@dv@step@var{#1}{#2}{#3}{#4}}% + \pgf@lib@dv@func@parse% +} +\def\pgf@lib@dv@samples#1#2#3amples#4;{% + \expandafter\def\expandafter\pgf@lib@dv@parsed\expandafter{\pgf@lib@dv@parsed\pgf@lib@dv@samples@var{#1}{#2}{#3}{#4}}% + \pgf@lib@dv@func@parse% +} + +% +% Executer... +% +\def\pgf@lib@dv@samples@var#1#2#3#4{% + \pgfmathparse{#3}% + \let\pgf@lib@dv@temp=\pgfmathresult% + \pgfmathparse{#2}% + \pgfmathparse{\pgf@lib@dv@temp-\pgfmathresult}% + \pgfmathparse{\pgfmathresult/(#4-1)}% + \let\pgf@lib@dv@temp=\pgfmathresult% + \pgf@lib@dv@step@var{#1}{#2}{#3}{\pgf@lib@dv@temp}% +} + +\def\pgf@lib@dv@step@var#1#2#3#4#5\pgf@stop{% + {% + \def\pgf@loop@body{#5}% + \pgfmathparse{#2}% + \pgfkeyslet{/data point/#1}{\pgfmathresult}% + \pgfmathparse{#3}% + \let\pgf@loop@end\pgfmathresult% + \pgfmathparse{#4}% + \let\pgf@loop@step\pgfmathresult% + \pgfmathloop% + \pgfmathlessthan{\pgf@loop@end}{\pgfkeysvalueof{/data point/#1}} + \ifdim\pgfmathresult pt<1pt\relax% + \pgf@loop@body\pgf@stop% + \pgfmathparse{\pgfkeysvalueof{/data point/#1}+\pgf@loop@step}% + \pgfkeyslet{/data point/#1}{\pgfmathresult}% + \repeatpgfmathloop%% + }% +} + +\def\pgf@lib@dv@eval@func#1#2{% + \pgfkeysvalueof{/pgf/data/evaluator}{#2}% + \pgfkeyslet{/data point/#1}{\pgfmathresult}% +} + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.polar.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.polar.code.tex new file mode 100644 index 00000000000..f39adbbedaa --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.polar.code.tex @@ -0,0 +1,192 @@ +% Copyright 2008 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.polar.code.tex,v 1.2 2008/11/24 18:31:22 tantau Exp $ + +\usepgfmodule{datavisualization} + +% This file defines code for doing plots involving polar +% coordinates. This includes not only standard polar plots, but also +% pie charts. + + + +\pgfooclass{polar transformer} +{ + % Class plor mapper + % + % A polar mapper is used to transform attributes given as (2d) polar + % coordinates to canvas coordinates. Note that no special ranges + % can be specified and that the angle must be given in degrees. You + % can, however, use a standard mapper to change these things. + + \attribute angle; + % The attribute from which the angle is read. + + \attribute radius; + % The attribute from which the radius is read. + + \attribute unit vector 0 degrees; + % The unit vector 0 degrees + + \attribute unit vector 90 degrees; + % The unit vector 90 degrees + + + + % Constructor + % + % #1 = angle attribute. Example: rotation. + % #2 = radius attribute. Example: height. + % #3 = unit vector 0 degrees + % #4 = unit vector 90 degrees + % + \method polar transformer(#1,#2,#3,#4) { + \pgfooset{angle}{#1} + \pgfooset{radius}{#2} + \pgfooset{unit vector 0 degrees}{#3} + \pgfooset{unit vector 90 degrees}{#4} + } + + % Method + \method default connects() { + \pgfoothis.get handle(\pgf@dv@me) + \pgfkeysvalueof{/pgf/data visualization/obj}.connect(\pgf@dv@me,transform,transform datapoint signal) + \pgfkeysvalueof{/pgf/data visualization/obj}.connect(\pgf@dv@me,path,path signal) + \pgfkeysvalueof{/pgf/data visualization/obj}.connect(\pgf@dv@me,direction,direction signal) + } + + % Getters + \method get angle attribute(#1) { + \pgfooget{angle}{#1} + } + + \method get radius attribute(#1) { + \pgfooget{radius}{#1} + } + + + % Slot + % + % This slot should be connected to the transform datapoint + % signal. When this signal is emitted, the coordinate system will be + % shifted according to the current value of the attribute. + \method transform() { + \pgfkeysgetvalue{/data point/\pgfoovalueof{angle}/const}\pgf@dv@angle% + \ifx\pgf@dv@angle\relax + \pgfkeysgetvalue{/data point/\pgfoovalueof{angle}}\pgf@dv@angle% + \fi + \ifx\pgf@dv@angle\relax\else% + \ifx\pgf@dv@angle\pgfutil@empty\else% + \pgfkeysgetvalue{/data point/\pgfoovalueof{radius}/const}\pgf@dv@radius% + \ifx\pgf@dv@radius\relax + \pgfkeysgetvalue{/data point/\pgfoovalueof{radius}}\pgf@dv@radius% + \fi + \ifx\pgf@dv@radius\pgfutil@empty\else% + \ifx\pgf@dv@radius\relax\else% + \pgfmathsincos{\pgf@dv@angle}% + \pgfmathmultiply{\pgfmathresultx}{\pgf@dv@radius}% + \let\pgf@dv@polar@temp=\pgfmathresult + \pgftransformshift{\pgfpointscale{\pgf@dv@polar@temp}{\pgfoovalueof{unit vector 0 degrees}}}% + \pgfmathmultiply{\pgfmathresulty}{\pgf@dv@radius}% + \let\pgf@dv@polar@temp=\pgfmathresult + \pgftransformshift{\pgfpointscale{\pgf@dv@polar@temp}{\pgfoovalueof{unit vector 90 degrees}}}% + \fi% + \fi% + \fi% + \fi% + } + + + + % Reaction to the path signal + % + % Here is what we do: When a pgfdvpathmoveto is done, the radius and + % the angle are recorded. When a pgfdvpathlineto is done, the saved + % radius and angle are compared with the new angle and radius. If, + % and only if, the radius is the same, but the angle is different, + % the lineto is caught and replaced by an arc from the previous + % position to the new position. + + \attribute prev angle; + \attribute prev radius; + + \method path(#1) {% + \ifpgfdvhandled% + \else% + \ifx#1\pgfdvpathlinetotoken + % Ok, let us have a look... + \pgfooget{prev radius}\pgf@dv@prev@rad + \pgfkeysgetvalue{/data point/\pgfoovalueof{radius}}\pgf@dv@current@rad + \ifx\pgf@dv@current@rad\relax + \else + \ifdim\pgf@dv@current@rad pt=\pgf@dv@prev@rad pt% + \pgfooget{prev angle}\pgf@dv@prev@angle + \pgfkeysgetvalue{/data point/\pgfoovalueof{angle}}\pgf@dv@current@angle + \ifx\pgf@dv@current@angle\relax + \else + \ifdim\pgf@dv@current@angle pt=\pgf@dv@prev@angle pt% + % do nothing + \else% + % Do arc: + \pgfpatharcaxes{\pgf@dv@prev@angle}{\pgf@dv@current@angle} + {\pgfpointscale{\pgf@dv@current@rad}{\pgfoovalueof{unit vector 0 degrees}}} + {\pgfpointscale{\pgf@dv@current@rad}{\pgfoovalueof{unit vector 90 degrees}}}% + \pgfdvhandledtrue% + \fi% + \fi% + \fi% + \fi% + \fi% + \fi% + % No matter what, record the current position + \pgfooeset{prev angle}{\pgfkeysvalueof{/data point/\pgfoovalueof{angle}}} + \pgfooeset{prev radius}{\pgfkeysvalueof{/data point/\pgfoovalueof{radius}}} + } + + % Method + % + % React to direction signals. See pgfpointdvdirection for an + % explanation + % + \method direction(#1) {% + \ifx#1\pgfdvdirectionfromtoken + % Record angle and radius + \xdef\pgf@dv@polar@from@angle{\pgfkeysvalueof{/data point/\pgfoovalueof{angle}}} + \xdef\pgf@dv@polar@from@radius{\pgfkeysvalueof{/data point/\pgfoovalueof{radius}}} + \else% + \pgfkeysgetvalue{/data point/\pgfoovalueof{radius}}\pgf@dv@polar@to@radius + \ifx\pgf@dv@polar@to@radius\relax + \else + \ifdim\pgf@dv@polar@to@radius pt=\pgf@dv@polar@from@radius pt% + \pgfkeysgetvalue{/data point/\pgfoovalueof{angle}}\pgf@dv@polar@to@angle + \ifx\pgf@dv@polar@to@angle\relax + \else + \ifdim\pgf@dv@polar@to@angle pt=\pgf@dv@polar@from@angle pt% + % do nothing + \else% + % Output vector that it orthogonal to start angle: + \ifdim\pgf@dv@polar@to@angle pt>\pgf@dv@polar@from@angle pt% + \pgf@process{\pgfpointpolar{\pgf@dv@polar@from@angle+90}{1pt}} + \else + \pgf@process{\pgfpointpolar{\pgf@dv@polar@from@angle-90}{1pt}} + \fi + \pgfdvhandledtrue + \fi% + \fi% + \fi% + \fi% + \fi% + } +} + + +\endinput + + diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.footprints.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.footprints.code.tex index 5cf633d0c59..5cf633d0c59 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.footprints.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.footprints.code.tex diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.fractals.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.fractals.code.tex index 22c9d8d1b27..22c9d8d1b27 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.fractals.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.fractals.code.tex diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.markings.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.markings.code.tex new file mode 100644 index 00000000000..dcb98da9119 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.markings.code.tex @@ -0,0 +1,187 @@ +% Copyright 2008 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\usepgfmodule{decorations} + + +% A marking decoration is used to add markings (which are just pgf +% scopes, essentially) at certain positions of a path. + +\pgfkeys{ + /pgf/decoration/reset marks/.code=\let\pgf@lib@dec@mark@marks=\pgfutil@empty, + /pgf/decoration/mark/.code=\pgf@lib@dec@parsemark#1\pgf@lib@dec@stop, +} + +\let\pgf@lib@dec@mark@marks=\pgfutil@empty + +\def\pgf@lib@dec@parsemark{\pgfutil@ifnextchar b{\pgf@lib@dec@parsebetween}{\pgf@lib@dec@parseat}} +\def\pgf@lib@dec@parseat at position#1with#2\pgf@lib@dec@stop{% + \expandafter\def\expandafter\pgf@lib@dec@mark@marks\expandafter{\pgf@lib@dec@mark@marks% + \pgf@lib@dec@domark{#1}{#2}% + }% +} +\def\pgf@lib@dec@parsebetween between positions#1and#2step#3with#4\pgf@lib@dec@stop{% + \expandafter\def\expandafter\pgf@lib@dec@mark@marks\expandafter{\pgf@lib@dec@mark@marks% + \pgf@lib@dec@dobetweenmark{#1}{#2}{#3}{#4}% + }% +} + +\def\pgf@lib@dec@arrowhead#1#2{% + \expandafter\ifx\csname tikz@special@arrow@end#2\endcsname\relax% be nice to TikZ + \pgfsetarrowsend{#2} + \else% + \pgfsetarrowsend{\csname tikz@special@arrow@end#2\endcsname}% + \fi% + \pgf@x=0pt% + \pgf@shorten@end% + \pgftransformxshift{-\pgf@x} + \pgftransformxscale{#1} + \pgflowlevelsynccm% + \pgflowlevelobj{}{\pgf@endarrow}% +} + +\def\pgf@lib@dec@doarrowhead#1{% + \pgf@lib@dec@arrowhead{1}{#1}% +} +\def\pgf@lib@dec@doarrowheadrev#1{% + \pgf@lib@dec@arrowhead{-1}{#1}% +} + + +\pgfdeclaredecoration{markings}{init} +{ + \state{init} + [ + width=0pt, + persistent precomputation={% + \pgfkeys{/pgf/decoration/mark info/sequence number/.initial=0}% + \pgfkeys{/pgf/decoration/mark info/distance from start/.initial=}% + }, + next state=pre + ] + {} + + \state{pre} + [ + width=0pt, + persistent precomputation={% + \def\pgf@lib@dec@computed@width{0pt}% + \pgf@lib@dec@mark@marks\pgf@lib@dec@mark@last% + \let\arrow=\pgf@lib@dec@doarrowhead% + \let\arrowreversed=\pgf@lib@dec@doarrowheadrev% + }, + next state=skipper + ] + {} + + \state{skipper}[width=\pgf@lib@dec@computed@width-\pgfdecoratedcompleteddistance-1sp, + next state=\pgf@lib@dec@next@state]{} + + \state{main} + [ + width=1sp, + next state=pre, + persistent precomputation={% + \pgfutil@tempcnta=\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}\relax% + \advance\pgfutil@tempcnta by1\relax% + \pgfkeys{/pgf/decoration/mark info/sequence number/.expanded=\the\pgfutil@tempcnta}% + \pgfkeys{/pgf/decoration/mark info/distance from start/.expanded=\pgf@lib@dec@computed@width}% + }% + ] + {% + \pgfinterruptpath% + \pgfscope% + \let\pgf@lib@dec@mark@marks=\pgfutil@empty% + \pgf@lib@dec@computed@action% + \endpgfscope% + \endpgfinterruptpath% + \ifx\pgf@lib@mark@node\pgfutil@empty% + \else% + \pgf@lib@mark@connect@node% + \fi% + }% + + \state{final}[width=\pgfdecoratedremainingdistance]{ + \ifx\pgf@lib@mark@node\pgfutil@empty% + \pgfpathmoveto{\pgfpointdecoratedpathlast} + \else% + \pgfpathlineto{\pgfpointdecoratedpathlast} + \fi% + } +} + +\def\pgf@lib@dec@domark#1#2#3\pgf@lib@dec@mark@last{% + \def\pgf@lib@dec@mark@marks{#3}% + \pgf@lib@dec@parsenum{#1}% + \def\pgf@lib@dec@computed@action{#2}% + \def\pgf@lib@dec@next@state{main}% +} + + +\def\pgf@lib@dec@dobetweenmark#1#2#3#4#5\pgf@lib@dec@mark@last{% + \pgf@lib@dec@parsenum{#1}% + \let\pgf@lib@dec@mark@start=\pgf@lib@dec@computed@width% + \pgf@lib@dec@parsenum{#2}% + \let\pgf@lib@dec@mark@end=\pgf@lib@dec@computed@width% + \ifdim\pgf@lib@dec@mark@end<\pgf@lib@dec@mark@start\relax% + % Skip! + #5\pgf@lib@dec@mark@last% + \else% + % + \pgf@lib@dec@parsenum{#3}% + \pgfmathparse{\pgf@lib@dec@mark@start+\pgf@lib@dec@computed@width}% + % Update entry in mark list + \edef\pgf@temp{\noexpand\pgf@lib@dec@dobetweenmark{\pgfmathresult pt}{\pgf@lib@dec@mark@end}{\pgf@lib@dec@computed@width}}% + \expandafter\def\expandafter\pgf@lib@dec@mark@marks\expandafter{\pgf@temp{#4}#5}% + \let\pgf@lib@dec@computed@width\pgf@lib@dec@mark@start% + \def\pgf@lib@dec@computed@action{#4}% + \def\pgf@lib@dec@next@state{main}% + \fi% +} + + +\def\pgf@lib@dec@parsenum#1{% + \pgfmathparse{#1}% + \ifpgfmathunitsdeclared% + \ifdim\pgfmathresult pt<0pt\relax% + \pgfmathparse{\pgfdecoratedpathlength\pgfmathresult pt}% + \else% + \pgfmathparse{\pgfmathresult pt}% + \fi% + \else% + \ifdim\pgfmathresult pt<0pt\relax% + \pgfmathparse{\pgfdecoratedpathlength\pgfmathresult*\pgfdecoratedpathlength}% + \else% + \pgfmathparse{\pgfmathresult*\pgfdecoratedpathlength}% + \fi% + \fi% + \edef\pgf@lib@dec@computed@width{\pgfmathresult pt}% +} + +\def\pgf@lib@dec@mark@last{% + \def\pgf@lib@dec@next@state{final}% +} + + +% +% If you set the mark connection node inside a mark picture, the +% output path will contain a line to this node +% + +\pgfkeys{/pgf/decoration/mark connection node/.store in=\pgf@lib@mark@node, + /pgf/decoration/mark connection node=} +\def\pgf@lib@mark@connect@node{% + % Line to "left" end of the node + \pgfpathlineto{\pgfpointshapeborder{\pgf@lib@mark@node}{\pgfqpoint{-1pt}{0pt}}} + % Move to "right" end of the node + \pgfpathmoveto{\pgfpointshapeborder{\pgf@lib@mark@node}{\pgfqpoint{1pt}{0pt}}} +}% + + +\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.pathmorphing.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.pathmorphing.code.tex index a6052489796..a6052489796 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.pathmorphing.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.pathmorphing.code.tex diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.pathreplacing.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.pathreplacing.code.tex index d07ae8ab6e5..e618ac996cf 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.pathreplacing.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.pathreplacing.code.tex @@ -1,4 +1,4 @@ -% Copyright 2008 by Mark Wibrow +% Copyright 2008 by Mark Wibrow and Till Tantau % % This file may be distributed and/or modified % @@ -174,4 +174,54 @@ +% show path construction decoration +% +\pgfdeclaredecoration{show path construction}{check for moveto}{ + \state{check for moveto}[width=0pt, next state=segment, + persistent precomputation={% + \begingroup% + \pgf@lib@decoraions@installinputsegmentpoints% + \ifx\pgfdecorationpreviousinputsegment\pgfdecorationinputsegmentmoveto% + \pgfdecoratedinputsegmentmovetocode% + \fi% + \endgroup% + }]{} + \state{segment}[width=\pgfdecoratedinputsegmentremainingdistance, next state=check for moveto, + persistent precomputation={% + \begingroup% + \pgf@lib@decoraions@installinputsegmentpoints% + \csname pgfdecoratedinputsegment\pgfdecorationcurrentinputsegment code\endcsname% + \endgroup% + }]{} + \state{final}{% + \egroup% + \begingroup% + \pgf@lib@decoraions@installinputsegmentpoints% + \csname pgfdecoratedinputsegment\pgfdecorationcurrentinputsegment code\endcsname% + \endgroup% + \bgroup% + } +} + +\pgfkeys{ + /pgf/decoration/.cd, + moveto code/.code=\def\pgfdecoratedinputsegmentmovetocode{#1}, + lineto code/.code=\def\pgfdecoratedinputsegmentlinetocode{#1}, + curveto code/.code=\def\pgfdecoratedinputsegmentcurvetocode{#1}, + closepath code/.code=\def\pgfdecoratedinputsegmentclosepathcode{#1} +} + +\let\pgfdecoratedinputsegmentmovetocode\pgfutil@empty% +\let\pgfdecoratedinputsegmentlinetocode\pgfutil@empty% +\let\pgfdecoratedinputsegmentcurvetocode\pgfutil@empty% +\let\pgfdecoratedinputsegmentclosepathcode\pgfutil@empty% + +\def\pgf@lib@decoraions@installinputsegmentpoints{% + \let\pgfpointdecoratedinputsegmentfirst\pgf@decorate@inputsegment@first% + \let\pgfpointdecoratedinputsegmentlast\pgf@decorate@inputsegment@last% + \let\pgfpointdecoratedinputsegmentsupporta\pgf@decorate@inputsegment@supporta% + \let\pgfpointdecoratedinputsegmentsupportb\pgf@decorate@inputsegment@supportb% +} + + \endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.shapes.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.shapes.code.tex index 6e1b25101bd..6e1b25101bd 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.shapes.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.shapes.code.tex diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.text.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.text.code.tex new file mode 100644 index 00000000000..b13f3ce0199 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.text.code.tex @@ -0,0 +1,347 @@ +% Copyright 2008 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\usepgfmodule{decorations} + + +% Options for text decorations + +\pgfkeys{ + /pgf/decoration/.cd, + text/.store in=\pgfdecorationtext,% + text color/.store in=\pgf@lib@decorationtextcolor,% + text format delimiters/.code={\expandafter\pgfsetdecoratetextformatdelimiters#1}, + text align/.code={\pgfkeys{/pgf/decoration/text align/.cd,#1}}, + text align/.cd, + align/.initial=left, + left/.style={/pgf/decoration/text align/align=left}, + right/.style={/pgf/decoration/text align/align=right}, + center/.style={/pgf/decoration/text align/align=center}, + left indent/.initial=0pt, + right indent/.initial=0pt, + fit to path/.is if=pgf@lib@dec@text@fit, + fit to path stretching spaces/.default=true, + fit to path stretching spaces/.code={% + \csname pgf@lib@dec@text@fit#1\endcsname% + \csname pgf@lib@dec@text@stretch@spaces#1\endcsname% + }% +} + +\newif\ifpgf@lib@dec@text@scan@space +\newif\ifpgf@lib@dec@text@stretch@spaces +\newif\ifpgf@lib@dec@text@fit + +\def\pgf@lib@decorationtextcolor{black} + +\def\pgf@lib@dec@text@left@text{left} +\def\pgf@lib@dec@text@right@text{right} +\def\pgf@lib@dec@text@right@center{center} + +% Decorates a path with a text. The path is removed during this +% process + +\pgfdeclaredecoration{text along path}{initial}{ +\state{initial}[width=+0pt, next state=left indent, + persistent precomputation={% + \edef\pgf@lib@dec@text@indent@left{\pgfkeysvalueof{/pgf/decoration/text align/left indent}}% + \edef\pgf@lib@dec@text@indent@right{\pgfkeysvalueof{/pgf/decoration/text align/right indent}}% + \edef\pgf@lib@dec@text@align{\pgfkeysvalueof{/pgf/decoration/text align/align}}% + \pgfdecoratedremainingdistance=\pgfdecoratedpathlength% + \advance\pgfdecoratedremainingdistance by-\pgf@lib@dec@text@indent@right\relax% + \edef\pgfdecoratedpathlength{\the\pgfdecoratedremainingdistance}% + \pgf@lib@dec@text@getwidth% + \pgf@x=\pgf@lib@dec@text@width\relax% + \pgf@y=\pgfdecoratedremainingdistance% + \ifpgf@lib@dec@text@fit% + \advance\pgf@y by-\pgf@lib@dec@text@indent@left\relax% + \advance\pgf@y by-\pgf@x% + \ifpgf@lib@dec@text@stretch@spaces% + \def\pgf@lib@dec@text@character@shift{0pt}% + \divide\pgf@y by\pgf@lib@dec@space@count\relax% + \edef\pgf@lib@dec@text@space@shift{\the\pgf@y}% + \else% + \c@pgf@counta=\pgf@lib@dec@character@count\relax% + \advance\c@pgf@counta by-1\relax% + \divide\pgf@y by\c@pgf@counta\relax% + \edef\pgf@lib@dec@text@character@shift{\the\pgf@y}% + \def\pgf@lib@dec@text@space@shift{0pt}% + \fi% + \ifdim\pgf@y<0pt\relax% + \pgf@lib@dec@text@fitfalse% + \pgf@lib@dec@text@stretch@spacesfalse% + \def\pgf@lib@dec@text@character@shift{0pt}% + \def\pgf@lib@dec@text@space@shift{0pt}% + \fi% + \else% + \def\pgf@lib@dec@text@character@shift{0pt}% + \def\pgf@lib@dec@text@space@shift{0pt}% + \ifx\pgf@lib@dec@text@align\pgf@lib@dec@text@left@text% + \else% + \ifx\pgf@lib@dec@text@align\pgf@lib@dec@text@right@text% + \advance\pgf@y by-\pgf@x% + \edef\pgf@lib@dec@text@indent@left{\the\pgf@y}% + \else% + \advance\pgf@y by-\pgf@x% + \advance\pgf@y by-\pgf@lib@dec@text@indent@left\relax% + \pgf@y=0.5\pgf@y% + \advance\pgf@y by\pgf@lib@dec@text@indent@left\relax% + \edef\pgf@lib@dec@text@indent@left{\the\pgf@y}% + \fi% + \fi% + \fi% + \let\pgfdecorationrestoftext=\pgfdecorationtext% + }]{} +\state{left indent}[width=+\pgf@lib@dec@text@indent@left, next state=scan]{} +% +\state{scan}[width=+0pt, next state=before typeset, + persistent precomputation={ + \pgf@lib@dec@text@scanchar% + \ifvoid\pgf@lib@dec@text@box% + \setbox\pgf@lib@dec@text@box\hbox{}% + \wd\pgf@lib@dec@text@box16383pt\relax% + \fi% + }]{} +% +\state{before typeset}[width=+.5\wd\pgf@lib@dec@text@box, next state=typeset]{} +% +\state{typeset}[width=+0pt, next state=after typeset] +{% + \pgftransformxshift{+-.5\wd\pgf@lib@dec@text@box}% + \setbox\pgf@hbox\hbox{\copy\pgf@lib@dec@text@box}% + \pgfqboxsynced\pgf@hbox% +} +\state{after typeset}[width=+.5\wd\pgf@lib@dec@text@box, next state=shift, + persistent precomputation={% + \ifpgf@lib@dec@text@fit% + \ifpgf@lib@dec@text@stretch@spaces% + \ifpgf@lib@dec@text@scan@space% + \let\pgf@lib@dec@text@shift=\pgf@lib@dec@text@space@shift% + \else% + \def\pgf@lib@dec@text@shift{0pt}% + \fi% + \else% + \let\pgf@lib@dec@text@shift=\pgf@lib@dec@text@character@shift% + \fi% + \else% + \def\pgf@lib@dec@text@shift{0pt}% + \fi% + }]{} +\state{shift}[width=+\pgf@lib@dec@text@shift, next state=scan]{} +\state{final}{} +} + + +% \pgfsetdecoratetextformatdelimiters +% +% Set the delimiters for formatting in the text decoration. +% NB: Catcodes for delimiters should be 11 or 12. +% +% Examples: +% +% \pgfsetdecoratetextformatdelimiters{|}{}% 2nd argument can be empty. +% +% \def\pgfdecoratetext{A big |\color{red}|red|| apple.} +% +% \pgfsetdecoratetextformatdelimiters{[}{]} +% +% \def\pgfdecoratetext{The [\it]very[+\color{green}]green[] sprouts.} +% +\def\pgfsetdecoratetextformatdelimiters#1#2{% + \def\pgf@lib@dec@text@formatchar{#1}% + \def\pgf@test{#2}% + \ifx\pgf@test\pgfutil@empty% + \def\pgf@lib@dec@text@collectformat##1#1{% + \pgf@lib@dec@text@@collectformat##1\pgf@stop}% + \else% + \def\pgf@lib@dec@text@collectformat##1#2{% + \pgf@lib@dec@text@@collectformat##1\pgf@stop}% + \fi% +} + +\pgfsetdecoratetextformatdelimiters{|}{} + +\newbox\pgf@lib@dec@text@box +\newif\ifpgf@lib@decorate@textmathmode + +\let\pgfdecorationtext=\pgfutil@empty +\let\pgfdecorationrestoftext=\pgfutil@empty% +\let\pgf@lib@dec@text@format=\pgfutil@empty + +\def\pgf@lib@dec@text@scanchar{% + \pgf@lib@dec@text@scan@spacefalse% + \ifx\pgfdecorationrestoftext\pgfutil@empty% + \let\pgf@lib@dec@text@char\pgfutil@empty% + \setbox\pgf@lib@dec@text@box\box\pgfutil@voidb@x% + \let\pgf@next\relax% + \else% + \let\pgf@next\pgf@lib@dec@text@@scanchar% + \fi% + \pgf@next} + +\def\pgf@lib@dec@text@@scanchar{% + \expandafter\pgf@lib@dec@text@@@scanchar\pgfdecorationrestoftext\pgf@stop} + +\def\pgf@lib@dec@text@@@scanchar{% + \futurelet\pgf@lib@dec@lettoken% + \pgf@lib@dec@text@@@@scanchar} + +\def\pgf@lib@dec@text@@@@scanchar{% + \ifx\pgf@lib@dec@lettoken\pgfutil@sptoken% + \let\pgf@next\pgf@lib@dec@text@insertspace% + \else% + \let\pgf@next\pgf@lib@dec@text@@@@@scanchar% + \fi% + \pgf@next} + +\def\pgf@lib@dec@text@@@@@scanchar{% + \pgfutil@ifnextchar\bgroup{\pgf@lib@dec@text@collectgroup}% + {\pgf@lib@dec@text@@@@@@scanchar}} + +\def\pgf@lib@dec@text@collectgroup#1{% + \def\pgf@lib@dec@text@char{#1}% + \pgf@lib@dec@text@collectrestoftext} + +\def\pgf@lib@dec@text@@@@@@scanchar#1{% + \ifx#1\pgf@stop% + \pgf@lib@dec@text@box\box\pgfutil@voidb@x% + \let\pgf@next\pgf@lib@dec@text@endoftext% + \else% + \def\pgf@lib@dec@text@char{#1}% + \ifx#1\space% + \let\pgf@next\pgf@lib@dec@text@collectrestoftext% + \else% + \ifx#1\ % + \let\pgf@next\pgf@lib@dec@text@collectrestoftext% + \else% + \ifx\pgf@lib@dec@text@char\pgf@lib@dec@text@formatchar% + \let\pgf@next\pgf@lib@dec@text@collectformat% + \else% + \expandafter\ifcat\noexpand#1\relax% + \let\pgf@next\pgf@lib@dec@text@expandcs% + \else% + \ifnum\catcode`#1=3\relax% + \ifpgf@lib@decorate@textmathmode% + \pgf@lib@decorate@textmathmodefalse% + \else% + \pgf@lib@decorate@textmathmodetrue% + \fi% + \let\pgf@next\pgf@lib@dec@text@@@scanchar% + \else% + \let\pgf@next\pgf@lib@dec@text@collectrestoftext% + \fi% + \fi% + \fi% + \fi% + \fi% + \fi% + \pgf@next% +} + +\def\pgf@lib@dec@text@@collectformat{% + \pgfutil@ifnextchar+{\pgf@lib@dec@text@addtoformat}{\pgf@lib@dec@text@setformat}} + +\def\pgf@lib@dec@text@setformat#1\pgf@stop{% + \def\pgf@lib@dec@text@format{#1}% + \pgf@lib@dec@text@@@scanchar% +} + +\def\pgf@lib@dec@text@addtoformat+#1\pgf@stop{% + \expandafter\def\expandafter\pgf@lib@dec@text@format\expandafter{\pgf@lib@dec@text@format#1}% + \pgf@lib@dec@text@@@scanchar% +} + +\def\pgf@lib@dec@text@insertspace{% + \pgf@lib@dec@text@scan@spacetrue% + \pgfutil@ifnextchar\bgroup{\pgf@lib@dec@text@@insertspacegrp}% + {\pgf@lib@dec@text@@insertspace}} + +\def\pgf@lib@dec@text@@insertspacegrp#1{% + \pgf@lib@dec@text@@@@@@scanchar\space{#1}} + +\def\pgf@lib@dec@text@@insertspace#1{% + \pgf@lib@dec@text@@@@@@scanchar\space#1} + +\def\pgf@lib@dec@text@expandcs{% + \expandafter\expandafter\expandafter\pgf@lib@dec@text@@@@@scanchar% + \pgf@lib@dec@text@char} + +\def\pgf@lib@dec@text@endoftext{% + \let\pgfdecoraterestoftext\pgfutil@empty% + \let\pgf@lib@dec@text@char\pgfutil@empty% +} +\def\pgf@lib@dec@text@collectrestoftext{% + \pgf@lib@dec@text@dobox% + \futurelet\pgf@lib@dec@text@lettoken% + \pgf@lib@dec@text@@collectrestoftext} + +\def\pgf@lib@dec@text@@collectrestoftext{% + \ifx\bgroup\pgf@lib@dec@text@lettoken% + \let\pgf@next\pgf@lib@dec@text@@@collectrestoftextgrp% + \else% + \let\pgf@next\pgf@lib@dec@text@@@collectrestoftext% + \fi% + \pgf@next} + +\def\pgf@lib@dec@text@@@collectrestoftextgrp#1#2\pgf@stop{\def\pgfdecorationrestoftext{{#1}#2}% +} + +\def\pgf@lib@dec@text@@@collectrestoftext#1\pgf@stop{\def\pgfdecorationrestoftext{#1}} + +{% + \catcode`\$3 % + \gdef\pgf@lib@dec@mathshift{$}% + \catcode`\$9 $% For editors with annoying syntax highlighting. +}% + +\def\pgf@lib@dec@text@dobox{% + \setbox\pgf@lib@dec@text@box\hbox{% + \pgfinterruptpicture% + \begingroup% + \pgfsetcolor{\pgf@lib@decorationtextcolor}% + \ifpgf@lib@decorate@textmathmode\pgf@lib@dec@mathshift\fi% + \pgf@lib@dec@text@format\relax% + \pgf@lib@dec@text@char% + \ifpgf@lib@decorate@textmathmode\pgf@lib@dec@mathshift\fi% + \endgroup% + \endpgfinterruptpicture% + }% +} + +\def\pgf@lib@dec@text@getwidth{% + \begingroup% + \let\c@pgf@lib@dec@characters=\c@pgf@counta% + \let\c@pgf@lib@dec@spaces=\c@pgf@countb% + \let\pgfdecorationrestoftext=\pgfdecorationtext% + \c@pgf@lib@dec@spaces=0\relax% + \c@pgf@lib@dec@characters=0\relax% + \pgfmathloop% + \pgf@lib@dec@text@scanchar% + \ifvoid\pgf@lib@dec@text@box% + \else% + \setbox\pgf@hbox=\hbox{{% + \unhbox\pgf@hbox% + \unhbox\pgf@lib@dec@text@box% + }}% + \advance\c@pgf@lib@dec@characters by1\relax% + \ifpgf@lib@dec@text@scan@space% + \advance\c@pgf@lib@dec@spaces by1\relax% + \fi% + \repeatpgfmathloop% + \global\pgf@x=\the\wd\pgf@hbox% + \xdef\pgf@lib@dec@temp{\the\c@pgf@lib@dec@characters}% + \xdef\pgf@lib@dec@@temp{\the\c@pgf@lib@dec@spaces}% + \endgroup% + \edef\pgf@lib@dec@text@width{\the\pgf@x}% + \let\pgf@lib@dec@character@count=\pgf@lib@dec@temp% + \let\pgf@lib@dec@space@count=\pgf@lib@dec@@temp% +} + + + +\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryarrows.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryarrows.code.tex index 9de07884dd5..d91a83b111f 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryarrows.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryarrows.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryarrows.code.tex,v 1.7 2007/06/07 07:41:11 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryarrows.code.tex,v 1.9 2008/10/27 21:00:46 tantau Exp $ % A square bracket shaped arrow @@ -228,6 +228,53 @@ } +% A square shaped arrow +\newdimen\arrowsize +\pgfarrowsdeclare{square}{square} +{ + \arrowsize=0.4pt + \advance\arrowsize by.275\pgflinewidth% + \pgfarrowsleftextend{+-\arrowsize} + \advance\arrowsize by.5\pgflinewidth + \pgfarrowsrightextend{+\arrowsize} +} +{ + \arrowsize=0.4pt + \advance\arrowsize by.275\pgflinewidth% + \pgfsetdash{}{+0pt} + \pgfsetroundjoin + \pgfpathmoveto{\pgfqpoint{1\arrowsize}{4\arrowsize}} + \pgfpathlineto{\pgfqpoint{-7\arrowsize}{4\arrowsize}} + \pgfpathlineto{\pgfqpoint{-7\arrowsize}{-4\arrowsize}} + \pgfpathlineto{\pgfqpoint{1\arrowsize}{-4\arrowsize}} + \pgfpathclose + \pgfusepathqfillstroke +} +% A open square shaped arrow + +\pgfarrowsdeclare{open square}{open square}%{{-.5bp}{8.5bp}} +{ + \arrowsize=0.4pt + \advance\arrowsize by.275\pgflinewidth% + \pgfarrowsleftextend{+-.5\pgflinewidth} + \advance\arrowsize by7\arrowsize + \advance\arrowsize by.5\pgflinewidth + \pgfarrowsrightextend{+\arrowsize} +} +{ + \arrowsize=0.4pt + \advance\arrowsize by.275\pgflinewidth% + \pgfsetdash{}{+0pt} + \pgfsetroundjoin + \pgfpathmoveto{\pgfqpoint{8\arrowsize}{4\arrowsize}} + \pgfpathlineto{\pgfqpoint{0\arrowsize}{4\arrowsize}} + \pgfpathlineto{\pgfqpoint{0\arrowsize}{-4\arrowsize}} + \pgfpathlineto{\pgfqpoint{8\arrowsize}{-4\arrowsize}} + \pgfpathclose + \pgfusepathqstroke +} + + % A triangle shaped arrow @@ -839,4 +886,46 @@ } + + + +% Mathematical arrows + + +% The arrow tip of an \implies arrow, to be used with an inner line. +% +% Example: +% +% \pgfsetarrow{-implies} +% \pgfsetlinewidth{1.8pt} +% \pgfsetinnerlinewidth{1pt} + +\pgfarrowsdeclare{implies}{implies} +{ + \pgfmathsetlength{\pgfutil@tempdima}{.25\pgflinewidth+.25*\pgfinnerlinewidth}% + \pgfmathsetlength{\pgfutil@tempdimb}{.5\pgflinewidth-.5*\pgfinnerlinewidth}% + \pgfarrowsrightextend{2\pgfutil@tempdima+.5\pgfutil@tempdimb} + \pgfarrowsleftextend{1.3\pgfutil@tempdima+.5\pgfutil@tempdimb} +} +{ + \pgfmathsetlength{\pgfutil@tempdima}{.25\pgflinewidth+.25*\pgfinnerlinewidth}% + \pgfmathsetlength{\pgfutil@tempdimb}{.5\pgflinewidth-.5*\pgfinnerlinewidth}% + \pgfsetlinewidth{\pgfutil@tempdimb} + \pgfsetdash{}{+0pt} + \pgfsetroundcap + \pgfsetroundjoin + \pgfpathmoveto{\pgfpoint{-1.4\pgfutil@tempdima}{2.65\pgfutil@tempdima}} + \pgfpathcurveto + {\pgfpoint{-0.75\pgfutil@tempdima}{1.25\pgfutil@tempdima}} + {\pgfpoint{1\pgfutil@tempdima}{0.05\pgfutil@tempdima}} + {\pgfpoint{2\pgfutil@tempdima}{0pt}} + \pgfpathcurveto + {\pgfpoint{1\pgfutil@tempdima}{-0.05\pgfutil@tempdima}} + {\pgfpoint{-.75\pgfutil@tempdima}{-1.25\pgfutil@tempdima}} + {\pgfpoint{-1.4\pgfutil@tempdima}{-2.65\pgfutil@tempdima}} + \pgfusepathqstroke +} + + + \endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.markings.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.markings.code.tex deleted file mode 100644 index b09975a9aef..00000000000 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.markings.code.tex +++ /dev/null @@ -1,114 +0,0 @@ -% Copyright 2008 by Mark Wibrow -% -% This file may be distributed and/or modified -% -% 1. under the LaTeX Project Public License and/or -% 2. under the GNU Public License. -% -% See the file doc/generic/pgf/licenses/LICENSE for more details. - -\usepgfmodule{decorations} - - -% A marking decoration is used to add markings (which are just pgf -% scopes, essentially) at certain positions of a path. - -\pgfkeys{ - /pgf/decoration/reset marks/.code=\let\pgf@lib@dec@mark@marks=\pgfutil@empty, - /pgf/decoration/mark/.code=\pgf@lib@dec@parsemark#1\pgf@lib@dec@stop, -} - -\let\pgf@lib@dec@mark@marks=\pgfutil@empty - -\def\pgf@lib@dec@parsemark at position#1with#2\pgf@lib@dec@stop{% - \expandafter\def\expandafter\pgf@lib@dec@mark@marks\expandafter{\pgf@lib@dec@mark@marks% - \pgf@lib@dec@domark{#1}{#2}% - }% -} - -\def\pgf@lib@dec@arrowhead#1#2{% - \expandafter\ifx\csname tikz@special@arrow@end#2\endcsname\relax% be nice to TikZ - \pgfsetarrowsend{#2} - \else% - \pgfsetarrowsend{\csname tikz@special@arrow@end#2\endcsname}% - \fi% - \pgf@x=0pt% - \pgf@shorten@end% - \pgftransformxshift{-\pgf@x} - \pgftransformxscale{#1} - \pgflowlevelsynccm% - \pgflowlevelobj{}{\pgf@endarrow}% -} - -\def\pgf@lib@dec@doarrowhead#1{% - \pgf@lib@dec@arrowhead{1}{#1}% -} -\def\pgf@lib@dec@doarrowheadrev#1{% - \pgf@lib@dec@arrowhead{-1}{#1}% -} - - -\pgfdeclaredecoration{markings}{pre} -{ - \state{pre} - [ - width=0pt, - persistent precomputation={% - \pgf@lib@dec@mark@marks\pgf@lib@dec@mark@last% - \let\arrow=\pgf@lib@dec@doarrowhead% - \let\arrowreversed=\pgf@lib@dec@doarrowheadrev% - }, - next state=skipper - ] - {} - - \state{skipper}[width=\pgf@lib@dec@computed@width-\pgfdecoratedcompleteddistance-1sp, - next state=\pgf@lib@dec@next@state]{} - - \state{main} - [ - width=1sp, - next state=pre - ] - {% - \pgfinterruptpath% - \pgfscope% - \let\pgf@lib@dec@mark@marks=\pgfutil@empty% - \pgf@lib@dec@computed@action% - \endpgfscope% - \endpgfinterruptpath% - }% - - \state{final}[width=\pgfdecoratedremainingdistance]{} -} - -\def\pgf@lib@dec@domark#1#2#3\pgf@lib@dec@mark@last{% - \def\pgf@lib@dec@mark@marks{#3}% - \pgf@lib@dec@parsenum{#1}% - \def\pgf@lib@dec@computed@action{#2}% - \def\pgf@lib@dec@next@state{main}% -} - -\def\pgf@lib@dec@parsenum#1{% - \pgfmathparse{#1}% - \ifpgfmathunitsdeclared% - \ifdim\pgfmathresult pt<0pt\relax% - \edef\pgf@lib@dec@computed@width{\pgfdecoratedpathlength\pgfmathresult pt}% - \else% - \edef\pgf@lib@dec@computed@width{\pgfmathresult pt}% - \fi% - \else% - \ifdim\pgfmathresult pt<0pt\relax% - \edef\pgf@lib@dec@computed@width{\pgfdecoratedpathlength\pgfmathresult*\pgfdecoratedpathlength}% - \else% - \edef\pgf@lib@dec@computed@width{\pgfmathresult*\pgfdecoratedpathlength}% - \fi% - \fi% -} - -\def\pgf@lib@dec@mark@last{% - \def\pgf@lib@dec@next@state{final}% -} - - -\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.text.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.text.code.tex deleted file mode 100644 index b773e36563c..00000000000 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarydecorations.text.code.tex +++ /dev/null @@ -1,233 +0,0 @@ -% Copyright 2008 by Mark Wibrow -% -% This file may be distributed and/or modified -% -% 1. under the LaTeX Project Public License and/or -% 2. under the GNU Public License. -% -% See the file doc/generic/pgf/licenses/LICENSE for more details. - -\usepgfmodule{decorations} - - -% Options for text decorations - -\pgfkeys{ - /pgf/decoration/.cd, - text/.store in=\pgfdecorationtext,% - text color/.store in=\pgf@lib@decorationtextcolor,% - text format delimiters/.code={\expandafter\pgfsetdecoratetextformatdelimiters#1} -} -\def\pgf@lib@decorationtextcolor{black} - -% Decorates a path with a text. The path is removed during this -% process - -\pgfdeclaredecoration{text along path}{initial}{ - \state{initial}[width=+0pt, - next state=scan, - persistent precomputation=\let\pgfdecorationrestoftext\pgfdecorationtext] - {} - \state{scan}[width=+0pt, - next state=before typeset, - persistent precomputation= - { - \pgf@lib@decorations@text@scanchar% - \ifvoid\pgf@lib@decorations@text@box% - \setbox\pgf@lib@decorations@text@box\hbox{}% - \wd\pgf@lib@decorations@text@box16383pt\relax% - \fi% - }] - {} - \state{before typeset}[width=+.5\wd\pgf@lib@decorations@text@box, next state=typeset]{} - \state{typeset}[width=+0pt, next state=after typeset] - { - \pgftransformxshift{+-.5\wd\pgf@lib@decorations@text@box}% - \setbox\pgf@hbox\hbox{\copy\pgf@lib@decorations@text@box}% - \pgfqboxsynced\pgf@hbox% - } - \state{after typeset}[width=+.5\wd\pgf@lib@decorations@text@box, next state=scan]{} - \state{final}{} -} - - -% \pgfsetdecoratetextformatdelimiters -% -% Set the delimiters for formatting in the text decoration. -% NB: Catcodes for delimiters should be 11 or 12. -% -% Examples: -% -% \pgfsetdecoratetextformatdelimiters{|}{}% 2nd argument can be empty. -% -% \def\pgfdecoratetext{A big |\color{red}|red|| apple.} -% -% \pgfsetdecoratetextformatdelimiters{[}{]} -% -% \def\pgfdecoratetext{The [\it]very[+\color{green}]green[] sprouts.} -% -\def\pgfsetdecoratetextformatdelimiters#1#2{% - \def\pgf@lib@decorations@text@formatchar{#1}% - \def\pgf@test{#2}% - \ifx\pgf@test\pgfutil@empty% - \def\pgf@lib@decorations@text@collectformat##1#1{% - \pgf@lib@decorations@text@@collectformat##1\pgf@stop}% - \else% - \def\pgf@lib@decorations@text@collectformat##1#2{% - \pgf@lib@decorations@text@@collectformat##1\pgf@stop}% - \fi% -} - -\pgfsetdecoratetextformatdelimiters{|}{} - -\newbox\pgf@lib@decorations@text@box -\newif\ifpgf@lib@decorate@textmathmode - -\let\pgfdecorationtext\pgfutil@empty -\let\pgfdecorationrestoftext\pgfutil@empty% -\let\pgf@lib@decorations@text@format\pgfutil@empty - -\def\pgf@lib@decorations@text@scanchar{% - \ifx\pgfdecorationrestoftext\pgfutil@empty% - \let\pgf@lib@decorations@text@char\pgfutil@empty% - \setbox\pgf@lib@decorations@text@box\box\voidb@x% - \let\pgf@next\relax% - \else% - \let\pgf@next\pgf@lib@decorations@text@@scanchar% - \fi% - \pgf@next} - -\def\pgf@lib@decorations@text@@scanchar{% - \expandafter\pgf@lib@decorations@text@@@scanchar\pgfdecorationrestoftext\pgf@stop} - -\def\pgf@lib@decorations@text@@@scanchar{% - \futurelet\pgf@lib@decorations@lettoken% - \pgf@lib@decorations@text@@@@scanchar} - -\def\pgf@lib@decorations@text@@@@scanchar{% - \ifx\pgf@lib@decorations@lettoken\pgfutil@sptoken% - \let\pgf@next\pgf@lib@decorations@text@insertspace% - \else% - \let\pgf@next\pgf@lib@decorations@text@@@@@scanchar% - \fi% - \pgf@next} - -\def\pgf@lib@decorations@text@@@@@scanchar{% - \pgfutil@ifnextchar\bgroup{\pgf@lib@decorations@text@collectgroup}% - {\pgf@lib@decorations@text@@@@@@scanchar}} - -\def\pgf@lib@decorations@text@collectgroup#1{% - \def\pgf@lib@decorations@text@char{#1}% - \pgf@lib@decorations@text@collectrestoftext} - -\def\pgf@lib@decorations@text@@@@@@scanchar#1{% - \ifx#1\pgf@stop% - \pgf@lib@decorations@text@box\box\voidb@x% - \let\pgf@next\pgf@lib@decorations@text@endoftext% - \else% - \def\pgf@lib@decorations@text@char{#1}% - \ifx#1\space% - \let\pgf@next\pgf@lib@decorations@text@collectrestoftext% - \else% - \ifx#1\ % - \let\pgf@next\pgf@lib@decorations@text@collectrestoftext% - \else% - \ifx\pgf@lib@decorations@text@char\pgf@lib@decorations@text@formatchar% - \let\pgf@next\pgf@lib@decorations@text@collectformat% - \else% - \expandafter\ifcat\noexpand#1\relax% - \let\pgf@next\pgf@lib@decorations@text@expandcs% - \else% - \ifnum\catcode`#1=3\relax% - \ifpgf@lib@decorate@textmathmode% - \pgf@lib@decorate@textmathmodefalse% - \else% - \pgf@lib@decorate@textmathmodetrue% - \fi% - \let\pgf@next\pgf@lib@decorations@text@@@scanchar% - \else% - \let\pgf@next\pgf@lib@decorations@text@collectrestoftext% - \fi% - \fi% - \fi% - \fi% - \fi% - \fi% - \pgf@next% -} - -\def\pgf@lib@decorations@text@@collectformat{% - \pgfutil@ifnextchar+{\pgf@lib@decorations@text@addtoformat}{\pgf@lib@decorations@text@setformat}} - -\def\pgf@lib@decorations@text@setformat#1\pgf@stop{% - \def\pgf@lib@decorations@text@format{#1}% - \pgf@lib@decorations@text@@@scanchar% -} - -\def\pgf@lib@decorations@text@addtoformat+#1\pgf@stop{% - \expandafter\def\expandafter\pgf@lib@decorations@text@format\expandafter{\pgf@lib@decorations@text@format#1}% - \pgf@lib@decorations@text@@@scanchar% -} - -\def\pgf@lib@decorations@text@insertspace{% - \pgfutil@ifnextchar\bgroup{\pgf@lib@decorations@text@@insertspacegrp}% - {\pgf@lib@decorations@text@@insertspace}} - -\def\pgf@lib@decorations@text@@insertspacegrp#1{% - \pgf@lib@decorations@text@@@@@@scanchar\space{#1}} - -\def\pgf@lib@decorations@text@@insertspace#1{% - \pgf@lib@decorations@text@@@@@@scanchar\space#1} - -\def\pgf@lib@decorations@text@expandcs{% - \expandafter\expandafter\expandafter\pgf@lib@decorations@text@@@@@scanchar% - \pgf@lib@decorations@text@char} - -\def\pgf@lib@decorations@text@endoftext{% - \let\pgfdecoraterestoftext\pgfutil@empty% - \let\pgf@lib@decorations@text@char\pgfutil@empty% -} -\def\pgf@lib@decorations@text@collectrestoftext{% - \pgf@lib@decorations@text@dobox% - \futurelet\pgf@lib@decorations@text@lettoken% - \pgf@lib@decorations@text@@collectrestoftext} - -\def\pgf@lib@decorations@text@@collectrestoftext{% - \ifx\bgroup\pgf@lib@decorations@text@lettoken% - \let\pgf@next\pgf@lib@decorations@text@@@collectrestoftextgrp% - \else% - \let\pgf@next\pgf@lib@decorations@text@@@collectrestoftext% - \fi% - \pgf@next} - -\def\pgf@lib@decorations@text@@@collectrestoftextgrp#1#2\pgf@stop{\def\pgfdecorationrestoftext{{#1}#2}% -} - -\def\pgf@lib@decorations@text@@@collectrestoftext#1\pgf@stop{\def\pgfdecorationrestoftext{#1}} - -{% - \catcode`\$3 % - \gdef\pgf@lib@decorations@mathshift{$}% - \catcode`\$9 $% For editors with annoying syntax highlighting. -}% - -\def\pgf@lib@decorations@text@dobox{% - \setbox\pgf@lib@decorations@text@box\hbox{% - \pgfinterruptpicture% - \begingroup% - \pgfsetcolor{\pgf@lib@decorationtextcolor}% - \ifpgf@lib@decorate@textmathmode\pgf@lib@decorations@mathshift\fi% - \pgf@lib@decorations@text@format\relax% - \pgf@lib@decorations@text@char% - \ifpgf@lib@decorate@textmathmode\pgf@lib@decorations@mathshift\fi% - \endgroup% - \endpgfinterruptpicture% - }% -} - - - - - - -\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryfixedpointarithmetic.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryfixedpointarithmetic.code.tex new file mode 100644 index 00000000000..240eddf4435 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryfixedpointarithmetic.code.tex @@ -0,0 +1,637 @@ +% Copyright 2006 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + + +\pgfkeys{/pgf/.cd, + fixed point arithmetic/.code={% + \pgfmathfp@plots@install% + \pgfmathfp@parser@install% + \let\pgfmathparse=\pgfmathfpparse% + \pgfkeys{/pgf/fixed point/.cd, #1}% + },% + fixed point/.cd, + scale results/.code={% + \pgfmathfpparse{#1}% + \let\pgfmathfpscale=\pgfmathresult% + }% +} + +\def\pgfmathfpscale{1} + +\def\pgfmathfpparse{% + \begingroup% + \let\pgfmathpostparse=\relax% + \pgfmath@catcodes% + \pgfmath@quickparsefalse% + \pgfmathfpparse@} + +\def\pgfmathfpparse@#1{% + \edef\pgfmathfp@expression{#1}% + \expandafter\pgfmathfpparse@@\pgfmathfp@expression\pgfmathfp@} + +\def\pgfmathfp@char@asterisk{*} +\def\pgfmathfpparse@@#1#2\pgfmathfp@{% + \def\pgfmathfp@test{#1}% + \ifx\pgfmathfp@test\pgfmathfp@char@asterisk% + \edef\pgfmathfp@expression{\pgfmathfpscale#1#2}% + \else% + \edef\pgfmathfp@expression{#1#2}% + \fi% + \expandafter\pgfmathparse@\expandafter{\pgfmathfp@expression}% + % \endgroup provided by \pgfpathmarse@end +} + +% Crude handling of file plots +% +\pgfkeys{/pgf/fixed point/.cd, + scale file plot x/.code=\pgfmathfpparse{#1}\edef\pgfmathfpplotscalex{\pgfmathresult*}, + scale file plot y/.code=\pgfmathfpparse{#1}\edef\pgfmathfpplotscaley{\pgfmathresult*}, + scale file plot z/.code=\pgfmathfpparse{#1}\edef\pgfmathfpplotscalez{\pgfmathresult*} +} + +\def\pgfmathfp@plots@install{% + \let\pgfmathfpplotscalex=\pgfutil@empty + \let\pgfmathfpplotscaley=\pgfutil@empty + \let\pgfmathfpplotscalez=\pgfutil@empty + \let\pgf@parsexyline=\pgfmathfp@parsexyline% + \let\pgf@parsexyzline=\pgfmathfp@parsexyzline% +} + +\def\pgfmathfp@parsexyline#1 #2 #3\pgf@stop{% + \edef\pgfmathfp@marshal{% + \noexpand\pgfplotstreampoint{\noexpand\pgfpointxy{\pgfmathfpplotscalex#1}{\pgfmathfpplotscaley#2}}% + }% + \pgfmathfp@marshal% +} + +\def\pgfmathfp@parsexyzline#1 #2 #3 #4\pgf@stop{% + \edef\pgfmathfp@marshal{% + \noexpand\pgfplotstreampoint{% + \noexpand\pgfpointxyz{\pgfmathfpplotscalex#1}{\pgfmathfpplotscaley#2}{\pgfmathfpplotscalez#3}% + }% + }% + \pgfmathfp@marshal% +} + +% +\def\pgfmathfp@parser@install{% + % + \expandafter\ifx\csname FP@version\endcsname\relax% + \PackageError{pgf}{You need to say `\string\usepackage{fp}' to use % + fixed point arithmetic}{}% + \else% + % + % Don't want messages. + % + \FPmessagesfalse% + \FPdebugfalse% + % + % Install float commands... + % + \let\pgfmathadd@=\pgfmathfpadd@% + \let\pgfmathsubtract@=\pgfmathfpsubtract@% + \let\pgfmathmultiply@=\pgfmathfpmultiply@% + \let\pgfmathdivide@=\pgfmathfpdivide@% + \let\pgfmathabs@=\pgfmathfpabs@% + \let\pgfmathround@=\pgfmathfpround@% + \let\pgfmathfloor@=\pgfmathfpfloor@% + \let\pgfmathceil@=\pgfmathfpceil@% + \let\pgfmathmod@=\pgfmathfpmod@% + \let\pgfmathmax@=\pgfmathfpmax@% + \let\pgfmathmin@=\pgfmathfpmin@% + \let\pgfmathsin@=\pgfmathfpsin@% + \let\pgfmathcos@=\pgfmathfpcos@% + \let\pgfmathtan@=\pgfmathfptan@% + \let\pgfmathdeg@=\pgfmathfpdeg@% + \let\pgfmathrad@=\pgfmathfprad@% + \let\pgfmathatan@=\pgfmathfpatan@% + \let\pgfmathasin@=\pgfmathfpasin@% + \let\pgfmathacos@=\pgfmathfpacos@% + \let\pgfmathcot@=\pgfmathfpcot@% + \let\pgfmathsec@=\pgfmathfpsec@% + \let\pgfmathcosec@=\pgfmathfpcosec@% + \let\pgfmathpow@=\pgfmathfppow@% + \let\pgfmathexp@=\pgfmathfpexp@% + \let\pgfmathln@=\pgfmathfpln@% + \let\pgfmathsqrt@=\pgfmathfpsqrt@% + \let\pgfmath@pi=\pgfmathfppi@% + \let\pgfmathveclen@=\pgfmathfpveclen@% + \let\pgfmathe@=\pgfmathfpe@% + % + \let\pgfmathlessthan@=\pgfmathfplessthan@% + \let\pgfmathgreaterthan@=\pgfmathfpgreaterthan@% + \let\pgfmathequalto@=\pgfmathfpequalto@% + % + \let\pgfmathrnd=\pgfmathfprnd% + \let\pgfmathrand=\pgfmathfprand% + \let\pgfmathsetseed=\pgfmathfpsetseed% + % + \let\pgfmathscientific=\pgfmathfpscientific% + \fi% +}% + +\def\pgfmathfpe@{let\pgfmathresult=\FPe}% +\def\pgfmathfppi@{let\pgfmathresult=\FPpi}% + + +% Scientific notation. + +\def\pgfmathfpscientific#1#2{% + \begingroup% + \FPpow\pgfmathresult{10}{#2}\unskip% Needed. + \FPmul\pgfmathresult{#1}{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% Comparison stuff... + +% lessthan +% +\def\pgfmathfplessthan#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfplessthan@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfplessthan@#1#2{% + \begingroup% + \FPiflt{#1}{#2}% + \def\pgfmathresult{1.0}% + \else% + \def\pgfmathresult{0.0}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% greaterthan +% +\def\pgfmathfpgreaterthan#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpgreaterthan@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpgreaterthan@#1#2{% + \begingroup% + \FPifgt{#1}{#2}% + \def\pgfmathresult{1.0}% + \else% + \def\pgfmathresult{0.0}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% equalto +% +\def\pgfmathfpequalto#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpequalto@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpequalto@#1#2{% + \begingroup% + \FPifeq{#1}{#2}% + \def\pgfmathresult{1.0}% + \else% + \def\pgfmathresult{0.0}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + + +% Basic arithmetic stuff... + +% add +% +\def\pgfmathfpadd#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpadd@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpadd@#1#2{% + \begingroup% + \FPadd\pgfmathresult{#1}{#2}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% subtract +% +\def\pgfmathfpsubtract#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpsubtract@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpsubtract@#1#2{% + \begingroup% + \FPsub\pgfmathresult{#1}{#2}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% multiply +% +\def\pgfmathfpmultiply#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpmultiply@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpmultiply@#1#2{% + \begingroup% + \FPmul\pgfmathresult{#1}{#2}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% divide +% +\def\pgfmathfpdivide#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpdivide@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpdivide@#1#2{% + \begingroup% + \FPdiv\pgfmathresult{#1}{#2}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% abs +% +\def\pgfmathfpabs#1{% + \pgfmathfpparse{#1}% + \pgfmathfpabs@{\pgfmathresult}% +} +\def\pgfmathfpabs@#1{% + \begingroup% + \FPabs\pgfmathresult{#1} + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% round +% +\def\pgfmathfpround#1{% + \pgfmathfpparse{#1}% + \pgfmathfpround@{\pgfmathresult}% +} +\def\pgfmathfpround@#1{% + \begingroup% + \FPround\pgfmathresult{#1}{0}% + \edef\pgfmathresult{\pgfmathresult.0}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% floor +% +\def\pgfmathfpfloor#1{% + \pgfmathfpparse{#1}% + \pgfmathfpfloor@{\pgfmathresult}% +} +\def\pgfmathfpfloor@#1{% + \begingroup% + \FPtrunc\pgfmathresult{#1}{0}% + \FPifneg{#1}% + \FPsub\pgfmathresult{\pgfmathresult}{1}% + \fi% + \edef\pgfmathresult{\pgfmathresult.0}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% ceil +% +\def\pgfmathfpceil#1{% + \pgfmathfpparse{#1}% + \pgfmathfpceil@{\pgfmathresult}% +} +\def\pgfmathfpceil@#1{% + \begingroup% + \FPtrunc\pgfmathresult{#1}{0}% + \FPifpos{#1}% + \FPadd\pgfmathresult{\pgfmathresult}{1}% + \fi% + \edef\pgfmathresult{\pgfmathresult.0}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% mod +% +\def\pgfmathfpmod#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpmod@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpmod@#1#2{% + \begingroup% + \FPdiv\pgfmathresult{#1}{#2}% + \FPtrunc\pgfmathresult{\pgfmathresult}{0}% + \FPmul\pgfmathresult{\pgfmathresult}{#2}% + \FPsub\pgfmathresult{#1}{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% max +% +\def\pgfmathfpmax#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpmax@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpmax@#1#2{% + \begingroup% + \FPifgt{#1}{#2}% + \def\pgfmathresult{#1}% + \else% + \def\pgfmathresult{#2}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% min +% +\def\pgfmathfpmin#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpmin@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpmin@#1#2{% + \begingroup% + \FPiflt{#1}{#2}% + \def\pgfmathresult{#1}% + \else% + \def\pgfmathresult{#2}% + \fi% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% Functions... + +% pow +% +\def\pgfmathfppow#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfppow@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfppow@#1#2{% + \begingroup% + \FPpow\pgfmathresult{#1}{#2}\unskip% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% exp +% +\def\pgfmathfpexp#1{% + \pgfmathfpparse{#1}% + \pgfmathfpexp@{\pgfmathresult}% +} +\def\pgfmathfpexp@#1{% + \begingroup% + \FPexp\pgfmathresult{#1}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% ln +% +\def\pgfmathfpln#1{% + \pgfmathfpparse{#1}% + \pgfmathfpln@{\pgfmathresult}% +} +\def\pgfmathfpln@#1{% + \begingroup% + \FPln\pgfmathresult{#1}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% sqrt +% +\def\pgfmathfpsqrt#1{% + \pgfmathfpparse{#1}% + \pgfmathfpsqrt@{\pgfmathresult}% +} +\def\pgfmathfpsqrt@#1{% + \begingroup% + \FProot\pgfmathresult{#1}{2}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% veclen +% +\def\pgfmathfpveclen#1#2{% + \pgfmathfpparse{#2}\let\pgfmath@result=\pgfmathresult% + \pgfmathfpparse{#1}% + \pgfmathfpveclen@{\pgfmathresult}{\pgfmath@result}% +} +\def\pgfmathfpveclen@#1#2{% + \begingroup% + \FPmul\pgfmath@result{#1}{#1}% + \FPmul\pgfmath@@result{#2}{#2}% + \FPadd\pgfmathresult{\pgfmath@result}{\pgfmath@@result}% + \FProot\pgfmathresult{\pgfmathresult}{2}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% Trigonometric stuff... + +% sin +% +\def\pgfmathfpsin#1{% + \pgfmathfpparse{#1}% + \pgfmathfpsin@{\pgfmathresult}% +} +\def\pgfmathfpsin@#1{% + \begingroup% + \FPmul\pgfmathresult{#1}{0.017453292519943295}% + \FPsin\pgfmathresult{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% cos +% +\def\pgfmathfpcos#1{% + \pgfmathfpparse{#1}% + \pgfmathfpcos@{\pgfmathresult}% +} +\def\pgfmathfpcos@#1{% + \begingroup% + \FPmul\pgfmathresult{#1}{0.017453292519943295}% + \FPcos\pgfmathresult{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% tan +% +\def\pgfmathfptan#1{% + \pgfmathfpparse{#1}% + \pgfmathfptan@{\pgfmathresult}% +} +\def\pgfmathfptan@#1{% + \begingroup% + \FPmul\pgfmathresult{#1}{0.017453292519943295}% + \FPtan\pgfmathresult{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% acos +% +\def\pgfmathfpacos#1{% + \pgfmathfpparse{#1}% + \pgfmathfpacos@{\pgfmathresult}% +} +\def\pgfmathfpacos@#1{% + \begingroup% + \FParccos\pgfmathresult{#1}% + \FPmul\pgfmathresult{\pgfmathresult}{57.295779513082320885}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% asin +% +\def\pgfmathfpasin#1{% + \pgfmathfpparse{#1}% + \pgfmathfpasin@{\pgfmathresult}% +} +\def\pgfmathfpasin@#1{% + \begingroup% + \FParcsin\pgfmathresult{#1}% + \FPmul\pgfmathresult{\pgfmathresult}{57.295779513082320885}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% atan +% +\def\pgfmathfpatan#1{% + \pgfmathfpparse{#1}% + \pgfmathfpatan@{\pgfmathresult}% +} +\def\pgfmathfpatan@#1{% + \begingroup% + \FParctan\pgfmathresult{#1}% + \FPmul\pgfmathresult{\pgfmathresult}{57.295779513082320885}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% cot +% +\def\pgfmathfpcot#1{% + \pgfmathfpparse{#1}% + \pgfmathfpcot@{\pgfmathresult}% +} +\def\pgfmathfpcot@#1{% + \begingroup% + \FPmul\pgfmathresult{#1}{0.017453292519943295}% + \FPcot\pgfmathresult{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% sec +% +\def\pgfmathfpsec#1{% + \pgfmathfpparse{#1}% + \pgfmathfpsec@{\pgfmathresult}% +} +\def\pgfmathfpsec@#1{% + \begingroup% + \FPmul\pgfmathresult{#1}{0.017453292519943295}% + \FPcos\pgfmathresult{\pgfmathresult}% + \FPdiv\pgfmathresult{1}{\pgfmathresult} + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% cosec +% +\def\pgfmathfpcosec#1{% + \pgfmathfpparse{#1}% + \pgfmathfpcosec@{\pgfmathresult}% +} +\def\pgfmathfpcosec@#1{% + \begingroup% + \FPmul\pgfmathresult{#1}{0.017453292519943295}% + \FPsin\pgfmathresult{\pgfmathresult}% + \FPdiv\pgfmathresult{1}{\pgfmathresult} + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% deg +% +\def\pgfmathfpdeg#1{% + \pgfmathfpparse{#1}% + \pgfmathfpdeg@{\pgfmathresult}% +} +\def\pgfmathfpdeg@#1{% + \begingroup% + \FPmul\pgfmathresult{#1}{57.295779513082320885}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% rad +% +\def\pgfmathfprad#1{% + \pgfmathfpparse{#1}% + \pgfmathfprad@{\pgfmathresult}% +} +\def\pgfmathfprad@#1{% + \begingroup% + \FPmul\pgfmathresult{#1}{0.01745329251994325}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% Random stuff... + +\def\pgfmathfpsetseed#1{% + \pgfmathfpparse{#1}% + \afterassignment\pgfmath@gobbletilpgfmath@% + \FPseed\pgfmathresult\relax\pgfmath@% +} + +% rnd +% +\def\pgfmathfprnd{% + \begingroup% + \FPrandom\pgfmathresult% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + +% rand +% +\def\pgfmathfprand{% + \begingroup% + \FPrandom\pgfmathresult% + \FPmul\pgfmathresult{2}{\pgfmathresult}% + \FPsub\pgfmathresult{\pgfmathresult}{1}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +} + diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryfpu.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryfpu.code.tex new file mode 100644 index 00000000000..cecc76d593e --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryfpu.code.tex @@ -0,0 +1,1965 @@ +% Copyright 2008/2009 by Christian Feuersaenger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU General Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\newif\ifpgfmathfloatparseactive +\newif\ifpgfmathfloat@scaleactive + +% public macro which invokes '#1' if the fpu is installed and ready and '#2' +% otherwise. +\def\pgflibraryfpuifactive#1#2{% + \ifpgfmathfloatparseactive + #1% + \else + #2% + \fi +}% + +\pgfqkeys{/pgf}{ + % enable the FPU parser if it is not yet active + % + % It will be deactivated after the current TeX group + fpu/.is choice, + fpu/true/.code={% + \ifpgfmathfloatparseactive + \else + \pgfutil@ifundefined{pgfmathdeclarefunction}{% + % Ohoh - we are running on a TeX distribution with + % PGF 2.00 which doesn't have the new math engine. + % I can provide special treatment here, provided that + % all float commands are still able to run (that means + % more information needs to be copied from the pgf cvs + % to pgf 2.00 - for example pgfmathfloat.code.tex). + % + % I employ this to work with pgfplots and pgf 2.00 + % using all new features. + \pgfmathfloat@parser@install@pgf@two@null@null% + }{% + \pgfmathfloat@parser@install% + }% + \pgfmathfloatparseactivetrue + % improve compatibility with Marks FP library: + \pgfkeysalso{/pgf/fixed point arithmetic/.prefix style={/pgf/fpu=false}}% + \fi + },% + fpu/false/.code={% + \ifpgfmathfloatparseactive + \pgfmathfloat@uninstall% + \pgfmathfloatparseactivefalse + \fi + },% + fpu/.default=true, + % Use this to introduce a result scaling. + % Every expression in which the prefix '*' occurs + % will be multiplied with the result and converted to fixed point + % representation. + fpu/scale results/.code={% + \ifpgfmathfloatparseactive + \pgfmathparse{#1}% + \else + \pgfmathfloatparsenumber{#1}% + \fi + \let\pgfmathfloatscale=\pgfmathresult% + },% + % determines the output format of each complete expression parsing + % process. If 'scale results' is active, 'fixed' is assumed + % automatically. + fpu/output format/.is choice, + fpu/output format/float/.code= {\let\pgfmathfloatparse@output=\relax}, + fpu/output format/sci/.code= {\def\pgfmathfloatparse@output{\pgfmathfloattosci@{\pgfmathresult}}}, + fpu/output format/fixed/.code= {\def\pgfmathfloatparse@output{\pgfmathfloattofixed@{\pgfmathresult}}}, + fpu/output format/float, + fpu/rel thresh/.code={% + \pgfmathfloatparsenumber{#1}% + \let\pgfmathfloat@relthresh=\pgfmathresult + }, + fpu/rel thresh=1e-4, +} + +\pgfmathfloatcreate{1}{1.0}{0}\let\pgfmathfloatscale=\pgfmathresult + +% This is the replacement parser invocation. +% It does two things which are different to \pgfmathparse: +% 1. it disables any dimension dependand scalings, +% 2. it implements the 'scale results' feature. +\def\pgfmathfloatparse{% + \begingroup% + % disable any dimension-dependant scalings: + \let\pgfmathpostparse=\relax% + \pgfmath@catcodes% + \pgfmath@quickparsefalse% + \pgfmathfloatparse@} + +% for pgf 2.00 : +\def\pgfmathfloatparse@pgf@two@null@null{% + \pgfmath@quickparsefalse% + \pgfmathfloatparse@} + +\def\pgfmathfloatparse@#1{% + \edef\pgfmathfloat@expression{#1}% + \expandafter\pgfmathfloatparse@@\pgfmathfloat@expression\pgfmathfloat@ + \ifpgfmathfloat@scaleactive + \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfmathfloatscale} + \pgfmathfloattofixed{\pgfmathresult}% + \else + \pgfmathfloatparse@output + \fi +} + +\def\pgfmathfloat@char@asterisk{*} +\def\pgfmathfloatparse@@#1#2\pgfmathfloat@{% + \def\pgfmathfloat@test{#1}% + \ifx\pgfmathfloat@test\pgfmathfloat@char@asterisk% + \def\pgfmathfloat@expression{#2}% + \pgfmathfloat@scaleactivetrue + \fi% + \expandafter\pgfmathparse@\expandafter{\pgfmathfloat@expression}% + % \endgroup provided by \pgfpathmarse@end +} + +% Crude handling of file plots +% +\pgfkeys{/pgf/fpu/.cd, + scale file plot x/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscalex{\pgfmathresult*}, + scale file plot y/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscaley{\pgfmathresult*}, + scale file plot z/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscalez{\pgfmathresult*} +} + +\def\pgfmathfloat@uninstall@appendcmd#1{% + \expandafter\gdef\expandafter\pgfmathfloat@uninstall\expandafter{\pgfmathfloat@uninstall #1}% +}% + +% If the uninstall command is already assembled, it will skip the +% uninstall assemblation. +\def\pgfmathfloat@plots@checkuninstallcmd{% + \pgfutil@ifundefined{pgfmathfloat@uninstall}{% + \global\let\pgfmathfloat@uninstall=\pgfutil@empty + }{% + % We already HAVE an uninstall command (prepared globally). + % So: don't waste time assembling one! + \def\pgfmathfloat@uninstall@appendcmd##1{}% + \def\pgfmathfloat@prepareuninstallcmd##1{}% + }% +}% + +% This assembles an uninstall command globally ON FIRST USAGE. +% See \pgfmathfloat@plots@checkuninstallcmd +\def\pgfmathfloat@prepareuninstallcmd#1{% + % and store backup information (globally - I don't want to do that + % all the time when the FPU is used!): + \expandafter\global\expandafter\let\csname pgfmathfloat@backup@\string#1\endcsname=#1% + \expandafter\gdef\expandafter\pgfmathfloat@uninstall\expandafter{\pgfmathfloat@uninstall + \expandafter\let\expandafter#1\csname pgfmathfloat@backup@\string#1\endcsname% + }% +} + +\def\pgfmathfloat@install#1=#2{% + \pgfmathfloat@prepareuninstallcmd{#1}% + \let#1=#2% +} +\def\pgfmathfloat@install@unimplemented#1{% + \expandafter\pgfmathfloat@prepareuninstallcmd\csname pgfmath@#1@\endcsname% + \expandafter\def\csname pgfmath#1@\endcsname##1{\pgfmathfloat@notimplemented{#1}}% +} +\def\pgfmathfloat@plots@install{% + \let\pgfmathfloatplotscalex=\pgfutil@empty + \let\pgfmathfloatplotscaley=\pgfutil@empty + \let\pgfmathfloatplotscalez=\pgfutil@empty + \pgfmathfloat@install\pgf@parsexyline=\pgfmathfloat@parsexyline% + \pgfmathfloat@install\pgf@parsexyzline=\pgfmathfloat@parsexyzline% +} +\def\pgfmathfloat@parsexyline#1 #2 #3\pgf@stop{% + \edef\pgfmathfloat@marshal{% + \noexpand\pgfplotstreampoint{\noexpand\pgfpointxy{\pgfmathfloatplotscalex#1}{\pgfmathfloatplotscaley#2}}% + }% + \pgfmathfloat@marshal% +} +\def\pgfmathfloat@parsexyzline#1 #2 #3 #4\pgf@stop{% + \edef\pgfmathfloat@marshal{% + \noexpand\pgfplotstreampoint{% + \noexpand\pgfpointxyz{\pgfmathfloatplotscalex#1}{\pgfmathfloatplotscaley#2}{\pgfmathfloatplotscalez#3}% + }% + }% + \pgfmathfloat@marshal% +} + +% +\def\pgfmathfloat@parser@install@functions{% + % Install float commands... + % + \pgfmathfloat@install\pgfmathadd@=\pgfmathfloatadd@% + \pgfmathfloat@install\pgfmathsubtract@=\pgfmathfloatsubtract@% + \pgfmathfloat@install\pgfmathneg@=\pgfmathfloatneg@% + \pgfmathfloat@install\pgfmathmultiply@=\pgfmathfloatmultiply@% + \pgfmathfloat@install\pgfmathdivide@=\pgfmathfloatdivide@% + \pgfmathfloat@install\pgfmathabs@=\pgfmathfloatabs@% + \pgfmathfloat@install\pgfmathround@=\pgfmathfloatround@% + \pgfmathfloat@install\pgfmathfloor@=\pgfmathfloatfloor@% + \pgfmathfloat@install\pgfmathmod@=\pgfmathfloatmod@% + \pgfmathfloat@install\pgfmathmax@=\pgfmathfloatmax@% + \pgfmathfloat@install\pgfmathmin@=\pgfmathfloatmin@% + \pgfmathfloat@install\pgfmathsin@=\pgfmathfloatsin@% + \pgfmathfloat@install\pgfmathcos@=\pgfmathfloatcos@% + \pgfmathfloat@install\pgfmathtan@=\pgfmathfloattan@% + \pgfmathfloat@install\pgfmathdeg@=\pgfmathfloatdeg@% + \pgfmathfloat@install\pgfmathrad@=\pgfmathfloatrad@% + \pgfmathfloat@install\pgfmathatan@=\pgfmathfloatatan@% + \pgfmathfloat@install\pgfmathasin@=\pgfmathfloatasin@% + \pgfmathfloat@install\pgfmathacos@=\pgfmathfloatacos@% + \pgfmathfloat@install\pgfmathcot@=\pgfmathfloatcot@% + \pgfmathfloat@install\pgfmathsec@=\pgfmathfloatsec@% + \pgfmathfloat@install\pgfmathcosec@=\pgfmathfloatcosec@% + \pgfmathfloat@install\pgfmathexp@=\pgfmathfloatexp@% + \pgfmathfloat@install\pgfmathln@=\pgfmathfloatln@% + \pgfmathfloat@install\pgfmathsqrt@=\pgfmathfloatsqrt@% + \pgfmathfloat@install\pgfmath@pi=\pgfmathfloatpi@% + \pgfmathfloat@install\pgfmathpi=\pgfmathfloatpi@% + \pgfmathfloat@install\pgfmathe@=\pgfmathfloate@% + \pgfmathfloat@install\pgfmathe=\pgfmathfloate@% + \pgfmathfloat@install\pgfmathlessthan@=\pgfmathfloatlessthan@% + \pgfmathfloat@install\pgfmathless@=\pgfmathfloatlessthan@% + \pgfmathfloat@install\pgfmathgreaterthan@=\pgfmathfloatgreaterthan@% + \pgfmathfloat@install\pgfmathgreater@=\pgfmathfloatgreaterthan@% + \pgfmathfloat@install\pgfmathpow@=\pgfmathfloatpow@ + \pgfmathfloat@install\pgfmathrand@=\pgfmathfloatrand@ + \pgfmathfloat@install\pgfmathrand=\pgfmathfloatrand@ + \pgfmathfloat@install\pgfmathrnd@=\pgfmathfloatrnd@ + \pgfmathfloat@install\pgfmathrnd=\pgfmathfloatrnd@ + \pgfmathfloat@install\pgfmathtrue@=\pgfmathfloattrue@ + \pgfmathfloat@install\pgfmathfalse@=\pgfmathfloatfalse@ + \pgfmathfloat@install\pgfmathnot@=\pgfmathfloatnot@ + \pgfmathfloat@install\pgfmathhex@=\pgfmathfloathex@ + \pgfmathfloat@install\pgfmathHex@=\pgfmathfloatHex@ + \pgfmathfloat@install\pgfmathoct@=\pgfmathfloatoct@ + \pgfmathfloat@install\pgfmathbin@=\pgfmathfloatbin@ + \pgfmathfloat@install\pgfmathand@=\pgfmathfloatand@ + \pgfmathfloat@install\pgfmathor@=\pgfmathfloator@ + \pgfmathfloat@install\pgfmathfactorial@=\pgfmathfloatfactorial@ + \pgfmathfloat@install\pgfmathveclen@=\pgfmathfloatveclen@ + \pgfmathfloat@install\pgfmathcosh@=\pgfmathfloatcosh@ + \pgfmathfloat@install\pgfmathsinh@=\pgfmathfloatsinh@ + \pgfmathfloat@install\pgfmathtanh@=\pgfmathfloattanh@ + \pgfmathfloat@install@unimplemented{ceil}% + \pgfmathfloat@install@unimplemented{frac}% + \pgfmathfloat@install@unimplemented{log2}% + \pgfmathfloat@install@unimplemented{log10}% + \pgfmathfloat@install@unimplemented{equalto}% + \pgfmathfloat@install@unimplemented{random}% + \pgfmathfloat@install@unimplemented{setseed}% + \pgfmathfloat@install@unimplemented{Mod}% + \pgfmathfloat@install@unimplemented{real}% + \pgfmathfloat@install@unimplemented{notequal}% +% \pgfmathfloat@install@unimplemented{atan2}% +% \pgfmathfloat@install@unimplemented{height}% + % + % + \pgfmathfloat@install\pgfmathscientific=\pgfmathfloatscientific% +} + +\def\pgfmathfloat@parser@install{% + \pgfmathfloat@plots@checkuninstallcmd + \pgfmathfloat@plots@install% + \pgfmathfloat@parser@install@functions + % + % + % + % The following methods actually enable the parser to work with + % the internal floating point number representation. + % + % The idea is as follows: + % 1. Every operand must be given in internal float representation. + % 2. The internal float repr can be distinguished by a normal + % number. This is accomplished by introducing a new "exponent" + % token. + % 3. The stack-push-operation checks whether the argument is a + % float. If not, it is parsed properly before pushing it. + \pgfmath@tokens@make{exponent}{\pgfmathfloat@POSTFLAGSCHAR}% + \pgfmathfloat@uninstall@appendcmd{% + \expandafter\let\csname pgfmath@token@exponent@\pgfmathfloat@POSTFLAGSCHAR\endcsname=\relax + }% + \let\pgfmath@basic@parse@exponent=\pgfmath@parse@exponent% + \let\pgfmath@basic@stack@push@operand=\pgfmath@stack@push@operand + \pgfmathfloat@install\pgfmath@stack@push@operand=\pgfmathfloat@stack@push@operand + \pgfmathfloat@install\pgfmath@parse@exponent=\pgfmathfloat@parse@float@or@exponent + % + \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse% +}% + +\def\pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG#1{% + \edef\pgfmathfloat@loc@TMPa{% + \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1\endcsname{% + \noexpand\let\noexpand\pgfmath@parsepostgroup\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname% + \noexpand\expandafter\noexpand\pgfmath@parse@}% + \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname{% + \noexpand\expandafter\expandafter\noexpand\csname pgfmath#1@\endcsname\noexpand\expandafter{\noexpand\pgfmathresult}% + \noexpand\pgfmath@postfunction% + }% + }% + \pgfmathfloat@loc@TMPa +}% +\def\pgfmathfloat@parser@install@pgf@two@null@null{% + \pgfmathfloat@plots@checkuninstallcmd + \pgfmathfloat@plots@install% + \pgfmathfloat@parser@install@functions + \let\pgfmathrand@=\pgfmath@basic@rand@ + \let\pgfmathrnd@=\pgfmath@basic@rnd@ + \pgfmathfloat@install\pgfmathmax@=\pgfmathfloatmaxtwo% + \pgfmathfloat@install\pgfmathmin@=\pgfmathfloatmintwo% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{factorial}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{hex}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{bin}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{oct}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{tanh}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{sinh}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{cosh}% + % + % The following methods actually enable the parser to work with + % the internal floating point number representation. + % + % The idea is as follows: + % 1. Every operand must be given in internal float representation. + % 2. The internal float repr can be distinguished by a normal + % number. This is accomplished by introducing a new "exponent" + % token. + % 3. The stack-push-operation checks whether the argument is a + % float. If not, it is parsed properly before pushing it. + \let\pgfmath@basic@parsedecimalpoint=\pgfmath@parsedecimalpoint% + \let\pgfmath@basic@stack@push@operand=\pgfmath@stackpushoperand + \pgfmathfloat@install\pgfmath@stackpushoperand=\pgfmathfloat@stack@push@operand + \pgfmathfloat@install\pgfmath@parsedecimalpoint=\pgfmathfloat@parsedecimalpoint@pgf@two@null@null + \pgfmathfloat@install\pgfmath@endparse=\pgfmathfloat@endparse@pgf@two@null@null + \pgfmathfloat@install\pgfmath@endparsegroup=\pgfmathfloat@endparsegroup@pgf@two@null@null + \pgfmathfloat@install\pgfmath@postfunction=\pgfmathfloat@postfunction@pgf@two@null@null + \pgfmathfloat@install\pgfmath@@parseoperandgroup=\pgfmathfloat@@parseoperandgroup + % + \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse@pgf@two@null@null% +}% + +\pgfutil@ifundefined{pgfmathdeclarefunction}{% + % BACKWARDS COMPATIBILITY: We have PGF 2.00 : + \def\pgfmathdeclarepseudoconstant#1#2{% + \begingroup + \toks0=\expandafter{\csname pgfmath#1@\endcsname}% + \toks1={\pgfmath@postfunction}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \xdef\pgfmathfloat@glob@TMPb{\the\toks0 }% + \endgroup + \expandafter\let\csname pgfmath@parsefunction@#1\endcsname=\pgfmathfloat@glob@TMP + \expandafter\let\csname pgfmath#1\endcsname=\pgfmathfloat@glob@TMPb + \expandafter\def\csname pgfmath#1@\endcsname{#2}% + }% + \let\pgfmathredeclarepseudoconstant=\pgfmathdeclarepseudoconstant +}{% + \pgfutil@ifundefined{pgfmathdeclarepseudoconstant}{% + \def\pgfmathdeclarepseudoconstant#1#2{\pgfmathdeclarefunction*{#1}{0}{#2}} + }{}% +}% + +\pgfmathdeclarepseudoconstant{inf}{\def\pgfmathresult{inf}} +\pgfmathdeclarepseudoconstant{infty}{\def\pgfmathresult{inf}} +\pgfmathdeclarepseudoconstant{nan}{\def\pgfmathresult{nan}} +\pgfmathdeclarepseudoconstant{NaN}{\def\pgfmathresult{nan}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Hacks to the basic level pgf math engine: +% +% WARNING: These methods rely heavily on the internal float representation! +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% for pgf2.00 : +\def\pgfmathfloat@parsedecimalpoint@pgf@two@null@null#1{% + \expandafter\ifx\pgfmathfloat@POSTFLAGSCHAR#1% check whether it is a float + \let\pgfmath@next=\pgfmathfloat@return@float@pgf@two@null@null% + \else + \def\pgfmath@next{\pgfmath@basic@parsedecimalpoint#1}% + \fi + \pgfmath@next +} +% for pgf2.00: +\def\pgfmathfloat@return@float@pgf@two@null@null#1]{% + \edef\pgfmathresult{\the\c@pgfmath@parsecounta\pgfmathfloat@POSTFLAGSCHAR#1]}% + \let\pgfmath@resulttemp=\pgfmathresult + \pgfmath@parseoperator% +}% +% for pgf2.00: +\def\pgfmathfloat@endparse@pgf@two@null@null#1\pgfmath@empty{% + \pgfmath@processalloperations% + \pgfmath@stackpop{\pgfmathresult}% + % delete the final unit scalings + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup% + \ignorespaces% +} +% for pgf2.00: +\def\pgfmathfloat@endparsegroup@pgf@two@null@null{% + \pgfmath@processalloperations% + \pgfmath@stackpop{\pgfmathresult}% + % eliminated register usage here... + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup% + \pgfmath@parsepostgroup% +} +% for pgf2.00: +\def\pgfmathfloat@postfunction@pgf@two@null@null{% + \let\pgfmath@parsepostgroup\pgfmath@parseoperator% + \ifnum\pgfmath@sign1<0 + \pgfmathfloatneg@{\pgfmathresult}% + \let\pgfmath@sign\pgfutil@empty + \fi + \pgfmath@parseoperator} +% for pgf2.00: +\def\pgfmathfloat@@parseoperandgroup{% + \let\pgfmath@postparsegroup\pgfmath@parseoperator% + \ifnum\pgfmath@sign1<0 + \pgfmathfloatneg@{\pgfmathresult}% + \let\pgfmath@sign\pgfutil@empty + \fi + \pgfmath@parseoperator% +} + + + + + + +% PRECONDITION: +% either +% <number>e +% ^ +% -> read the exponent. +% or +% <sign>\pgfmathfloat@POSTFLAGSCHAR +% ^ +% -> we have a parsed floating point number -> read it. +\def\pgfmathfloat@parse@float@or@exponent{% + \if\pgfmath@token \pgfmathfloat@POSTFLAGSCHAR% + % Ok, we actually HAVE a pre-parsed floating point number! + % Return it. + \expandafter\pgfmathfloat@return@float\expandafter\pgfmath@token@next + \else + % We have a standard number in scientific format. Parse it. + \expandafter\pgfmath@basic@parse@exponent + \fi +}% +\def\pgfmathfloat@return@float#1]{% + \edef\pgfmathresult{\pgfmath@number \pgfmathfloat@POSTFLAGSCHAR#1]}% + \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}% + \pgfmath@parse@@operator% +}% + +% This extends the functionality of the basic level operand stack: it +% assures every element on the stack is a float. +\def\pgfmathfloat@stack@push@operand#1{% + \pgfutil@ifnextchar\bgroup{% + \let\pgfmathfloat@stack@push@operand@list@=\pgfutil@empty + \pgfmathfloat@stack@push@operand@list + }{% + \pgfmathfloat@stack@push@operand@single + }% + #1\relax +}% +\def\pgfmathfloat@stack@push@operand@single#1\relax{% + \expandafter\pgfutil@in@\pgfmathfloat@POSTFLAGSCHAR{#1}% + \ifpgfutil@in@ + \pgfmath@basic@stack@push@operand{#1}% + \else + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}% + \fi +}% +\def\pgfmathfloat@stack@push@operand@GOBBLE#1\relax{}% +\def\pgfmathfloat@stack@push@operand@list#1{% + \expandafter\pgfutil@in@ \pgfmathfloat@POSTFLAGSCHAR{#1}% + \ifpgfutil@in@ + \expandafter\def\expandafter\pgfmathfloat@stack@push@operand@list@\expandafter{% + \pgfmathfloat@stack@push@operand@list@{#1}% + }% + \else + \pgfmathfloatparsenumber{#1}% + \begingroup + \toks0=\expandafter{\pgfmathfloat@stack@push@operand@list@}% + \toks1=\expandafter{\pgfmathresult}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 {\the\toks1}}% + \endgroup + \let\pgfmathfloat@stack@push@operand@list@=\pgfmathfloat@glob@TMP + \fi + \pgfutil@ifnextchar\relax{% + \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathfloat@stack@push@operand@list@}% + \pgfmathfloat@stack@push@operand@GOBBLE + }{% + \pgfmathfloat@stack@push@operand@list + }% +}% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% --- END --- Hacks to the basic level pgf math engine +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Here starts the implementation of the floating point +% routines. +% +% They can be used even if the FPU parser is not active. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Remember the basic math commands. They will be invoked as subroutines in floating point routines. +\let\pgfmath@basic@add@=\pgfmathadd@ +\let\pgfmath@basic@subtract@=\pgfmathsubtract@ +\let\pgfmath@basic@multiply@=\pgfmathmultiply@ +\let\pgfmath@basic@divide@=\pgfmathdivide@ +\let\pgfmath@basic@reciprocal@=\pgfmathreciprocal@ +\let\pgfmath@basic@abs@=\pgfmathabs@ +\let\pgfmath@basic@round@=\pgfmathround@ +\let\pgfmath@basic@rand@=\pgfmathrand@ +\let\pgfmath@basic@rnd@=\pgfmathrnd@ +\let\pgfmath@basic@setseed@=\pgfmathsetseed@ +\let\pgfmath@basic@random@=\pgfmathrandom@ +\let\pgfmath@basic@floor@=\pgfmathfloor@ +\let\pgfmath@basic@ceil@=\pgfmathceil@ +\let\pgfmath@basic@mod@=\pgfmathmod@ +\let\pgfmath@basic@max@=\pgfmathmax@ +\let\pgfmath@basic@min@=\pgfmathmin@ +\let\pgfmath@basic@sin@=\pgfmathsin@ +\let\pgfmath@basic@cos@=\pgfmathcos@ +\let\pgfmath@basic@tan@=\pgfmathtan@ +\let\pgfmath@basic@deg@=\pgfmathdeg@ +\let\pgfmath@basic@rad@=\pgfmathrad@ +\let\pgfmath@basic@atan@=\pgfmathatan@ +\let\pgfmath@basic@asin@=\pgfmathasin@ +\let\pgfmath@basic@acos@=\pgfmathacos@ +\let\pgfmath@basic@cot@=\pgfmathcot@ +\let\pgfmath@basic@sec@=\pgfmathsec@ +\let\pgfmath@basic@cosec@=\pgfmathcosec@ +\let\pgfmath@basic@pow@=\pgfmathpow@ +\let\pgfmath@basic@exp@=\pgfmathexp@ +\let\pgfmath@basic@ln@=\pgfmathln@ +\let\pgfmath@basic@sqrt@=\pgfmathsqrt@ +\let\pgfmath@basic@@pi=\pgfmath@pi +\let\pgfmath@basic@veclen@=\pgfmathveclen@ +\let\pgfmath@basic@e@=\pgfmathe@ +\let\pgfmath@basic@lessthan@=\pgfmathlessthan@ +\let\pgfmath@basic@greaterthan@=\pgfmathgreaterthan@ +\let\pgfmath@basic@equalto@=\pgfmathequalto@ +\let\pgfmath@basic@true@=\pgfmathtrue@ +\let\pgfmath@basic@false@=\pgfmathfalse@ + +\def\pgfmathfloatscientific#1#2{% + \edef\pgfmathresult{#1e#2}% + \expandafter\pgfmathfloatparsenumber\expandafter{\pgfmathresult}% +} +% Compares #1 with #2 and sets \pgfmathresult either to 1.0 or 0.0. +% +% It also sets the boolean \ifpgfmathfloatcomparison (globally). +\def\pgfmathfloatlessthan@#1#2{% +%\def\pgfmathfloatlessthan#1#2#3\and#4#5#6{% + \global\pgfmathfloatcomparisonfalse + \begingroup + \edef\pgfmathfloat@loc@TMPa{#1}% + \edef\pgfmathfloat@loc@TMPb{#2}% + \expandafter\pgfmathfloat@decompose\pgfmathfloat@loc@TMPa\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E + \expandafter\pgfmathfloat@decompose\pgfmathfloat@loc@TMPb\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E + \ifcase\pgfmathfloat@a@S + % x = 0 -> (x<y <=> y >0) + \ifcase\pgfmathfloat@b@S + % y = 0 + \or% y > 0 + \global\pgfmathfloatcomparisontrue + \or% y < 0 + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty + \fi + \or + % x > 0 -> (x<y <=> ( y > 0 && |x| < |y|) ) + \ifcase\pgfmathfloat@b@S + % y = 0 + \or% y>0: + \pgfmathfloatlessthan@positive + \or% y < 0 + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty + \fi + \or + % x < 0 -> (x<y <=> (y >= 0 || |x| > |y|) ) + \ifcase\pgfmathfloat@b@S + % y = 0 + \global\pgfmathfloatcomparisontrue + \or%y > 0 + \global\pgfmathfloatcomparisontrue + \or% 'y<0': + \pgfmathfloatgreaterthan@positive + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty + \fi + \or + % x = nan. + \or + % x = +infty + \or + % x = -infty + \ifnum\pgfmathfloat@b@S=3 + \else + \global\pgfmathfloatcomparisontrue + \fi + \fi + \endgroup + \ifpgfmathfloatcomparison + \def\pgfmathresult{1.0}% + \else + \def\pgfmathresult{0.0}% + \fi +} +\let\pgfmathfloatlessthan=\pgfmathfloatlessthan@ +\let\pgfmathfloatless@=\pgfmathfloatlessthan@ + +% compares \pgfmathfloat@a@[SME] < \pgfmathfloat@b@[SME] +\def\pgfmathfloatlessthan@positive{% + \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E + \global\pgfmathfloatcomparisontrue + \else + \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E + \ifdim\pgfmathfloat@a@M<\pgfmathfloat@b@M + \global\pgfmathfloatcomparisontrue + \fi + \fi + \fi +} + +% compares \pgfmathfloat@a@[SME] > \pgfmathfloat@b@[SME] +\def\pgfmathfloatgreaterthan@positive{% + \ifnum\pgfmathfloat@a@E>\pgfmathfloat@b@E + \global\pgfmathfloatcomparisontrue + \else + \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E + \ifdim\pgfmathfloat@a@M>\pgfmathfloat@b@M + \global\pgfmathfloatcomparisontrue + \fi + \fi + \fi +} + + +\def\pgfmathfloatgreaterthan@#1#2{\pgfmathfloatlessthan@{#2}{#1}} +\let\pgfmathfloatgreaterthan=\pgfmathfloatgreaterthan@ +\let\pgfmathfloatgreater@=\pgfmathfloatgreaterthan@ + +\def\pgfmathfloatmax@#1{% + \begingroup + \pgfmathfloatcreate{2}{1.0}{2147483644}% + \let\pgfmathmaxsofar=\pgfmathresult + \pgfmathfloatmax@@#1{}% +}% +\def\pgfmathfloatmax@@#1{% + \def\pgfmath@temp{#1}% + \ifx\pgfmath@temp\pgfmath@empty% + \expandafter\pgfmathfloatmax@@@% + \else% + \pgfmathfloatlessthan{\pgfmathmaxsofar}{#1}% + \ifpgfmathfloatcomparison + \edef\pgfmathmaxsofar{#1}% + \fi + \expandafter\pgfmathfloatmax@@% + \fi% +}% +\def\pgfmathfloatmax@@@{% + \let\pgfmathresult=\pgfmathmaxsofar + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup +}% +\def\pgfmathfloatmin@#1{% + \begingroup + \pgfmathfloatcreate{1}{1.0}{2147483644}% + \let\pgfmathminsofar=\pgfmathresult + \pgfmathfloatmin@@#1{}% +}% +\def\pgfmathfloatmin@@#1{% + \def\pgfmath@temp{#1}% + \ifx\pgfmath@temp\pgfmath@empty% + \expandafter\pgfmathfloatmin@@@% + \else% + \pgfmathfloatlessthan{#1}{\pgfmathminsofar}% + \ifpgfmathfloatcomparison + \edef\pgfmathminsofar{#1}% + \fi + \expandafter\pgfmathfloatmin@@% + \fi% +}% +\def\pgfmathfloatmin@@@{% + \let\pgfmathresult=\pgfmathminsofar + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup +}% + +\def\pgfmathfloatmaxtwo#1#2{% + \pgfmathfloatlessthan{#1}{#2}% + \ifpgfmathfloatcomparison + \edef\pgfmathresult{#2}% + \else + \edef\pgfmathresult{#1}% + \fi +} +\let\pgfmathfloatmax=\pgfmathfloatmaxtwo + +\def\pgfmathfloatmintwo#1#2{% + \pgfmathfloatlessthan{#1}{#2}% + \ifpgfmathfloatcomparison + \edef\pgfmathresult{#1}% + \else + \edef\pgfmathresult{#2}% + \fi +} +\let\pgfmathfloatmin=\pgfmathfloatmintwo + +% Renormalizes #1 to extended precision mantisse, meaning +% 100 <= m < 1000 +% instead of 1 <= m < 10. +% +% The 'extended precision' means we have higher accuracy when we apply pgfmath operations to mantisses. +% +% The input argument is expected to be a normalized floating point number; the output argument is a non-normalized floating point number (well, normalized to extended precision). +% +% The operation is supposed to be very fast. +% +% @see \pgfmathfloatsetextprecision +% +% There is a routine for internal usage, +% \pgfmathfloattoextentedprecision@a. It also provides exponent and +% sign of #1 in output arguments and may be used to increase speed. +\def\pgfmathfloattoextentedprecision#1{% + \begingroup + \pgfmathfloattoextentedprecision@a{#1}% + \pgfmathfloatcreate{\pgfmathfloat@a@S}{\pgfmathresult}{\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\def\pgfmathfloattoextentedprecision@@zero#1\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1}% +}% +\def\pgfmathfloattoextentedprecision@@one#1.#2#3\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1#2.#3}% +}% +\def\pgfmathfloattoextentedprecision@@two#1.#2#3#4\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1#2#3.#4}% +}% +\def\pgfmathfloattoextentedprecision@@three#1.#2#3#4#5\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1#2#3#4.#5}% +}% + +% Sets extended precision to 10^#1. +% +% The different choices are +% +% - 0: normalization 0 <= m < 1 (disable extended precision) +% - 1: normalization 10 <= m < 100 +% - 2: normalization 100 <= m < 1000 (default) +% - 3: normalization 1000 <= m < 10000 +% +% #1 is the exponent, #1 = 0,1,2 or 3. +% +% This setting applies to \pgfmathfloattoextentedprecision and friends. +\def\pgfmathfloatsetextprecision#1{% + \ifcase#1\relax + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@zero + \def\pgfmathfloatextprec@shift{0}% + \or + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@one + \def\pgfmathfloatextprec@shift{1}% + \or + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@two + \def\pgfmathfloatextprec@shift{2}% + \else + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@three + \def\pgfmathfloatextprec@shift{3}% + \fi +}% +\pgfmathfloatsetextprecision{2}% + +% Does the "hard" work for \pgfmathfloattoextentedprecision. It +% provides additional outputs. +% +% INPUT: +% #1 normalized floating point number. Maybe a macro (it will be expanded ONCE) +% +% OUTPUT: +% - \pgfmathresult : the mantisse in extended precision +% - \pgfmathfloat@a@S : the sign of #1 +% - \pgfmathfloat@a@E : the exponent of #1, adjusted for extended precision +% - \pgfmathfloat@a@Mtok : undefined (its contents will be destroyed. +% +\def\pgfmathfloattoextentedprecision@a#1{% + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@S<3 + \advance\pgfmathfloat@a@E by-\pgfmathfloatextprec@shift\relax% compensate for shift + \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 000\pgfmathfloat@EOI + \fi +}% + + +% Similar to \pgfmathfloattoextentedprecision@a, this one here fills the '@b' registers. +\def\pgfmathfloattoextentedprecision@b#1{% + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E + \ifnum\pgfmathfloat@b@S<3 + \advance\pgfmathfloat@b@E by-\pgfmathfloatextprec@shift\relax + \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 00\pgfmathfloat@EOI + \fi +}% + +% Addition of two floating point numbers using 8 significant digits. +\def\pgfmathfloatadd@#1#2{% + \begingroup + % + % renormalize argument to 100 <= m < 1000 for extended accuracy: + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloattoextentedprecision@b{#2}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + \edef\pgfmathresult{#2}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}% + \fi + \ifcase\pgfmathfloat@b@S + \edef\pgfmathresult{#1}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@argb{-\pgfmathfloat@argb}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}% + \fi + \ifpgfmathfloatcomparison + % Shift lesser mantisse to fit the larger one: + \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E + \pgfmathfloatadd@shift{\pgfmathfloat@arga}{\pgfmathfloat@a@E}{\pgfmathfloat@b@E}% + \else + \pgfmathfloatadd@shift{\pgfmathfloat@argb}{\pgfmathfloat@b@E}{\pgfmathfloat@a@E}% + \fi + % add them! + \pgfmath@basic@add@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% #1= floating point number +% #2= TeX code to execute if #1 == 0 +% #3= TeX code to execute if #1 != 0 +\def\pgfmathfloatifzero#1#2#3{% + \pgfmathfloatgetflagstomacro{#1}\pgfmathfloat@loc@TMPa + \if\pgfmathfloat@loc@TMPa0 #2\else#3\fi +}% + +\def\pgfmathfloatiffinite#1#2#3{% + \pgfmathfloatgetflagstomacro{#1}\pgfmathfloatiffinite@ + \ifnum\pgfmathfloatiffinite@>2 #3\else #2\fi +}% + + +% Computes the relative error between #1 and #2 (assuming #2 != 0) and +% invokes #3 if the relative error is below `/pgf/fpu/rel thresh' and +% #4 if that is not the case. +\long\def\pgfmathfloatifapproxequalrel#1#2#3#4{% + \begingroup + \pgfmathfloatparsenumber{#1}% + \let\pgfmathfloatarga=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\pgfmathfloatargb=\pgfmathresult + \pgfmathfloatrelerror@\pgfmathfloatarga\pgfmathfloatargb + \let\pgfmathfloatarga=\pgfmathresult + \pgfmathfloatlessthan@\pgfmathfloatarga\pgfmathfloat@relthresh + \ifpgfmathfloatcomparison + \def\pgfmathfloat@loc@TMPa{#3}% + \else + \def\pgfmathfloat@loc@TMPa{#4}% + \fi + \expandafter\endgroup + \pgfmathfloat@loc@TMPa +}% + +% Invokes code '#3' if the flags of the floating point number '#1' +% match the flag provided in '#2'. +% +% \pgfmathfloatcreate{1}{1.0}{2} +% \pgfmathfloatifflags{\pgfmathresult}{0}{It's zero!}{It's not zero!}% +% \pgfmathfloatifflags{\pgfmathresult}{1}{It's positive!}{It's not positive!}% +% \pgfmathfloatifflags{\pgfmathresult}{2}{It's negative!}{It's not negative!}% +% or, equivalently +% \pgfmathfloatifflags{\pgfmathresult}{+}{It's positive!}{It's not positive!}% +% \pgfmathfloatifflags{\pgfmathresult}{-}{It's negative!}{It's not negative!}% +% it also supports #2=u which means 'unbounded' +\def\pgfmathfloatifflags#1#2#3#4{% + \if#2-% + \pgfmathfloatifflags{#1}{2}{#3}{#4}% + \else + \if#2+% + \pgfmathfloatifflags{#1}{1}{#3}{#4}% + \else + \pgfmathfloatgetflagstomacro#1\pgfmathfloat@loc@TMPa + \if#2u% + \ifnum\pgfmathfloat@loc@TMPa>2 + #3\relax + \else + #4\relax + \fi + \else + \if\pgfmathfloat@loc@TMPa#2 + #3\relax + \else + #4\relax + \fi + \fi + \fi + \fi +}% + +% #1=mantisse which needs to be shifted (with smaller exponent) +% #2=smaller exponent +% #3=larger exponent +% +% ATTENTION: this helper method DESTROYS contents of \pgfmathfloat@a@S. +\def\pgfmathfloatadd@shift#1#2#3{% + \pgf@xa=#1 pt% + \pgfmathfloat@a@S=#3\relax + \advance\pgfmathfloat@a@S by-#2\relax + \ifcase\pgfmathfloat@a@S + \or + \divide\pgf@xa by10\relax + \or + \divide\pgf@xa by100\relax + \or + \divide\pgf@xa by1000\relax + \or + \divide\pgf@xa by10000\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by10\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by100\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by1000\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by10000\relax + \else + \pgf@xa=0pt% + \fi + #2=#3\relax + \edef#1{\pgf@sys@tonumber\pgf@xa}% +} + +\let\pgfmathfloatadd=\pgfmathfloatadd@ + + +% Subtracts two floating point numbers. +\def\pgfmathfloatsubtract@#1#2{% + \begingroup + \edef\pgfmathresult{#2}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E + \ifcase\pgfmathfloat@b@S + \edef\pgfmathresult{#1}% + \or + \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}% + \let\pgfmathfloatsub@arg=\pgfmathresult + \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}% + \or + \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}% + \let\pgfmathfloatsub@arg=\pgfmathresult + \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}% + \else + \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\let\pgfmathfloatsubtract=\pgfmathfloatsubtract@ + +% Scales a floating point number #1 with a fixed point number #2 using pgfmathmultiply. +% +% Use this method if #2 is small number. +\def\pgfmathfloatmultiplyfixed@#1#2{% + \begingroup + % + % renormalize argument to 100 <= m < 1000 for extended accuracy: + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + \edef\pgfmathresult{#1}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}% + \fi + \ifpgfmathfloatcomparison + \pgfmath@basic@multiply@{\pgfmathfloat@arga}{#2}% + % renormalize product. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\let\pgfmathfloatmultiplyfixed=\pgfmathfloatmultiplyfixed@ + + +\def\pgfmathfloatmultiply@#1#2{% + \begingroup + \pgfmathfloatsetextprecision{1}% + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloattoextentedprecision@b{#2}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + % 0 + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% + + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{1}% + \or + \def\pgfmathresult@S{2}% + \else + \expandafter\pgfmathfloatcreate\the\pgfmathfloat@b@S{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% - + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{2}% + \or + \def\pgfmathresult@S{1}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% nan + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% +infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% -infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \fi + \ifpgfmathfloatcomparison + \pgfmath@basic@multiply@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatmultiply=\pgfmathfloatmultiply@ + +% Defines \pgfmathresult to be #1 / #2 for two floating point numbers. +% +% It employs the basic math engine internally to divide mantissas. +\def\pgfmathfloatdivide@#1#2{% + \begingroup + \pgfmathfloatsetextprecision{1}% is not too important, I think. After all, 0.1 <= #1/#2 < 10 or so due to normalization (no matter, which) + \edef\pgfmathfloat@arga{#1}% + \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \edef\pgfmathfloat@argb{#2}% + \pgfmathfloattoextentedprecision@b{\pgfmathfloat@argb}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + % 0 + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% + + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{1}% + \or + \def\pgfmathresult@S{2}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \else + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% - + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{2}% + \or + \def\pgfmathresult@S{1}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \else + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% nan + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% +infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% what is inf/inf ? + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% or inf/-inf ? + \pgfmathfloatcomparisonfalse + \fi + \or% -infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \fi + \ifpgfmathfloatcomparison + \pgfmath@basic@divide@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + \advance\pgfmathfloat@a@E by-\pgfmathfloat@b@E + % renormalize. This is the only part were an expensive float routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + % And re-insert the proper sign: + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatdivide=\pgfmathfloatdivide@ + +\def\pgfmathfloatreciprocal@#1{% + \begingroup + % FIXME optimize + \edef\pgfmathfloat@loc@TMPa{#1}% + \pgfmathfloatcreate{1}{1.0}{0}% + \pgfmathfloatdivide@{\pgfmathresult}{\pgfmathfloat@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% Computes sqrt(#1) in floating point arithmetics. +% +% It employs sqrt( m * 10^e ) = sqrt(m) * sqrt(10^e). +\def\pgfmathfloatsqrt@#1{% + \begingroup + \pgfmathfloatsetextprecision{3}% + \edef\pgfmathfloat@arga{#1}% + \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \ifcase\pgfmathfloat@a@S + % 0 + \pgfmathfloatcreate{0}{0.0}{0}% + \or% + + \pgfmath@basic@sqrt@{\pgfmathfloat@arga}% + \ifodd\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@E>0 + \expandafter\pgfmath@basic@multiply@\expandafter{\pgfmathresult}{3.16227766}% * sqrt(10) + \else + \expandafter\pgfmath@basic@multiply@\expandafter{\pgfmathresult}{0.316227766}% * sqrt(0.1) + \fi + \fi + \divide\pgfmathfloat@a@E by2 % sqrt(10^e) = 10^{e/2} (see above for odd e) + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathfloat@arga{\pgfmathresult e\the\pgfmathfloat@a@E}% + \pgfmathfloatqparsenumber{\pgfmathfloat@arga}% + \or% - + \pgfmathfloatcreate{3}{0.0}{0}% + \or% nan + \pgfmathfloatcreate{3}{0.0}{0}% + \or% +infty + \pgfmathfloatcreate{4}{0.0}{0}% + \or% -infty + \pgfmathfloatcreate{3}{0.0}{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatsqrt=\pgfmathfloatsqrt@ + +% Returns the integer part of the floating point number #1. +% +% The result is returned as floating point as well. +% +% This operation is not limited to TeX's range of count registers (it +% works symbolly) +% +% @see \pgfmathfloattoint +\def\pgfmathfloatint@#1{% + \begingroup + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + % 0: nothing to do. + \or% + + \expandafter\pgfmathfloatint@@\the\pgfmathfloat@a@Mtok\pgfmathfloat@EOI + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or% - + \expandafter\pgfmathfloatint@@\the\pgfmathfloat@a@Mtok\pgfmathfloat@EOI + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \else + % nothing to do + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloatint@@#1.{% + \ifnum\pgfmathfloat@a@E<0 + \pgfmathfloat@a@S=0 + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0 + \expandafter\pgfmathfloatint@@loop@gobble + \else + \pgfmathfloat@a@Mtok={#1.}% + \pgfmathfloat@b@E=\pgfmathfloat@a@E + \expandafter\pgfmathfloatint@@loop + \fi +}% +\def\pgfmathfloatint@@loop#1{% + \def\pgfmathfloatint@@loop@{#1}% + \ifx\pgfmathfloatint@@loop@\pgfmathfloat@EOI + \let\pgfmathfloatint@@loop@next=\relax + \else + \ifnum\pgfmathfloat@b@E=0 + \let\pgfmathfloatint@@loop@next=\pgfmathfloatint@@loop@gobble + \else + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \advance\pgfmathfloat@b@E by-1 + \let\pgfmathfloatint@@loop@next=\pgfmathfloatint@@loop + \fi + \fi + \pgfmathfloatint@@loop@next +}% +\def\pgfmathfloatint@@loop@gobble#1\pgfmathfloat@EOI{}% +\let\pgfmathfloatint=\pgfmathfloatint@ +\let\pgfmathfloatfloor=\pgfmathfloatint +\let\pgfmathfloatfloor@=\pgfmathfloatint@ + +\def\pgfmathfloat@notimplemented#1{% + \pgfmath@error{Sorry, the operation '#1' has not yet been implemented in the floating point unit :-(}{}% + \pgfmathfloatcreate{0}{0.0}{0}% +}% + +% Divides or multiplies the input number by 10^#4 using an arithmetic +% left/right shift. +% +% Input: +% #1 a normalised floating point number. +% #2 a positive or negative integer number denoting the shift. +% +% Example: +% \pgfmathfloatshift{11e3}{4}% +% -> pgfmathresult = 11e7 +\def\pgfmathfloatshift@#1#2{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \advance\pgfmathfloat@a@E by#2\relax + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloatshift=\pgfmathfloatshift@ + +% Defines \pgfmathresult to be |#1|, the absolute value of the +% normalized floating point number #1. +\def\pgfmathfloatabs@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + % 0: do nothing. + \or + % +: ok, is positive. + \or + % -: multiply with -1: + \pgfmathfloat@a@S=1 + \or + % nan: do nothing. + \or + % +infty: ok. + \or + % -infty: multiply with -1: + \pgfmathfloat@a@S=4 + \fi + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatabs=\pgfmathfloatabs@ + +% Computes the absolute error |#1 - #2| into \pgfmathresult. +\def\pgfmathfloatabserror@#1#2{% + \pgfmathfloatsubtract@{#1}{#2}% + \pgfmathfloatabs@{\pgfmathresult}% +}% +\let\pgfmathfloatabserror=\pgfmathfloatabserror@ + +% Computes the relative error |#1 - #2|/|#2| into \pgfmathresult, +% assuming #2 != 0. +\def\pgfmathfloatrelerror@#1#2{% + \pgfmathfloatsubtract@{#1}{#2}% + \pgfmathfloatdivide@{\pgfmathresult}{#2}% + \pgfmathfloatabs@{\pgfmathresult}% +}% +\let\pgfmathfloatrelerror=\pgfmathfloatrelerror@ + +% Computes \pgfmathresult = #1 mod #2 using truncated division. +% +\def\pgfmathfloatmod@#1#2{% + \begingroup + \pgfmathfloatdivide@{#1}{#2}% + \pgfmathfloatint@{\pgfmathresult}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloatmod=\pgfmathfloatmod@ + + +% A modification of \pgfmathfloatmod@ where #3 = 1/#2 is already +% known. This may be faster. +\def\pgfmathfloatmodknowsinverse@#1#2#3{% + \begingroup + \pgfmathfloatmultiply@{#1}{#3}% + \pgfmathfloatint@{\pgfmathresult}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloatmodknowsinverse=\pgfmathfloatmodknowsinverse@ + +\def\pgfmathfloatpi@{% + \pgfmathfloatcreate{1}{3.14159265358979}{0}% +}% +\let\pgfmathfloatpi=\pgfmathfloatpi@ + +\def\pgfmathfloate@{% + \pgfmathfloatcreate{1}{2.71828182845905}{0}% +} +\let\pgfmathfloate=\pgfmathfloate@ + +% Converts #1 from radians to degrees. +\def\pgfmathfloatdeg@#1{% + \expandafter\ifx\csname pgfmfltdeg@factor\endcsname\relax + % Lazy evaluation: + \pgfmathfloatcreate{1}{5.72957795130823}{1}% + \global\let\pgfmfltdeg@factor=\pgfmathresult + \fi + \pgfmathfloatmultiply@{#1}\pgfmfltdeg@factor% +} +\let\pgfmathfloatdeg=\pgfmathfloatdeg@ + +% Converts #1 from degree to radians. +\def\pgfmathfloatrad@#1{% + \expandafter\ifx\csname pgfmfltrad@factor\endcsname\relax + % Lazy evaluation: + \pgfmathfloatcreate{1}{1.74532925199433}{-2}% + \global\let\pgfmfltrad@factor=\pgfmathresult + \fi + \pgfmathfloatmultiply@{#1}\pgfmfltrad@factor% +} +\let\pgfmathfloatrad=\pgfmathfloatrad@ + +% Computes #1(#2) where #1 is a trigonometric function, i.e. +% #1(#2) = #1( #2 + r*360 ) +% +% #1 is a one-argument macro which assigns \pgfmathresult. +\def\pgfmathfloatTRIG@#1#2{% + \expandafter\ifx\csname pgfmathfloatTRIG@NUM\endcsname\relax% + % Lazy evaluation: + \pgfmathfloatcreate{1}{3.6}{2}% + \global\let\pgfmathfloatTRIG@NUM=\pgfmathresult + \pgfmathfloatcreate{1}{2.77777777777778}{-3}% + \global\let\pgfmathfloatTRIG@NUM@INV=\pgfmathresult + \fi + \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@NUM}{\pgfmathfloatTRIG@NUM@INV}% + \pgfmathfloattofixed@{\pgfmathresult}% + \expandafter#1\expandafter{\pgfmathresult}% + \pgfmathfloatparsenumber{\pgfmathresult}% +}% + +\def\pgfmathfloatsin@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}} +\let\pgfmathfloatsin=\pgfmathfloatsin@ +\def\pgfmathfloatcos@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}} +\let\pgfmathfloatcos=\pgfmathfloatcos@ +\def\pgfmathfloattan@#1{% + % compute sin(#1) / cos(#1) + \begingroup + \pgfmathfloatcos@{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatsin@{#1}% + \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloattan=\pgfmathfloattan@ + +\def\pgfmathfloatcot@#1{% + % compute cos(#1) / sin(#1) + \begingroup + \pgfmathfloatsin@{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatcos@{#1}% + \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatcot=\pgfmathfloatcot@ + +\def\pgfmathfloatatan@#1{% + \begingroup + \expandafter\ifx\csname pgfmathfloatatan@TMP\endcsname\relax% + \pgfmathfloatcreate{1}{1.6}{4}% + \global\let\pgfmathfloatatan@TMP=\pgfmathresult + \pgfmathfloatcreate{2}{1.6}{4}% + \global\let\pgfmathfloatatan@TMPB=\pgfmathresult + \fi + \pgfmathfloatgreaterthan@{#1}{\pgfmathfloatatan@TMP}% + \ifpgfmathfloatcomparison + \pgfmathfloatcreate{1}{9.0}{1}% + \else + \pgfmathfloatlessthan{#1}{\pgfmathfloatatan@TMPB}% + \ifpgfmathfloatcomparison + \pgfmathfloatcreate{2}{9.0}{1}% + \else + \pgfmathfloattofixed@{#1}% + \expandafter\pgfmath@basic@atan@\expandafter{\pgfmathresult}% + \pgfmathfloatparsenumber{\pgfmathresult}% + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatatan=\pgfmathfloatatan@ + +\def\pgfmathfloatsec@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}} +\let\pgfmathfloatsec=\pgfmathfloatsec@ +\def\pgfmathfloatcosec@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}} +\let\pgfmathfloatcosec=\pgfmathfloatcosec@ + +% Expands #2 using \edef and invokes #1 with the resulting string. +% +% DEPRECATED +% Example: +% \pgfmath@y=7.9pt +% \pgfmathlog@invoke@expanded\pgfmathexp@{{\pgf@sys@tonumber{\pgfmath@y}}}% +% will invoke +% \pgfmathexp@{7.9} +\def\pgfmathlog@invoke@expanded#1#2{% + \edef\pgfmath@resulttemp{#2}% + \expandafter#1\pgfmath@resulttemp +} + +\def\pgfmathfloatln@#1{% + \pgfmathlog@float{#1}% + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloatcreate{3}{0.0}{0}% + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \fi +} +\let\pgfmathfloatln=\pgfmathfloatln@ + +% Computes log(x) into \pgfmathresult. +% +% This allows numbers such at 10000000 or 5.23e-10 to be represented +% properly, although TeX-registers would produce overflow/underflow +% errors in these cases. +% +% The natural logarithm is computed using log(X*10^Y) = log(X) + log(10)*Y +% +% FIXME This routine is only kept for backwards compatibility! +% It does not work as expected because +% 1. it calls \pgfmathfloatparsenumber +% 2. it returns the result as fixed point number +% Use \pgfmathln@ instead! +\def\pgfmathlog@#1{% + \pgfmathfloatparsenumber{#1}% + \pgfmathlog@float{\pgfmathresult}% +} +\let\pgfmathlog=\pgfmathlog@ +\def\pgfmathlog@float#1{% + \begingroup% + % compute #1 = M*10^E with normalised mantisse M = [+-]*[1-9].XXXXX + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@S=1 + % Now, compute log(#1) = log(M) + E*log(10) + \expandafter\pgfmath@basic@ln@\expandafter{\the\pgfmathfloat@a@Mtok}% + \pgfmathfloat@b@M=\pgfmathresult pt% + \pgfmathfloat@a@M=2.302585pt% = log(10) + \multiply\pgfmathfloat@a@M by\pgfmathfloat@a@E\relax + \advance\pgfmathfloat@b@M by\pgfmathfloat@a@M + \edef\pgfmathresult{\pgf@sys@tonumber{\pgfmathfloat@b@M}}% + \else + \let\pgfmathresult=\pgfutil@empty% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup% +} + + +% Computes exp(#1) in floating point. +% +% The algorithm employs the identity +% exp(x) = exp(x - log(10^k) + log(10^k) +% = 10^k exp( x - k*log 10 ) +% with k choosen such that exp( x - k*log10) can be computed with the +% basic level math engine. +% +% The precision (relative error) is between 10^{-4} and 10^{-6}. For +% #1 = 700, it is even 10^{-3}. I will need to improve that someday. +\def\pgfmathfloatexp@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + % #1 = 0: + \pgfmathfloatcreate{1}{1.0}{0}% + \or% #1 > 0 + \pgfmathfloatexp@@{#1}% + \or% #1 < 0 + \pgfmathfloatexp@@{#1}% + \else + \edef\pgfmathresult{#1}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloatexp@@#1{% + % Employ the identity + % exp(x) = exp(x - log(10^k) + log(10^k)) = 10^k exp( x - k *log(10)) + % + % I'd like to have x - k*log(10) <= 1 + % => compute k := int( (x - 1) * 1/log(10) ) + % that should suffice since \pgfmathexp@ should be + % accurate enough for those numbers. + % + % please note that we can do all this in TeX registers. + % exp(700) is almost the maximum of double precision + % anyway, and exp(16000) is certainly the largest we will + % ever need. + \pgfmathfloattofixed@{#1}% + \pgf@xa=\pgfmathresult pt + \pgf@xa=0.434294481\pgf@xa\relax + \edef\pgfmathfloat@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}% + \expandafter\pgfmathfloatexp@@toint\pgfmathfloat@loc@TMPa\relax + \pgf@xa=2.302585092pt + \multiply\pgf@xa by-\pgfmathfloat@k\relax + \advance\pgf@xa by\pgfmathresult pt + \edef\pgfmathfloat@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}% +%\message{computing exp(\pgfmathresult) = 10^\pgfmathfloat@k * exp(\pgfmathfloat@loc@TMPa)...}% + \pgfmath@basic@exp@{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatparsenumber{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatshift@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@k}% +} +% determine 'k'. This is a heuristics. The exponential series +% converges best for |x| <= 1. However, the fixed point arithmetics +% for tex results in best results for large |x|. Well, I'll need to +% tune this here. +\def\pgfmathfloatexp@@toint#1.#2\relax{% + \c@pgf@counta=#1\relax + \ifnum\c@pgf@counta<0 +\advance\c@pgf@counta by-1 % FIXME . this is a test for optimizations. + \c@pgf@countb=#2\relax + \ifnum\c@pgf@countb>0 + \advance\c@pgf@counta by-1 + \fi + \fi + \edef\pgfmathfloat@k{\the\c@pgf@counta}% +}% +\let\pgfmathfloatexp=\pgfmathfloatexp@ + +\def\pgfmathfloatround@#1{% + \begingroup + \pgfkeysvalueof{/pgf/number format/precision/.@cmd}0\pgfeov + \pgfmathfloattofixed{#1}% + \pgfmathroundto{\pgfmathresult}% + \pgfmathfloatparsenumber{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + + +\def\pgfmathfloatneg@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S\relax + % 0: + \edef\pgfmathresult{#1}% + \or + % +: + \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or + % -: + \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or + % nan: + \edef\pgfmathresult{#1}% + \or + % +infty: + \pgfmathfloatcreate{5}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or + % -infty: + \pgfmathfloatcreate{4}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + + +\def\pgfmathfloatpow@#1#2{% + \begingroup% + \expandafter\pgfmathfloat@decompose@tok#2\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S\relax + % #1 ^ 0 = 1 + \pgfmathfloatcreate{1}{1.0}{0}% + \or + % #2 > 0 + \pgfmathfloatpow@@{#1}{#2}% + \or + % #2 < 0 + \pgfmathfloatpow@@{#1}{#2}% + \or + % #2 = nan + \edef\pgfmathresult{#2}% + \or + % #2 = inf + \edef\pgfmathresult{#2}% + \or + % #2 = -inf + \pgfmathfloatcreate{0}{0.0}{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% computes #1^#2 +% PRECONDITIONS +% - #2 is positive. +\def\pgfmathfloatpow@@#1#2{% + \pgfmathfloattofixed@{#2}% + \afterassignment\pgfmath@x% + \expandafter\c@pgfmath@counta\pgfmathresult pt\relax% + \ifdim\pgfmath@x=0pt % + % loop "manually"; we have an integer exponent! + \ifnum\c@pgfmath@counta<0 + \pgfmathfloatreciprocal@{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \c@pgfmath@counta=-\c@pgfmath@counta + \else + \edef\pgfmathfloat@loc@TMPa{#1}% + \fi + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \pgfmathloop + \ifnum\c@pgfmath@counta>0\relax% + \ifodd\c@pgfmath@counta% + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPb}{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \fi + \ifnum\c@pgfmath@counta>1\relax% + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \fi% + \divide\c@pgfmath@counta by2\relax% + \repeatpgfmathloop% + \else + % employ #1^#2 = exp( #2 * ln(#1) ) + \pgfmathfloatln@{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \edef\pgfmathfloat@loc@TMPb{#2}% + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPb}% + \pgfmathfloatexp@{\pgfmathresult}% + \fi +} + +\def\pgfmathfloat@definemethodfrombasic@NOARG#1{% + \pgfutil@ifundefined{pgfmath@basic@#1@}{% + \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}% + }{}% + \edef\pgfmathfloat@glob@TMP{% + \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname + \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}% + }% + \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP% + \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP% +}% +\def\pgfmathfloat@definemethodfrombasic@ONEARG#1{% + \pgfutil@ifundefined{pgfmath@basic@#1@}{% + \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}% + }{}% + \edef\pgfmathfloat@glob@TMP##1{% + \noexpand\pgfmathfloattofixed{##1}% + \noexpand\expandafter + \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname\noexpand\expandafter% + {\noexpand\pgfmathresult}% + \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}% + }% + \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP% + \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP% +}% +\def\pgfmathfloat@definemethodfrombasic@TWOARGS#1{% + \pgfutil@ifundefined{pgfmath@basic@#1@}{% + \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}% + }{}% + \edef\pgfmathfloat@glob@TMP##1##2{% + \noexpand\pgfmathfloattofixed{##2}% + \noexpand\let\noexpand\pgfmathfloat@loc@TMPa=\noexpand\pgfmathresult + \noexpand\pgfmathfloattofixed{##1}% + \noexpand\expandafter + \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname\noexpand\expandafter% + {\noexpand\pgfmathresult}{\noexpand\pgfmathfloat@loc@TMPa}% + \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}% + }% + \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP% + \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP% +}% +\pgfmathfloat@definemethodfrombasic@NOARG{rand} +\pgfmathfloat@definemethodfrombasic@NOARG{rnd} +\pgfmathfloat@definemethodfrombasic@NOARG{false} +\pgfmathfloat@definemethodfrombasic@NOARG{true} +% arcsin, arccos +\pgfmathfloat@definemethodfrombasic@ONEARG{asin} +\pgfmathfloat@definemethodfrombasic@ONEARG{acos} +\pgfmathfloat@definemethodfrombasic@ONEARG{not} +\pgfmathfloat@definemethodfrombasic@ONEARG{hex} +\pgfmathfloat@definemethodfrombasic@ONEARG{Hex} +\pgfmathfloat@definemethodfrombasic@ONEARG{oct} +\pgfmathfloat@definemethodfrombasic@ONEARG{bin} +\pgfmathfloat@definemethodfrombasic@TWOARGS{and} +\pgfmathfloat@definemethodfrombasic@TWOARGS{or} + +\pgfutil@ifundefined{pgfmathdeclarefunction}{% + % special treatment: \pgfmathrand@ was not properly defined for pgf 2.00: + \let\pgfmath@basic@rand=\pgfmathrand + \let\pgfmath@basic@rand@=\pgfmathrand@ + \def\pgfmathfloatrand@{% + \pgfmath@basic@rand + \pgfmathfloatparsenumber{\pgfmathresult}% + }% + \let\pgfmathfloatrand=\pgfmathfloatrand@% + % + % special treatment: \pgfmathrnd@ was not properly defined for pgf 2.00: + \let\pgfmath@basic@rnd=\pgfmathrnd + \let\pgfmath@basic@rnd@=\pgfmathrnd@ + \def\pgfmathfloatrnd@{% + \pgfmath@basic@rnd + \pgfmathfloatparsenumber{\pgfmathresult}% + }% + \let\pgfmathfloatrnd=\pgfmathfloatrnd@% +}{} + +% Implements the factorial of '#1'. +% This does only work if '#1 < 2^32'. +\def\pgfmathfloatfactorial@#1{% + \begingroup + \pgfmathfloattofixed{#1}% + % collect integer part into a 32 bit register: + \afterassignment\pgfmath@gobbletilpgfmath@% + \expandafter\c@pgfmath@counta\pgfmathresult\relax\pgfmath@% + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathloop + \ifnum\c@pgfmath@counta<2 % + \else + \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}% + \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \advance\c@pgfmath@counta by-1\relax% + \repeatpgfmathloop + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% Implements the vector length of a 2D vector. +% +% ATTENTION: this does NOT use the improved code of the basic layer! +% It simply computed sqrt( #1^2 + #2^2 )! +\def\pgfmathfloatveclen@#1#2{% + \begingroup + \edef\pgfmathfloat@@a{#1}% + \pgfmathfloatmultiply@{\pgfmathfloat@@a}{\pgfmathfloat@@a}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \edef\pgfmathfloat@@b{#2}% + \pgfmathfloatmultiply@{\pgfmathfloat@@b}{\pgfmathfloat@@b}% + \let\pgfmathfloat@@b=\pgfmathresult + % + \pgfmathfloatadd@{\pgfmathfloat@@a}{\pgfmathfloat@@b}% + \pgfmathfloatsqrt@{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\def\pgfmathfloatcosh@#1{% + \begingroup + \pgfmathfloatexp@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatneg@{#1}% + \pgfmathfloatexp@{\pgfmathresult}% + % + \pgfmathfloatadd@{\pgfmathresult}{\pgfmathfloat@@a}% + \expandafter\pgfmathfloatmultiplyfixed@\expandafter{\pgfmathresult}{0.5}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloatsinh@#1{% + \begingroup + \pgfmathfloatexp@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatneg@{#1}% + \pgfmathfloatexp@{\pgfmathresult}% + % + \pgfmathfloatsubtract@{\pgfmathfloat@@a}{\pgfmathresult}% + \expandafter\pgfmathfloatmultiplyfixed@\expandafter{\pgfmathresult}{0.5}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloattanh@#1{% + \begingroup + \pgfmathfloatsinh@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatcosh@{#1}% + \let\pgfmathfloat@@b=\pgfmathresult + % + \pgfmathfloatdivide@{\pgfmathfloat@@a}{\pgfmathfloat@@b}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryintersections.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryintersections.code.tex new file mode 100644 index 00000000000..698ec524ba8 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryintersections.code.tex @@ -0,0 +1,767 @@ +% Copyright 2008 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + + +\newcount\pgf@intersect@solutions + +\newif\ifpgf@intersect@sort +\newif\ifpgf@intersect@sort@by@second@path + +\def\pgfintersectionsortbyfirstpath{% + \pgf@intersect@sorttrue% + \pgf@intersect@sort@by@second@pathfalse% +} + +\def\pgfintersectionsortbysecondpath{% + \pgf@intersect@sorttrue% + \pgf@intersect@sort@by@second@pathtrue% +} + +\def\pgfpointintersectionsolution#1{% + \ifnum#1<1\relax% + \pgfpoint@intersect@solution@orgin% + \else% + \ifnum#1>\pgfintersectionsolutions\relax% + \pgfpoint@intersect@solution@orgin% + \else% + \csname pgfpoint@intersect@solution@#1\endcsname% + \fi% + \fi% +} + +\def\pgfpoint@intersect@solution@orgin{% + \begingroup% + \pgftransforminvert% + \pgfpointorigin% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \global\pgf@x=\pgf@x% + \global\pgf@y=\pgf@y% + \endgroup% +} + +\long\def\pgfintersectionofpaths#1#2{% + \begingroup% + \pgfinterruptpath% + #1% + \pgfgetpath\pgf@intersect@path@a% + \global\let\pgf@intersect@path@temp=\pgf@intersect@path@a% + \endpgfinterruptpath% + \endgroup% + \let\pgf@intersect@path@a=\pgf@intersect@path@temp% + % + \begingroup% + \pgfinterruptpath% + #2% + \pgfgetpath\pgf@intersect@path@b% + \global\let\pgf@intersect@path@temp=\pgf@intersect@path@b% + \endpgfinterruptpath% + \endgroup% + \let\pgf@intersect@path@b=\pgf@intersect@path@temp% + % + \pgf@intersect@solutions=0\relax% + \def\pgf@intersect@time@offset{0}% + % + \ifpgf@intersect@sort@by@second@path% + \let\pgf@intersect@temp=\pgf@intersect@path@a% + \let\pgf@intersect@path@a=\pgf@intersect@path@b% + \let\pgf@intersect@path@b=\pgf@intersect@temp% + \fi% + \let\pgf@intersect@token@after=\pgf@intersect@path@process@a% + \expandafter\pgf@intersectionofpaths\pgf@intersect@path@a\pgf@stop% + \edef\pgfintersectionsolutions{\the\pgf@intersect@solutions}% + \pgfmathloop% + \ifnum\pgfmathcounter>\pgfintersectionsolutions\relax% + \else% + \pgfutil@namelet{pgfpoint@intersect@solution@\pgfmathcounter}% + {pgfpoint@g@intersect@solution@\pgfmathcounter}% + \ifpgf@intersect@sort% + \pgfutil@namelet{pgf@intersect@solution@\pgfmathcounter @time@a}% + {pgf@g@intersect@solution@\pgfmathcounter @time@a}% + \fi% + \repeatpgfmathloop% + \ifpgf@intersect@sort% + \pgfintersectionsolutionsortbytime% + \fi% +} + +\def\pgf@intersectionofpaths#1{% + \ifx#1\pgf@stop% + \let\pgf@intersect@next=\relax% + \else% + \ifx#1\pgfsyssoftpath@movetotoken% + \let\pgf@intersect@next=\pgf@intersect@token@moveto% + \else% + \ifx#1\pgfsyssoftpath@linetotoken% + \let\pgf@intersect@next=\pgf@intersect@token@lineto% + \else% + \ifx#1\pgfsyssoftpath@closepathtoken% + \let\pgf@intersect@next=\pgf@intersect@token@lineto% + \else% + \ifx#1\pgfsyssoftpath@curvetosupportatoken% + \let\pgf@intersect@next=\pgf@intersect@token@curveto% + \else% + \ifx#1\pgfsyssoftpath@rectcornertoken% + \let\pgf@intersect@next=\pgf@intersect@token@rect% + \fi% + \fi% + \fi% + \fi% + \fi% + \fi% + \pgf@intersect@next} + +\def\pgf@intersect@token@moveto#1#2{% + \def\pgfpoint@intersect@start{\pgfqpoint{#1}{#2}}% + \pgf@intersectionofpaths% +} + +\def\pgf@intersect@token@lineto#1#2{% + \def\pgfpoint@intersect@end{\pgfqpoint{#1}{#2}}% + \def\pgf@intersect@type{line}% + \pgf@intersect@token@after% +} +\def\pgf@intersect@token@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{% + \def\pgfpoint@intersect@firstsupport{\pgfqpoint{#1}{#2}}% + \def\pgfpoint@intersect@secondsupport{\pgfqpoint{#3}{#4}}% + \def\pgfpoint@intersect@end{\pgfqpoint{#5}{#6}}% + \def\pgf@intersect@type{curve}% + \pgf@intersect@token@after% +} + +\def\pgf@intersect@token@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{% + \pgf@xa=#1\relax% + \advance\pgf@xa by#3\relax% + \pgf@ya=#2\relax% + \advance\pgf@ya by#4\relax% + \edef\pgf@marshal{% + \noexpand\pgfsyssoftpath@movetotoken{#1}{#2}% + \noexpand\pgfsyssoftpath@linetotoken{#1}{\the\pgf@ya}% + \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{\the\pgf@ya}% + \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{#2}% + \noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}% + }% + \expandafter\pgf@intersectionofpaths\pgf@marshal% +} + +\def\pgf@intersect@path@process@a{% + \pgf@intersect@path@getpoints@a% + \let\pgf@intersect@token@after=\pgf@intersect@path@process@b% + \expandafter\pgf@intersectionofpaths\pgf@intersect@path@b\pgf@stop% + \let\pgfpoint@intersect@start=\pgfpoint@intersect@end@a% + \let\pgf@intersect@token@after=\pgf@intersect@path@process@a% + \c@pgf@counta=\pgf@intersect@time@offset\relax% + \advance\c@pgf@counta by1\relax% + \edef\pgf@intersect@time@offset{\the\c@pgf@counta}% + \pgf@intersectionofpaths% +} + +\def\pgf@intersect@path@getpoints@a{% + \let\pgfpoint@intersect@start@a=\pgfpoint@intersect@start% + \let\pgfpoint@intersect@end@a=\pgfpoint@intersect@end% + \let\pgfpoint@intersect@firstsupport@a=\pgfpoint@intersect@firstsupport% + \let\pgfpoint@intersect@secondsupport@a=\pgfpoint@intersect@secondsupport% + \let\pgf@intersect@type@a=\pgf@intersect@type% +} + +\def\pgf@intersect@path@process@b{% + \pgf@intersect@path@getpoints@b% + \csname pgf@intersect@\pgf@intersect@type@a @and@\pgf@intersect@type@b\endcsname% + \let\pgfpoint@intersect@start=\pgfpoint@intersect@end@b% + \pgf@intersectionofpaths} + +\def\pgf@intersect@path@getpoints@b{% + \let\pgfpoint@intersect@start@b=\pgfpoint@intersect@start% + \let\pgfpoint@intersect@end@b=\pgfpoint@intersect@end% + \let\pgfpoint@intersect@firstsupport@b=\pgfpoint@intersect@firstsupport% + \let\pgfpoint@intersect@secondsupport@b=\pgfpoint@intersect@secondsupport% + \let\pgf@intersect@type@b=\pgf@intersect@type% +} + +\def\pgf@intersect@line@and@line{% + \pgf@intersectionoflines{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}% + {\pgfpoint@intersect@start@b}{\pgfpoint@intersect@end@b}% +}% + +\def\pgf@intersect@line@and@curve{% + \pgf@intersectionoflineandcurve% + {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@end@a}}% + {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@firstsupport@b}}% + {\pgf@process{\pgfpoint@intersect@secondsupport@b}}{\pgf@process{\pgfpoint@intersect@end@b}}% +} + +\def\pgf@intersect@curve@and@line{% + \pgf@intersectionofcurveandline% + {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@firstsupport@a}}% + {\pgf@process{\pgfpoint@intersect@secondsupport@a}}{\pgf@process{\pgfpoint@intersect@end@a}}% + {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@end@b}}% +} + +\def\pgf@intersect@curve@and@curve{% + \pgf@intersectionofcurves% + {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@firstsupport@a}}% + {\pgf@process{\pgfpoint@intersect@secondsupport@a}}{\pgf@process{\pgfpoint@intersect@end@a}}% + {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@firstsupport@b}}% + {\pgf@process{\pgfpoint@intersect@secondsupport@b}}{\pgf@process{\pgfpoint@intersect@end@b}}% +} + + +\def\pgfintersectionoflines#1#2#3#4{% + \pgf@intersect@solutions=0\relax% + \pgf@intersectionoflines{#1}{#2}{#3}{#4}% +} + +\def\pgf@intersectionoflines#1#2#3#4{% + \pgf@iflinesintersect{#1}{#2}{#3}{#4}% + {% + \global\advance\pgf@intersect@solutions by1\relax% + \expandafter\pgfextract@process\csname pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions\endcsname{% + \pgfpointintersectionoflines{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}% + {\pgfpoint@intersect@start@b}{\pgfpoint@intersect@end@b}% + }% + \ifpgf@intersect@sort% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\pgfpointdiff{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}}% + \edef\pgf@marshal{% + \noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@ya}}% + }% + \pgf@marshal% + \let\pgf@intersect@length@a=\pgfmathresult% + \pgf@process{\pgfpointdiff{\pgfpoint@intersect@start@a}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}% + \edef\pgf@marshal{% + \noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}% + }% + \pgf@marshal% + \pgfmathdivide@{\pgfmathresult}{\pgf@intersect@length@a}% + \pgf@x=\pgfmathresult pt\relax% + \advance\pgf@x by\pgf@intersect@time@offset pt\relax% + \expandafter\xdef\csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname% + {\pgfmath@tonumber{\pgf@x}}% + \fi% + }{}% +} + +% Test if two lines L1 and L2 intersect. +% +% #1 - first point P1 on L1. +% #2 - second point P2 on L1. +% #3 - first point P3 on L2. +% #2 - second point P4 on L2. +% #5 - code executed if intersection occurs. +% #6 - code executed if intersection does no occur. +% +% Let L1 be represented by P1+(P2-P1)s where 0<=s<=1 +% Let L2 be represented by P3+(P4-P3)t where 0<=t<=1 +% +% Then L1 and L2 intersect at +% +% s = |x2-x1 x3-x1| / |x4-x3 x2-x1| +% |y2-y1 y3-y1| |y4-y3 y2-y1| +% +% t = |x4-x3 x3-x1| / |x4-x3 x2-x1| +% |y4-y3 y3-y1| |y4-y3 y2-y1| +% +% with 0<=s,t<=1 +% +% s and t do not need to be calculated: +% +% Let s = A / C and t = B / C +% +% Then 0<=s<=1 if !(C=0) && ((A=0) || ((A>0) && !(C<A)) || ((A<0) && !(C>A))) +% 0<=t<=1 if !(C=0) && ((B=0) || ((B>0) && !(C<B)) || ((B<0) && !(C>B))) +% +\newif\ifpgf@s +\newif\ifpgf@t +\def\pgfiflinesintersect#1#2#3#4{% + \begingroup% + \pgf@iflinesintersect{\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}% + {\aftergroup\pgfutil@firstoftwo}{\aftergroup\pgfutil@secondoftwo}% + \endgroup% +} + +\def\pgf@iflinesintersect#1#2#3#4{% + #4\relax% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + #3\relax% + \advance\pgf@xc by-\pgf@x% + \advance\pgf@yc by-\pgf@y% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + #2\relax% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + #1\relax% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + \advance\pgf@xb by-\pgf@x% + \advance\pgf@yb by-\pgf@y% + % + % xc = x4-x3; yc=y4-y3; + % xb = x3-x1; yb=y3-y1; + % xa = x2-x1; ya=y2-y1; + % + % + % Normalise a little. 16384 may not be a robust choice. + % + \c@pgf@counta=\pgf@xa\divide\c@pgf@counta by16384\relax% + \c@pgf@countb=\pgf@xb\divide\c@pgf@countb by16384\relax% + \c@pgf@countc=\pgf@ya\divide\c@pgf@countc by16384\relax% + \c@pgf@countd=\pgf@yb\divide\c@pgf@countd by16384\relax% + \multiply\c@pgf@counta by\c@pgf@countd% + \multiply\c@pgf@countc by\c@pgf@countb% + \advance\c@pgf@counta by-\c@pgf@countc% + \pgfutil@tempcnta=\c@pgf@counta% + % + \c@pgf@counta=\pgf@xc\divide\c@pgf@counta by16384\relax% + \c@pgf@countc=\pgf@yc\divide\c@pgf@countc by16384\relax% + \multiply\c@pgf@countd by\c@pgf@counta% + \multiply\c@pgf@countb by\c@pgf@countc% + \advance\c@pgf@countd by-\c@pgf@countb% + \pgfutil@tempcntb=\c@pgf@countd% + % + \c@pgf@countb=\pgf@xa\divide\c@pgf@countb by16384\relax% + \c@pgf@countd=\pgf@ya\divide\c@pgf@countd by16384\relax% + \multiply\c@pgf@counta by\c@pgf@countd% + \multiply\c@pgf@countc by\c@pgf@countb% + \advance\c@pgf@counta by-\c@pgf@countc% + % + \pgf@sfalse% + \pgf@tfalse% + \ifnum\c@pgf@counta=0\relax% + \else% + \ifnum\pgfutil@tempcnta=0\relax% + \pgf@strue% + \else% + \ifnum\pgfutil@tempcnta>0\relax% + \ifnum\c@pgf@counta<\pgfutil@tempcnta% + \else% + \pgf@strue% + \fi% + \else% + \ifnum\c@pgf@counta>\pgfutil@tempcnta% + \else% + \pgf@strue% + \fi% + \fi% + \fi% + \ifnum\pgfutil@tempcntb=0\relax% + \pgf@ttrue% + \else% + \ifnum\pgfutil@tempcntb>0\relax% + \ifnum\c@pgf@counta<\pgfutil@tempcntb% + \else% + \pgf@ttrue% + \fi% + \else% + \ifnum\c@pgf@counta>\pgfutil@tempcntb% + \else% + \pgf@ttrue% + \fi% + \fi% + \fi% + \fi% + \let\pgf@intersect@next=\pgfutil@secondoftwo% + \ifpgf@s% + \ifpgf@t% + \let\pgf@intersect@next=\pgfutil@firstoftwo% + \fi% + \fi% + \pgf@intersect@next% +} + + + + +\def\pgfintersectionoflineandcurve#1#2#3#4#5#6{% + \pgf@intersect@solutions=0\relax% + \pgf@intersectionoflineandcurve{#1}{#2}{#3}{#4}{#5}{#6}% +} + +\def\pgf@intersectionoflineandcurve#1#2#3#4#5#6{% + \pgf@intersectionofcurves% + {\pgf@process{#1}}% + {% + \pgf@process{% + \pgfpointadd{#1\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}% + {#2\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}% + }% + }% + {% + \pgf@process{% + \pgfpointadd{#1\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}% + {#2\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}% + }% + }% + {\pgf@process{#2}}% + {\pgf@process{#3}}% + {\pgf@process{#4}}% + {\pgf@process{#5}}% + {\pgf@process{#6}}% +}% + +\def\pgf@intersectionofcurveandline#1#2#3#4#5#6{% + \pgf@intersectionofcurves% + {\pgf@process{#1}}% + {\pgf@process{#2}}% + {\pgf@process{#3}}% + {\pgf@process{#4}}% + {\pgf@process{#5}}% + {% + \pgf@process{% + \pgfpointadd{#5\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}% + {#6\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}% + }% + }% + {% + \pgf@process{% + \pgfpointadd{#5\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}% + {#6\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}% + }% + }% + {\pgf@process{#6}}% +}% + + + + +\def\pgfintersectiontolerance{0.1pt} +\def\pgfintersectiontolerancefactor{0.1} + + + +% Find the intersections of two bezier curves. +% +% #1 - #4 = curve 1. +% #5 - #8 = curve 2. +% #9 = the solution number. +% +% There is no guarantee of ordering of solutions. If there are +% no solutions, the origin is returned. +% +\def\pgfpointintersectionofcurves#1#2#3#4#5#6#7#8#9{% + \pgf@intersect@solutions=0\relax% + \pgf@intersectionofcurves% + {\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}% + {\pgf@process{#5}}{\pgf@process{#6}}{\pgf@process{#7}}{\pgf@process{#8}}% + \pgfpointintersectionsolution{#9}% +} + +% Return any intersection points of two curves C1 and C2. +% No order can be guaranteed for the solutions. +% +% #1, #2, #3, #4 - the points on C1 +% #5, #6, #7, #8 - the points on C2 +% +% Returns: +% +% \pgf@intersect@solutions - the number of solutions. +% \pgfpointintersectionsolution{<S>} - the point for soultion S. +% +% (Sort of) use: +% +% intersection(C1,C2) +% S = {}; +% intersection'(C1,C2); +% return S; +% +% intersection'(C1,C2) +% B1 = boundingbox(C1); +% B2 = boundingbox(C2); +% if intersect(B1,B2) +% if (B1.width < q) and (B1.height < q) and +% (B2.width < q) and (B2.height < q) +% S = S + {average_of_all_points(B1,B2)}; \\ is there a better choice? +% else +% Q = subdivideLeft(C1); +% R = subdivideRight(C1); +% intersection'(C2,Q); +% intersection'(C2,R); +% +% where q is a small value (tolerance). +% +\def\pgfintersectionofcurves#1#2#3#4#5#6#7#8{% + \pgf@intersect@solutions=0\relax% + \pgf@intersectionofcurves% + {\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}% + {\pgf@process{#5}}{\pgf@process{#6}}{\pgf@process{#7}}{\pgf@process{#8}}% +}% +\def\pgf@intersectionofcurves#1#2#3#4#5#6#7#8{% + \begingroup% + \dimendef\pgf@time@a=2\relax% + \dimendef\pgf@time@aa=4\relax% + \dimendef\pgf@time@b=6\relax% + \dimendef\pgf@time@bb=8\relax% + \pgf@time@a=0pt\relax% + \pgf@time@aa=1pt\relax% + \pgf@time@b=0pt\relax% + \pgf@time@bb=1pt\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b% + \let\pgf@curve@subdivde@after=\pgf@@intersectionofcurves% + \pgf@@intersectionofcurves{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}% + \endgroup% +} + +\def\pgf@@intersectionofcurves#1#2#3#4#5#6#7#8{% + \pgf@intersect@boundingbox@reset% + \pgf@intersect@boundingbox@update{#1}% + \pgf@intersect@boundingbox@update{#2}% + \pgf@intersect@boundingbox@update{#3}% + \pgf@intersect@boundingbox@update{#4}% + \edef\pgf@intersect@boundingbox@b{% + \noexpand\pgf@x=\the\pgf@xa% + \noexpand\pgf@y=\the\pgf@ya% + \noexpand\pgf@xa=\the\pgf@xb% + \noexpand\pgf@ya=\the\pgf@yb% + }% + \pgf@intersect@boundingbox@reset% + \pgf@intersect@boundingbox@update{#5}% + \pgf@intersect@boundingbox@update{#6}% + \pgf@intersect@boundingbox@update{#7}% + \pgf@intersect@boundingbox@update{#8}% + \edef\pgf@intersect@boundingbox@a{% + \noexpand\pgf@xb=\the\pgf@xa% + \noexpand\pgf@yb=\the\pgf@ya% + \noexpand\pgf@xc=\the\pgf@xb% + \noexpand\pgf@yc=\the\pgf@yb% + }% + \pgf@intersect@boundingbox@a% + \pgf@intersect@boundingbox@b% + \ifdim\pgf@xa<\pgf@xb% + \else% + \ifdim\pgf@x>\pgf@xc% + \else% + \ifdim\pgf@ya<\pgf@yb% + \else% + \ifdim\pgf@y>\pgf@yc% + \else% + \advance\pgf@xc by-\pgf@xb% + \advance\pgf@yc by-\pgf@yb% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + \let\pgf@intersect@subdivde=\relax% + \ifdim\pgf@xc<\pgfintersectiontolerance\relax% + \ifdim\pgf@xa<\pgfintersectiontolerance\relax% + \ifdim\pgf@yc<\pgfintersectiontolerance\relax% + \ifdim\pgf@ya<\pgfintersectiontolerance\relax% + \pgfextract@process\pgf@intersect@solution@candidate{% + \pgf@intersect@boundingbox@a% + \pgf@intersect@boundingbox@b% + \pgf@x=0.25\pgf@x% + \advance\pgf@x by0.25\pgf@xa% + \advance\pgf@x by0.25\pgf@xb% + \advance\pgf@x by0.25\pgf@xc% + \pgf@y=0.25\pgf@y% + \advance\pgf@y by0.25\pgf@ya% + \advance\pgf@y by0.25\pgf@yb% + \advance\pgf@y by0.25\pgf@yc% + }% + % We must avoid duplicate solutions. + \let\pgf@intersect@subdivde=\pgf@stop% + \pgf@ifsolution@duplicate\pgf@intersect@solution@candidate{}% + {% + \global\advance\pgf@intersect@solutions by1\relax% + \expandafter\global\expandafter\let% + \csname pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions\endcsname=% + \pgf@intersect@solution@candidate% + {% + \ifpgf@intersect@sort% + \advance\pgf@time@a by\pgf@time@aa% + \divide\pgf@time@a by2\relax% + \advance\pgf@time@a by\pgf@intersect@time@offset pt\relax% + \expandafter\xdef% + \csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname% + {\pgfmath@tonumber{\pgf@time@a}}% + \fi% + }% + }% + \fi% + \fi% + \fi% + \fi% + \ifx\pgf@intersect@subdivde\pgf@stop% + \else% + \pgf@intersect@subdivide@curve{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}% + \fi% + \fi% + \fi% + \fi% + \fi% +} + +\def\pgf@intersect@subdivide@curve@b#1#2#3#4#5#6#7#8{% + \begingroup% + \advance\pgf@time@bb by\pgf@time@b\relax% + \divide\pgf@time@bb by2\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@a% + \pgf@curve@subdivide@left{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}% + \endgroup% + \begingroup% + \advance\pgf@time@b by\pgf@time@bb\relax% + \divide\pgf@time@b by2\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@a% + \pgf@curve@subdivide@right{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}% + \endgroup% +} + +\def\pgf@intersect@subdivide@curve@a#1#2#3#4#5#6#7#8{% + \begingroup% + \advance\pgf@time@aa by\pgf@time@a\relax% + \divide\pgf@time@aa by2\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b% + \pgf@curve@subdivide@left{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}% + \endgroup% + \begingroup% + \advance\pgf@time@a by\pgf@time@aa\relax% + \divide\pgf@time@a by2\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b% + \pgf@curve@subdivide@right{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}% + \endgroup% +} + +\def\pgf@intersect@boundingbox@reset{% + \pgf@xa=16000pt\relax% + \pgf@ya=16000pt\relax% + \pgf@xb=-16000pt\relax% + \pgf@yb=-16000pt\relax% +} + +\def\pgf@intersect@boundingbox@update#1{% + #1\relax% + \ifdim\pgf@x<\pgf@xa\pgf@xa=\pgf@x\fi% + \ifdim\pgf@y<\pgf@ya\pgf@ya=\pgf@y\fi% + \ifdim\pgf@x>\pgf@xb\pgf@xb=\pgf@x\fi% + \ifdim\pgf@y>\pgf@yb\pgf@yb=\pgf@y\fi% +} + + +\def\pgf@curve@subdivide@left#1#2#3#4{% + % + % The left curve (from t=0 to t=.5) + % + #1\relax% + \pgfutil@tempdima=\pgf@x% + \pgfutil@tempdimb=\pgf@y% + \pgf@xa=.5\pgf@x\pgf@ya=.5\pgf@y% + \pgf@xb=.25\pgf@x\pgf@yb=.25\pgf@y% + \pgf@xc=.125\pgf@x\pgf@yc=.125\pgf@y% + #2\relax% + \advance\pgf@xa by.5\pgf@x\advance\pgf@ya by.5\pgf@y% + \advance\pgf@xb by.5\pgf@x\advance\pgf@yb by.5\pgf@y% + \advance\pgf@xc by.375\pgf@x\advance\pgf@yc by.375\pgf@y% + #3\relax% + \advance\pgf@xb by.25\pgf@x\advance\pgf@yb by.25\pgf@y% + \advance\pgf@xc by.375\pgf@x\advance\pgf@yc by.375\pgf@y% + #4\relax% + \advance\pgf@xc by.125\pgf@x\advance\pgf@yc by.125\pgf@y% + \edef\pgf@marshal{% + \noexpand\pgf@curve@subdivde@after% + {\noexpand\pgf@x=\the\pgfutil@tempdima\noexpand\pgf@y=\the\pgfutil@tempdimb}% + {\noexpand\pgf@x=\the\pgf@xa\noexpand\pgf@y\the\pgf@ya}% + {\noexpand\pgf@x=\the\pgf@xb\noexpand\pgf@y=\the\pgf@yb} + {\noexpand\pgf@x=\the\pgf@xc\noexpand\pgf@y=\the\pgf@yc}% + }% + \pgf@marshal% +} + +\def\pgf@curve@subdivide@right#1#2#3#4{% + % + % The right curve (from t=0.5 to t=1) + % + #1\relax% + \pgfutil@tempdima=.125\pgf@x\pgfutil@tempdimb=.125\pgf@y% + #2\relax% + \advance\pgfutil@tempdima by.375\pgf@x\advance\pgfutil@tempdimb by.375\pgf@y% + \pgf@xa=.25\pgf@x\pgf@ya=.25\pgf@y% + #3\relax% + \advance\pgfutil@tempdima by.375\pgf@x\advance\pgfutil@tempdimb by.375\pgf@y% + \advance\pgf@xa by.5\pgf@x\advance\pgf@ya by.5\pgf@y% + \pgf@xb=.5\pgf@x\pgf@yb=.5\pgf@y% + #4\relax% + \advance\pgfutil@tempdima by.125\pgf@x\advance\pgfutil@tempdimb by.125\pgf@y% + \advance\pgf@xa by.25\pgf@x\advance\pgf@ya by.25\pgf@y% + \advance\pgf@xb by.5\pgf@x\advance\pgf@yb by.5\pgf@y% + \pgf@xc=\pgf@x\pgf@yc=\pgf@y% + \edef\pgf@marshal{% + \noexpand\pgf@curve@subdivde@after% + {\pgf@x\the\pgfutil@tempdima\pgf@y\the\pgfutil@tempdimb}% + {\pgf@x\the\pgf@xa\pgf@y\the\pgf@ya}{\pgf@x\the\pgf@xb\pgf@y\the\pgf@yb} + {\pgf@x\the\pgf@xc\pgf@y\the\pgf@yc}% + }% + \pgf@marshal% +} + + +% A solution S1 is considered a duplicate of S2, if +% +% |x1 - x2|f < q and |y1 - y2|f < q +% +% where q is a small value (tolerance). +% +% #1 - the solution. +% +\def\pgf@ifsolution@duplicate#1{% + #1% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \let\pgf@intersect@next=\pgfutil@secondoftwo% + \pgfmathloop% + \ifnum\pgfmathcounter>\pgf@intersect@solutions\relax% + \else% + \pgf@process{\csname pgfpoint@g@intersect@solution@\pgfmathcounter\endcsname}% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@y by-\pgf@ya% + \ifdim\pgf@x<0pt\relax\pgf@x=-\pgf@x\fi% + \ifdim\pgf@y<0pt\relax\pgf@y=-\pgf@y\fi% + % + \pgf@x=\pgfintersectiontolerancefactor\pgf@x% + \pgf@y=\pgfintersectiontolerancefactor\pgf@y% + \ifdim\pgf@x<\pgfintersectiontolerance\relax% + \ifdim\pgf@y<\pgfintersectiontolerance\relax% + \let\pgf@intersect@next=\pgfutil@firstoftwo% + \fi% + \fi% + \repeatpgfmathloop% + \pgf@intersect@next% +} + + +\newif\ifpgf@intersect@solutions@sortfinish + +% Sort solutions according to their time index. +% +\def\pgfintersectionsolutionsortbytime{% + \pgf@intersect@solutions@sortfinishtrue% + \pgfmathloop% + \ifnum\pgfmathcounter=\pgfintersectionsolutions\relax% + \else% + \pgfutil@tempcnta=\pgfmathcounter% + \advance\pgfutil@tempcnta by1\relax% + \ifdim\csname pgf@intersect@solution@\pgfmathcounter @time@a\endcsname pt>% + \csname pgf@intersect@solution@\the\pgfutil@tempcnta @time@a\endcsname pt\relax% + \pgf@intersect@solutions@sortfinishfalse% + % + \pgfutil@namelet{pgf@intersect@temp}{pgfpoint@intersect@solution@\pgfmathcounter}% + \pgfutil@namelet{pgfpoint@intersect@solution@\pgfmathcounter}% + {pgfpoint@intersect@solution@\the\pgfutil@tempcnta}% + \pgfutil@namelet{pgfpoint@intersect@solution@\the\pgfutil@tempcnta}{pgf@intersect@temp}% + % + \pgfutil@namelet{pgf@intersect@temp}{pgf@intersect@solution@\pgfmathcounter @time@a}% + \pgfutil@namelet{pgf@intersect@solution@\pgfmathcounter @time@a}% + {pgf@intersect@solution@\the\pgfutil@tempcnta @time@a}% + \pgfutil@namelet{pgf@intersect@solution@\the\pgfutil@tempcnta @time@a}{pgf@intersect@temp}% + \fi% + \repeatpgfmathloop% + \ifpgf@intersect@solutions@sortfinish% + \else% + \expandafter\pgfintersectionsolutionsortbytime% + \fi% +} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarylindenmayersystems.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarylindenmayersystems.code.tex new file mode 100644 index 00000000000..d7bb3d9dd57 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarylindenmayersystems.code.tex @@ -0,0 +1,223 @@ +% Copyright 2008 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\newdimen\pgflsystemstep +\newcount\c@pgf@lsystem@iteration + +\newif\ifpgf@lsystem@randomize@step +\newif\ifpgf@lsystem@randomize@angle + +\pgfkeys{/pgf/lindenmayer system/.cd,% + step/.code={\pgfmathsetlength\pgflsystemstep{#1}},% + randomize step percent/.code={% + \pgfmathparse{#1}% + \let\pgflsystemrandomizesteppercent=\pgfmathresult% + \ifdim\pgfmathresult pt=0pt\relax% + \pgf@lsystem@randomize@stepfalse% + \else% + \pgf@lsystem@randomize@steptrue% + \fi% + },% + left angle/.code={\pgfmathparse{#1}\let\pgflsystemleftangle=\pgfmathresult},% + right angle/.code={\pgfmathparse{#1}\let\pgflsystemrightangle=\pgfmathresult},% + angle/.style={/pgf/lindenmayer system/left angle=#1, /pgf/lindenmayer system/right angle=#1},% + randomize angle percent/.code={% + \pgfmathparse{#1}% + \let\pgflsystemrandomizeanglepercent=\pgfmathresult% + \ifdim\pgfmathresult pt=0pt\relax% + \pgf@lsystem@randomize@anglefalse% + \else% + \pgf@lsystem@randomize@angletrue% + \fi% + }% +} + +\pgfkeys{/pgf/lindenmayer system/.cd, + step=5pt,% + randomize step percent=0,% + angle=90,% + randomize angle percent=0% +} + +\long\def\pgfdeclarelindenmayersystem#1#2{% + \pgfutil@ifundefined{pgf@lsystem@#1}% + {% + \begingroup% + \edef\pgf@lsystem@name{#1}% + \expandafter\global\expandafter\let\csname pgf@lsystem@#1\endcsname=\pgf@lsystem@name% + \let\symbol=\pgf@lsystem@symbol% + \let\rule=\pgf@lsystem@rule% + #2% + \endgroup% + }% + {\PackageError{pgf}{Lindenmayer system `#1' is already defined}{}}% +} + +\def\pgf@lsystem@symbol#1#2{% + \expandafter\gdef\csname pgf@lsystem@\pgf@lsystem@name @symbol@#1\endcsname{#2}% +} + +\def\pgf@lsystem@rule#1{\expandafter\pgf@lsystem@rule@#1\pgf@stop} +\def\pgf@lsystem@rule@#1{\def\pgf@lsystem@rule@head{#1}\pgf@lsystem@rule@@} +\def\pgf@lsystem@rule@@#1->{% Now some `fooling around' to deal with unwanted spaces. + \let\pgf@lsystem@rule@body=\pgfutil@empty% + \pgfutil@ifnextchar x{\pgf@lsystem@rule@@@}{\pgf@lsystem@rule@@@}} +\def\pgf@lsystem@rule@@@#1{% + \ifx#1\pgf@stop% + \expandafter\global\expandafter\let% + \csname pgf@lsystem@\pgf@lsystem@name @rule@\pgf@lsystem@rule@head\endcsname=\pgf@lsystem@rule@body% + \else% + \edef\pgf@lsystem@rule@body{\pgf@lsystem@rule@body#1}% + \expandafter\pgf@lsystem@rule@@@% + \fi% +} + +\def\pgflindenmayersystem#1#2#3{% + \begingroup% + \edef\pgf@lsystem@name{#1}% + \edef\pgf@lsystem@axiom{#2}% + \pgfmathtruncatemacro\pgf@lsystem@order{#3}% + % + \let\pgf@lsystem@current@symbol=\relax% + % + \c@pgf@lsystem@iteration=0\relax% + % + \ifnum\pgf@lsystem@order=0\relax% + \expandafter\pgf@lsystem@draw\pgf@lsystem@axiom\pgf@stop + \let\pgf@lsystem@next=\pgf@lsystem@end% + \else% + \let\pgf@lsystem@next=\pgf@lsystem@run% + \fi% + \expandafter\pgf@lsystem@next\pgf@lsystem@axiom\pgf@lsystem@stop% +} + +\def\pgf@lsystem@run#1{% + \ifx#1\pgf@lsystem@stop% + \def\pgf@lsystem@token{\pgf@lsystem@stop}% + \let\pgf@lsystem@next=\pgf@lsystem@end% + \else% + \ifx#1\pgf@stop% + \advance\c@pgf@lsystem@iteration by-1\relax% + \let\pgf@system@token=\pgfutil@empty% + \let\pgf@lsystem@next=\pgf@lsystem@run% + \else% + % Does #1 appear on the RHS of a rule...? + \expandafter\let\expandafter\pgf@lsystem@token\expandafter=% + \csname pgf@lsystem@\pgf@lsystem@name @rule@#1\endcsname% + \ifx\pgf@lsystem@token\relax% + % ...nope. So draw it straight away. + \pgf@lsystem@draw#1\pgf@stop% + \let\pgf@lsystem@token=\pgfutil@empty% + \else% + % ...yep. So, if the order has been reached draw the LHS + % immediately. Otherwise add the LHS to the token stream + % and continue. + \advance\c@pgf@lsystem@iteration by1\relax% + \ifnum\c@pgf@lsystem@iteration=\pgf@lsystem@order% + \expandafter\pgf@lsystem@draw\pgf@lsystem@token \pgf@stop% + \advance\c@pgf@lsystem@iteration by-1\relax% + \let\pgf@lsystem@token=\pgfutil@empty% + \else% + \expandafter\def\expandafter\pgf@lsystem@token\expandafter{\pgf@lsystem@token \pgf@stop}% + \fi% + \fi% + \let\pgf@lsystem@next=\pgf@lsystem@run% + \fi% + \fi% + \expandafter\pgf@lsystem@next\pgf@lsystem@token} + +\def\pgf@lsystem@end#1\pgf@lsystem@stop{\endgroup} + +\def\pgf@lsystem@draw#1{% + \ifx#1\pgf@stop% + \let\pgf@lsystem@next=\relax% + \else% + \expandafter\let\expandafter\pgf@lsystem@current@symbol\expandafter=% + \csname pgf@lsystem@\pgf@lsystem@name @symbol@#1\endcsname% + \ifx\pgf@lsystem@current@symbol\relax% Try a default symbol. + \expandafter\let\expandafter\pgf@lsystem@current@symbol\expandafter=% + \csname pgf@lsystem@symbol@default@#1\endcsname% + \fi% + \let\pgf@lsystem@next=\pgf@lsystem@@draw% + \fi% + \pgf@lsystem@next} + +\def\pgf@lsystem@@draw{% + \edef\pgflsystemcurrentstep{\the\pgflsystemstep}% + \let\pgflsystemcurrentrightangle=\pgflsystemrightangle% + \let\pgflsystemcurrentrightangle=\pgflsystemleftangle% + \pgf@lsystem@current@symbol% + \pgf@lsystem@draw} + +\expandafter\def\csname pgf@lsystem@symbol@default@F\endcsname{\pgflsystemdrawforward} +\expandafter\def\csname pgf@lsystem@symbol@default@f\endcsname{\pgflsystemmoveforward} +\expandafter\def\csname pgf@lsystem@symbol@default@+\endcsname{\pgflsystemturnleft} +\expandafter\def\csname pgf@lsystem@symbol@default@-\endcsname{\pgflsystemturnright} +\expandafter\def\csname pgf@lsystem@symbol@default@[\endcsname{\pgflsystemsavestate} +\expandafter\def\csname pgf@lsystem@symbol@default@]\endcsname{\pgflsystemrestorestate} + +\def\pgflsystemradonmizestep{% + \ifpgf@lsystem@randomize@step% + \pgfmathrand% + \pgf@x=\pgflsystemrandomizesteppercent pt\relax% + \pgf@x=\pgfmathresult\pgf@x% + \divide\pgf@x by20\relax% + \advance\pgf@x by\pgflsystemstep\relax% + \edef\pgflsystemcurrentstep{\the\pgf@x}% + \else% + \edef\pgflsystemcurrentstep{\the\pgflsystemstep}% + \fi% +} + +\def\pgflsystemdrawforward{% + \pgflsystemradonmizestep + \pgftransformxshift{+\pgflsystemcurrentstep}% + \pgfpathlineto{\pgfpointorigin}} + +\def\pgflsystemmoveforward{% + \pgflsystemradonmizestep + \pgftransformxshift{+\pgflsystemcurrentstep}% + \pgfpathmoveto{\pgfpointorigin}} + +\def\pgflsystemranomizerightangle{% + \ifpgf@lsystem@randomize@angle% + \pgf@x=\pgflsystemrandomizeanglepercent pt\relax% + \divide\pgf@x by20\relax% + \pgfmathrand% + \pgf@x=\pgfmathresult\pgf@x% + \advance\pgf@x by\pgflsystemrightangle pt\relax% + \edef\pgflsystemcurrentrightangle{\pgfmath@tonumber{\pgf@x}}% + \else% + \let\pgflsystemcurrentrightangle=\pgflsystemrightangle% + \fi% +} + +\def\pgflsystemranomizeleftangle{% + \ifpgf@lsystem@randomize@angle% + \pgf@x=\pgflsystemrandomizeanglepercent pt\relax% + \divide\pgf@x by20\relax% + \pgfmathrand% + \pgf@x=\pgfmathresult\pgf@x% + \advance\pgf@x by\pgflsystemleftangle pt\relax% + \edef\pgflsystemcurrentleftangle{\pgfmath@tonumber{\pgf@x}}% + \else% + \let\pgflsystemcurrentleftangle=\pgflsystemleftangle% + \fi% +} + +\def\pgflsystemturnright{% + \pgflsystemranomizerightangle + \pgftransformrotate{-\pgflsystemcurrentrightangle}} + +\def\pgflsystemturnleft{% + \pgflsystemranomizeleftangle + \pgftransformrotate{\pgflsystemcurrentleftangle}} + +\def\pgflsystemsavestate{\begingroup} +\def\pgflsystemrestorestate{\endgroup\pgfpathmoveto{\pgfpointorigin}} diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarypatterns.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarypatterns.code.tex index c9c29958585..acfc3fa7b2e 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarypatterns.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarypatterns.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibrarypatterns.code.tex,v 1.12 2008/01/15 10:27:34 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibrarypatterns.code.tex,v 1.13 2008/03/03 13:52:35 tantau Exp $ % Lines in different directions @@ -241,6 +241,7 @@ } \pgfutil@definecolor{pgf@lightsteelblue}{rgb}{0.6875,0.765625,0.8671875} +\pgfutil@colorlet{pgf@darklightsteelblue}{black!50!pgf@lightsteelblue} \pgfdeclarepatterninherentlycolored{crosshatch dots light steel blue} {\pgfpointorigin}{\pgfpoint{8pt}{8pt}} @@ -249,11 +250,11 @@ \pgfsetfillcolor{pgf@lightsteelblue} \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{8pt}{8pt}} \pgfusepath{fill} - \pgfsetfillcolor{black!80!pgf@lightsteelblue!10} + \pgfsetfillcolor{pgf@darklightsteelblue!10} \pgfpathcircle{\pgfpoint{2pt}{1.75pt}}{1pt} \pgfpathcircle{\pgfpoint{6pt}{5.75pt}}{1pt} \pgfusepath{fill} - \pgfsetfillcolor{black!80!pgf@lightsteelblue!70} + \pgfsetfillcolor{pgf@darklightsteelblue!70} \pgfpathcircle{\pgfpoint{2pt}{2.25pt}}{1pt} \pgfpathcircle{\pgfpoint{6pt}{6.25pt}}{1pt} \pgfusepath{fill} diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothandlers.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothandlers.code.tex index a0f504431eb..5ab9e84a796 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothandlers.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothandlers.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplothandlers.code.tex,v 1.9 2007/03/09 17:49:32 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplothandlers.code.tex,v 1.15 2010/05/31 10:11:22 tantau Exp $ \newif\ifpgf@plot@started @@ -280,7 +280,8 @@ \def\pgf@plotstreamstart{% \global\let\pgf@plotstreampoint=\pgf@plot@xcomb@handler% \global\let\pgf@plotstreamspecial=\pgfutil@gobble% - \global\let\pgf@plotstreamend=\relax% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfplotxzerolevelstreamstart }% } @@ -288,7 +289,11 @@ \pgf@process{#1}% \pgf@xa=\pgf@x% \pgf@ya=\pgf@y% - \pgfpathmoveto{\pgfqpoint{0pt}{\pgf@ya}}% + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% } @@ -306,7 +311,8 @@ \def\pgf@plotstreamstart{% \global\let\pgf@plotstreampoint=\pgf@plot@ycomb@handler% \global\let\pgf@plotstreamspecial=\pgfutil@gobble% - \global\let\pgf@plotstreamend=\relax% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfplotyzerolevelstreamstart }% } @@ -314,12 +320,412 @@ \pgf@process{#1}% \pgf@xa=\pgf@x% \pgf@ya=\pgf@y% - \pgfpathmoveto{\pgfqpoint{\pgf@xa}{0pt}}% + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% } +% PGF Bar or comb plots usually draw something from zero to the current plot's coordinate. +% +% The 'zero' offset can be changed using an input stream. +% +% There are two such streams which can be configured independently. +% The first one returns "zeros" for coordinate x, the second one +% returns "zeros" for coordinate y. +% +% \pgfplotxzerolevelstreamstart +% \pgfplotxzerolevelstreamnext % assigns \pgf@x globally +% \pgfplotxzerolevelstreamnext +% \pgfplotxzerolevelstreamnext +% \pgfplotxzerolevelstreamend +% +% and +% \pgfplotyzerolevelstreamstart +% \pgfplotyzerolevelstreamnext % assigns \pgf@x globally +% \pgfplotyzerolevelstreamend +% +\def\pgfplotxzerolevelstreamstart{\pgf@plotxzerolevelstreamstart}% +\def\pgfplotxzerolevelstreamend{\pgf@plotxzerolevelstreamend}% +\def\pgfplotxzerolevelstreamnext{\pgf@plotxzerolevelstreamnext} +\def\pgfplotyzerolevelstreamstart{\pgf@plotyzerolevelstreamstart}% +\def\pgfplotyzerolevelstreamend{\pgf@plotyzerolevelstreamend}% +\def\pgfplotyzerolevelstreamnext{\pgf@plotyzerolevelstreamnext} + +% This zero level stream always returns '#1' (a dimension). +\def\pgfplotxzerolevelstreamconstant#1{% + \edef\pgfplotxzerolevelstreamconstant@val{#1}% + \def\pgf@plotxzerolevelstreamstart{% + \global\let\pgf@plotxzerolevelstreamend=\relax + \gdef\pgf@plotxzerolevelstreamnext{\global\pgf@x=\pgfplotxzerolevelstreamconstant@val\relax}% + }% +}% +\pgfplotxzerolevelstreamconstant{0pt}% + +% This zero level stream always returns '#1'. +\def\pgfplotyzerolevelstreamconstant#1{% + \edef\pgfplotyzerolevelstreamconstant@val{#1}% + \def\pgf@plotyzerolevelstreamstart{% + \global\let\pgf@plotyzerolevelstreamend=\relax + \gdef\pgf@plotyzerolevelstreamnext{\global\pgf@x=\pgfplotyzerolevelstreamconstant@val\relax}% + }% +}% +\pgfplotyzerolevelstreamconstant{0pt}% + +\def\pgfplotbarwidth{\pgfkeysvalueof{/pgf/bar width}} + +\pgfqkeys{/pgf}{% + bar width/.initial=10pt, + bar shift/.initial=0pt, + bar interval width/.initial=1, + bar interval shift/.initial=0.5, +} + +% This handler places a rectangle at each point in the plot stream, a +% rectangle which touches the x-axis at one end and the current point +% at the other end: +% --(X)-- +% | | +% | | +% | | +% --(0)-- +% Example: +% +% \pgfplothandlerybar +% \pgfplotxyfile{mytable} +\def\pgfplothandlerybar{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@ybar@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfmathparse{\pgfplotbarwidth}% + \xdef\pgfplotbarwidth@{\pgfmathresult pt}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar shift}}% + \xdef\pgfplotbarshift@{\pgfmathresult pt}% + \pgfplotyzerolevelstreamstart + }% +} +\def\pgf@plot@ybar@handler#1{% + \pgf@process{#1}% + \pgf@ya=\pgf@y + \expandafter\pgf@xb\pgfplotbarwidth@\relax + \pgf@xc=\pgf@x + \advance\pgf@xc by-.5\pgf@xb + \advance\pgf@xc by\pgfplotbarshift@\relax + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@xc}{\pgf@yb}}% + {\pgfqpoint{\pgf@xb}{\pgf@ya}}% +} +% This handler places a rectangle at each point in the plot stream, a +% rectangle which touches the y-axis at one end and the current point +% at the other end: +% --------- +% | | +% (0) (X) +% | | +% --------- +% Example: +% +% \pgfplothandlerxbar +% \pgfplotxyfile{mytable} +\def\pgfplothandlerxbar{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@xbar@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfmathparse{\pgfplotbarwidth}% + \xdef\pgfplotbarwidth@{\pgfmathresult pt}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar shift}}% + \xdef\pgfplotbarshift@{\pgfmathresult pt}% + \pgfplotxzerolevelstreamstart + }% +} + +\def\pgf@plot@xbar@handler#1{% + \pgf@process{#1}% + \pgf@ya=\pgf@x + \expandafter\pgf@xb\pgfplotbarwidth@\relax + \pgf@xc=\pgf@y + \advance\pgf@xc by-.5\pgf@xb + \advance\pgf@xc by\pgfplotbarshift@\relax + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@yb}{\pgf@xc}}% + {\pgfqpoint{\pgf@ya}{\pgf@xb}}% +} + +% This handler is a variant of \pgfplothandlerybar which works with +% intervals instead of points. +% +% Bars are drawn between successive input coordinates and the width is +% determined relatively to the interval length. +% +% It looks like this: +% +% |---| |-----| +% | | | | +% | | | | +% | | | | +% (X)------(X)-----------(X) +% +% where (X) denotes the x-axis offsets of input coordinates. +% +% In more detail, if (x_i,y_i) and (x_{i+1},y_{i+1}) denote successive +% input coordinates, the bar will be placed above the +% interval [x_i,x_{i+1}], centered at +% +% x_i + \pgfkeysvalueof{/pgf/bar interval shift} * (x_{i+1} - x_i) +% +% with width +% +% \pgfkeysvalueof{/pgf/bar interval width} * (x_{i+1} - x_i). +% +% If you have N+1 input points, you will get N bars (one for each +% interval). The y_i value of the last bar will be ignored. +% +% Example: +% +% \pgfplothandlerybarinterval +% \pgfplotxyfile{mytable} +\def\pgfplothandlerybarinterval{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler@first% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}% + \xdef\pgfplotbarintervalwidth@{\pgfmathresult}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}% + \xdef\pgfplotbarintervalshift@{\pgfmathresult}% + \pgfplotyzerolevelstreamstart + }% +} + +\def\pgf@plot@ybarinterval@handler@first#1{% + \pgf@process{#1}% + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}% + \xdef\pgf@plot@barinterval@bar{\the\pgf@y}% + \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler% +} +\def\pgf@plot@ybarinterval@handler#1{% + \pgf@process{#1}% + \pgf@ya=\pgf@plot@barinterval@bar + \xdef\pgf@plot@barinterval@bar{\the\pgf@y}% + \pgf@xc=\pgf@plot@barinterval@intervalstart\relax + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}% + \pgf@xb=\pgf@x + \advance\pgf@xb by-\pgf@xc + \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb + \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb + \advance\pgf@xc by-.5\pgf@xb% center + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@xc}{\pgf@yb}}% + {\pgfqpoint{\pgf@xb}{\pgf@ya}}% +} + +% Like \pgfplothandlerybarinterval but for xbar. +\def\pgfplothandlerxbarinterval{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler@first% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}% + \xdef\pgfplotbarintervalwidth@{\pgfmathresult}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}% + \xdef\pgfplotbarintervalshift@{\pgfmathresult}% + \pgfplotxzerolevelstreamstart + }% +} + +\def\pgf@plot@xbarinterval@handler@first#1{% + \pgf@process{#1}% + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}% + \xdef\pgf@plot@barinterval@bar{\the\pgf@x}% + \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler% +} +\def\pgf@plot@xbarinterval@handler#1{% + \pgf@process{#1}% + \pgf@ya=\pgf@plot@barinterval@bar + \xdef\pgf@plot@barinterval@bar{\the\pgf@x}% + \pgf@xc=\pgf@plot@barinterval@intervalstart\relax + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}% + \pgf@xb=\pgf@y + \advance\pgf@xb by-\pgf@xc + \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb + \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb + \advance\pgf@xc by-.5\pgf@xb% center + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@yb}{\pgf@xc}}% + {\pgfqpoint{\pgf@ya}{\pgf@xb}}% +} + + +% This handler is very similar to \pgfplothandlerlineto, but it +% produces CONSTANT connected pieces of the form +% +% x +% | +% x--- | +% | x---- +% x-| +% +% Example: +% +% \pgfplothandlerconstantlineto +% \pgfplotxyfile{mytable} +\def\pgfplothandlerconstantlineto{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@const@line@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler@@% +} +\def\pgf@plot@const@line@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@yb\pgf@plot@const@line@handler@last\relax + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}% +} + +% A variant of \pgfplothandlerconstantlineto which places its mark on +% the right line ends. +% +% |---x +% ---x | +% |--x +% x +% +% Example: +% +% \pgfplothandlerconstantlinetomarkright +% \pgfplotxyfile{mytable} +\def\pgfplothandlerconstantlinetomarkright{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@const@line@mark@right@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler@@% +} +\def\pgf@plot@const@line@mark@right@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@yb\pgf@plot@const@line@handler@last\relax + \pgfpathlineto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}% +} + +% This handler is in fact a variant of \pgfplothandlerconstantlineto, +% but it does not draw vertical lines. It produces a sequence of +% line-to and move-to operations such that plot marks are placed at +% each right end: +% +% ---x +% ---x +% ---x +% --x +% +% Example: +% +% \pgfplothandlerjumpmarkright +% \pgfplotxyfile{mytable} +\def\pgfplothandlerjumpmarkright{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@jumpmarkright@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler@@% +} +\def\pgf@plot@jumpmarkright@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@yb\pgf@plot@const@line@handler@last\relax + \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}% +} + +% This handler is in fact a variant of \pgfplothandlerconstantlineto, +% but it does not draw vertical lines. It produces a sequence of +% line-to and move-to operations such that plot marks are placed at +% each left end: +% +% x--- +% x--- +% x--- +% x-- +% +% Example: +% +% \pgfplothandlerjumpmarkleft +% \pgfplotxyfile{mytable} +\def\pgfplothandlerjumpmarkleft{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@jumpmarkleft@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler@@% +} +\def\pgf@plot@jumpmarkleft@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@yb\pgf@plot@const@line@handler@last\relax + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}% +} @@ -515,6 +921,102 @@ +% This handler turns creates a series of straight line segements +% between consecutive points, but leaving /pgf/gap around stream point +% space. +% +% Example: +% +% \pgfplothandlergaplineto +% \pgfplotxyfile{mytable} + +\pgfkeys{/pgf/gap around stream point/.initial=1.5pt} + +\def\pgfplothandlergaplineto{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@gap@lineto@handler@initial% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} + +\def\pgf@plot@gap@lineto@handler@initial#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@gap@lineto@last{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \global\let\pgf@plotstreampoint=\pgf@plot@gap@lineto@handler% +} + +\def\pgf@plot@gap@lineto@handler#1{% + % Ok, compute normalized line vector + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@gap@lineto@next{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@plot@gap@lineto@last}{\pgf@plot@gap@lineto@next}}}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgfpathmoveto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap + around stream point}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgf@plot@gap@lineto@last}}% + \pgfpathlineto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap + around stream point}}{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}}{\pgf@plot@gap@lineto@next}}% + \global\let\pgf@plot@gap@lineto@last=\pgf@plot@gap@lineto@next% +} + + + + +% This handler works like \pgfplothandlergaplineto, only the last +% point is connected to the first point, creating a closed curve +% space. +% +% Example: +% +% \pgfplothandlergapcycle +% \pgfplotxyfile{mytable} + +\def\pgfplothandlergapcycle{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@gap@cycle@handler@initial% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgf@plot@gap@cycle@handler@finish% + \global\let\pgf@plot@gap@cycle@first=\relax% + }% +} + +\def\pgf@plot@gap@cycle@handler@initial#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@gap@cycle@last{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \global\let\pgf@plot@gap@cycle@first=\pgf@plot@gap@cycle@last% + \global\let\pgf@plotstreampoint=\pgf@plot@gap@cycle@handler% +} + +\def\pgf@plot@gap@cycle@handler#1{% + % Ok, compute normalized line vector + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@gap@cycle@next{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@plot@gap@cycle@last}{\pgf@plot@gap@cycle@next}}}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgfpathmoveto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap + around stream point}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgf@plot@gap@cycle@last}}% + \pgfpathlineto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap + around stream point}}{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}}{\pgf@plot@gap@cycle@next}}% + \global\let\pgf@plot@gap@cycle@last=\pgf@plot@gap@cycle@next% +} + +\def\pgf@plot@gap@cycle@handler@finish{% + \ifx\pgf@plot@gap@cycle@first\relax% + \else + \pgf@plot@gap@cycle@handler{\pgf@plot@gap@cycle@first}% + \fi +} + \endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryplotmarks.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryplotmarks.code.tex index e20805d50a1..57df579e3f3 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryplotmarks.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryplotmarks.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplotmarks.code.tex,v 1.5 2007/03/09 17:49:32 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplotmarks.code.tex,v 1.12 2010/10/15 07:34:06 ludewich Exp $ % A stroked circle mark @@ -19,6 +19,32 @@ } +% A Mercedes-line star + +\pgfdeclareplotmark{Mercedes star} +{% + \pgfpathmoveto{\pgfqpointpolar{90}{\pgfplotmarksize}} + \pgfpathlineto{\pgfpointorigin} + \pgfpathmoveto{\pgfqpointpolar{-30}{\pgfplotmarksize}} + \pgfpathlineto{\pgfpointorigin} + \pgfpathmoveto{\pgfqpointpolar{-150}{\pgfplotmarksize}} + \pgfpathlineto{\pgfpointorigin} + \pgfusepathqstroke +} + +\pgfdeclareplotmark{Mercedes star flipped} +{% + \pgfpathmoveto{\pgfqpointpolar{-90}{\pgfplotmarksize}} + \pgfpathlineto{\pgfpointorigin} + \pgfpathmoveto{\pgfqpointpolar{30}{\pgfplotmarksize}} + \pgfpathlineto{\pgfpointorigin} + \pgfpathmoveto{\pgfqpointpolar{150}{\pgfplotmarksize}} + \pgfpathlineto{\pgfpointorigin} + \pgfusepathqstroke +} + + + % A six-pointed star mark @@ -47,6 +73,19 @@ } +% An 10-pointed star mark + +\pgfdeclareplotmark{10-pointed star} +{% + \pgfpathmoveto{\pgfqpoint{0pt}{-\pgfplotmarksize}}\pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}} + \pgfpathmoveto{\pgfqpointpolar{18}{-\pgfplotmarksize}}\pgfpathlineto{\pgfqpointpolar{18}{\pgfplotmarksize}} + \pgfpathmoveto{\pgfqpointpolar{-54}{-\pgfplotmarksize}}\pgfpathlineto{\pgfqpointpolar{-54}{\pgfplotmarksize}} + \pgfpathmoveto{\pgfqpointpolar{234}{-\pgfplotmarksize}}\pgfpathlineto{\pgfqpointpolar{234}{\pgfplotmarksize}} + \pgfpathmoveto{\pgfqpointpolar{162}{-\pgfplotmarksize}}\pgfpathlineto{\pgfqpointpolar{162}{\pgfplotmarksize}} + \pgfusepathqstroke +} + + % An \oplus mark \pgfdeclareplotmark{oplus} @@ -209,4 +248,206 @@ \pgfusepathqfillstroke } +\newif\ifpgfmarktext@usetikznode +\pgfkeys{ + /pgf/text mark/.initial=p, + /pgf/text mark style/.initial=, + /pgf/text mark as node/.is if=pgfmarktext@usetikznode, + /pgf/text mark as node/.default=true, + % + % backw. compat: the extra search path confuses the '.unknown' + % handlers, so this here is deprecated: + /pgf/text mark/style/.style={/pgf/text mark style={#1}},% + /pgf/text mark/as node/.style={/pgf/text mark as node=#1},% +}% + +\pgfdeclareplotmark{text} +{ + \pgfkeysgetvalue{/pgf/text mark style}\pgfmarktext@style + \pgfkeysgetvalue{/pgf/text mark}\pgfmarktext@ + \ifpgfmarktext@usetikznode + \expandafter\node\expandafter[\pgfmarktext@style]{\pgfmarktext@}; + \else + \expandafter\pgftext\expandafter[\pgfmarktext@style]{\pgfmarktext@}% + \fi +} + +\pgfkeysdef{/pgf/mark color}{\def\pgf@mark@color{#1}} +\let\pgf@mark@color\pgfutil@empty + +\def\pgf@set@mark@color{% + \ifx\pgf@mark@color\pgfutil@empty + \pgfsys@color@rgb@fill{1}{1}{1}% + \else + \pgfsetfillcolor{\pgf@mark@color}% + \fi +}% +\def\pgf@mark@color@none{none}% + +% A half-down-filled and half-up-filled-white diamond-shaped mark +% (the shape can be rotated by "mark options = {rotate = 90}") +% created by Tomek + +\pgfdeclareplotmark{halfcircle}{% + \ifx\pgf@mark@color@none\pgf@mark@color + \else + \pgfscope + \pgf@set@mark@color + \pgfpathmoveto + {\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpatharc{180}{360}{\pgfplotmarksize}% + \pgfusepathqfill + \endpgfscope% + \fi + \pgfpathmoveto + {\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpathlineto + {\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfpathcircle{\pgfpointorigin}% + {\pgfplotmarksize}% + \pgfusepathqstroke +} +\pgfdeclareplotmark{halfcircle*}{% + \pgfpathmoveto + {\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfpatharc{0}{180}{\pgfplotmarksize}% + \pgfpathclose + \pgfusepathqfill + \ifx\pgf@mark@color@none\pgf@mark@color + \else + \pgfscope + \pgf@set@mark@color + \pgfpathmoveto + {\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpatharc{180}{360}{\pgfplotmarksize}% + \pgfusepathqfill + \endpgfscope% + \fi + \pgfpathcircle{\pgfpointorigin}% + {\pgfplotmarksize}% + \pgfusepathqstroke +} + +% A half-down-filled and half-up-filled-white diamond-shaped mark +% created by Magnus Tewes + +\pgfdeclareplotmark{halfdiamond*}{% + \pgfpathmoveto{\pgfqpoint{-.75\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{.75\pgfplotmarksize}{0pt}}% + \pgfusepathqfill + \ifx\pgf@mark@color@none\pgf@mark@color + \else + \pgfscope + \pgf@set@mark@color + \pgfpathmoveto{\pgfqpoint{.75\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{-.75\pgfplotmarksize}{0pt}}% + \pgfusepathqfill + \endpgfscope + \fi + \pgfpathmoveto{\pgfqpoint{.75\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{-.75\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathclose + \pgfusepathqstroke +} + +% A half-down-filled and half-up-filled-white tilted-squared-shaped mark +% created by Magnus Tewes + +\pgfdeclareplotmark{halfsquare*}{% + \pgfpathmoveto{\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfusepathqfill + \ifx\pgf@mark@color@none\pgf@mark@color + \else + \pgfscope + \pgf@set@mark@color + \pgfpathmoveto{\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfusepathqfill + \endpgfscope + \fi + \pgfpathmoveto{\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathclose + \pgfusepathqstroke +} + +% A half-right-filled and half-up-filled-white tilted-squared-shaped mark +% created by Magnus Tewes + +\pgfdeclareplotmark{halfsquare right*}{% + \pgfpathmoveto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfusepathqfill + \ifx\pgf@mark@color@none\pgf@mark@color + \else + \pgfscope + \pgf@set@mark@color + \pgfpathmoveto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfusepathqfill + \endpgfscope + \fi + \pgfpathmoveto{\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathclose + \pgfusepathqstroke +} + +% A half-left-filled and half-up-filled-white tilted-squared-shaped mark +% created by Magnus Tewes + +\pgfdeclareplotmark{halfsquare left*}{% + \pgfpathmoveto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfusepathqfill + \ifx\pgf@mark@color@none\pgf@mark@color + \else + \pgfscope + \pgf@set@mark@color + \pgfpathmoveto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfusepathqfill + \endpgfscope + \fi + \pgfpathmoveto{\pgfqpoint{\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{\pgfplotmarksize}}% + \pgfpathlineto{\pgfqpoint{-\pgfplotmarksize}{0pt}}% + \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}% + \pgfpathclose + \pgfusepathqstroke +} + + +% A stroke-filled heart-shaped mark +% created by Magnus Tewes +\pgfdeclareplotmark{heart}{% + \pgfpathmoveto{\pgfqpoint{0pt}{-1.75\pgfplotmarksize}} + \pgfpathcurveto{\pgfqpoint{0pt}{-1.75\pgfplotmarksize}}{\pgfqpoint{0pt}{-1.66\pgfplotmarksize}}{\pgfqpoint{-.5\pgfplotmarksize}{-1.165\pgfplotmarksize}} + \pgfpathcurveto{\pgfqpoint{-.5\pgfplotmarksize}{-1.165\pgfplotmarksize}}{\pgfqpoint{-\pgfplotmarksize}{-.75\pgfplotmarksize}}{\pgfqpoint{-\pgfplotmarksize}{0pt}} + \pgfpathcurveto{\pgfqpoint{-\pgfplotmarksize}{0pt}}{\pgfqpoint{-\pgfplotmarksize}{.5825\pgfplotmarksize}}{\pgfqpoint{-.5825\pgfplotmarksize}{.5825\pgfplotmarksize}} + \pgfpathcurveto{\pgfqpoint{-.5825\pgfplotmarksize}{.5825\pgfplotmarksize}}{\pgfqpoint{0pt}{.5825\pgfplotmarksize}}{\pgfqpoint{0pt}{0pt}} + \pgfpathcurveto{\pgfqpoint{0pt}{0pt}}{\pgfqpoint{0pt}{.5825\pgfplotmarksize}}{\pgfqpoint{.5825\pgfplotmarksize}{.5825\pgfplotmarksize}} + \pgfpathcurveto{\pgfqpoint{.5825\pgfplotmarksize}{.5825\pgfplotmarksize}}{\pgfqpoint{\pgfplotmarksize}{.5825\pgfplotmarksize}}{\pgfqpoint{\pgfplotmarksize}{0pt}} + \pgfpathcurveto{\pgfqpoint{\pgfplotmarksize}{0pt}}{\pgfqpoint{\pgfplotmarksize}{-.75\pgfplotmarksize}}{\pgfqpoint{.5\pgfplotmarksize}{-1.165\pgfplotmarksize}} + \pgfpathcurveto{\pgfqpoint{.5\pgfplotmarksize}{-1.165\pgfplotmarksize}}{\pgfqpoint{0pt}{-1.66\pgfplotmarksize}}{\pgfqpoint{0pt}{-1.75\pgfplotmarksize}} + \pgfpathclose + \pgfusepathqfillstroke +} + + \endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex new file mode 100644 index 00000000000..1043825d60f --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex @@ -0,0 +1,515 @@ +%-------------------------------------------- +% +% TeX profiling library +% +% Copyright 2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +\pgfutil@ifundefined{pdfelapsedtime}{% + \PackageError{pgf}{library 'profiler' can only be used with pdftex Rev. >= 1.671 because it needs the \string\pdfelapsedtime\space command}{}% + \global\let\pdfelapsedtime=\c@pgf@counta +}{} + + +% Defines a new profiler entry named `#1'. +% +% This allocates a set of counters. +\def\pgfprofilenew#1{% + \pgfutil@ifundefined{c@pgfprofile@elapsedtotal@#1}{% + \expandafter\gdef\csname c@pgfprofile@elapsedtotal@#1\endcsname{0}% + \expandafter\gdef\csname c@pgfprofile@elapsedself@#1\endcsname{0}% + \expandafter\gdef\csname c@pgfprofile@numinvocations@#1\endcsname{0}% + \expandafter\gdef\csname c@pgfprofile@subtractforself@#1\endcsname{0}% + \expandafter\gdef\csname c@pgfprofile@semaphor@#1\endcsname{0}% + \expandafter\gdef\csname c@pgfprofile@elapsed@at@start@#1\endcsname{0}% + \pgfprofile@all@registered@list@add{#1}% + }{% + % it is already defined and registered. Shouldn't hurt, might + % even be a good feature. + }% +}% + +\def\pgfprofile@TeX@DIALECT@toenvironment@begin#1{\csname #1\endcsname}% +\def\pgfprofile@TeX@DIALECT@toenvironment@end#1{\csname end#1\endcsname}% + +\def\pgfprofile@@to@pgfretval#1{% + \expandafter\let\expandafter\pgfretval#1% +}% + +% Defines a new profiler entry for the environment `#1'. +% +% This calls \pgfprofilenew and handles the begin/end of the +% environment automatically. +% +% #1 the environment name (a string) +% +% Optionally in square brackets: the profiler entry name +% \pgfprofilenewforenvironment{<environment name>} +% \pgfprofilenewforenvironment[<profiler entry name>]{<environment name>} +\def\pgfprofilenewforenvironment{\pgfutil@ifnextchar[{\pgfprofilenewforenvironment@}{\pgfprofilenewforenvironment@[]}}% +\def\pgfprofilenewforenvironment@[#1]#2{% + \expandafter\pgfprofile@@to@pgfretval\pgfprofile@TeX@DIALECT@toenvironment@begin{#2}% + \ifx\pgfretval\relax + \PackageError{pgf}{\string\pgfprofilenewforenvironment{#2} doesn't work: the environment `#2' is (not yet?) known or not known in this context}{}% + \else + \expandafter\global\expandafter\let\csname pgfprofile@orig@begin@#2\endcsname=\pgfretval + \expandafter\pgfprofile@@to@pgfretval\pgfprofile@TeX@DIALECT@toenvironment@end{#2}% + \expandafter\global\expandafter\let\csname pgfprofile@orig@end@#2\endcsname=\pgfretval + % + \def\pgfprofile@temp{#1}% + \ifx\pgfprofile@temp\pgfutil@empty + \pgfprofilenewforenvironment@@{\pgfprofileenv #2}{#2}% + \else + \pgfprofilenewforenvironment@@{#1}{#2}% + \fi + \fi +}% +\def\pgfprofilenewforenvironment@@#1#2{% + \pgfprofilenew{#1}% + \expandafter\expandafter\expandafter\gdef\pgfprofile@TeX@DIALECT@toenvironment@begin{#2}{% + \pgfprofilestart{#1}% + \csname pgfprofile@orig@begin@#2\endcsname + }% + \expandafter\expandafter\expandafter\gdef\pgfprofile@TeX@DIALECT@toenvironment@end{#2}{% + \csname pgfprofile@orig@end@#2\endcsname + \pgfprofileend{#1}% + }% +} + + +\def\pgfprofilecs{<CS>}% +\def\pgfprofileenv{<ENV>}% + +% Defines a new profiler entry for the control sequence '#1'. +% +% This calls \pgfprofilenew and enhances the control sequence with +% support for timings. +% +% #1: the control sequence (with backslash!) +% #2: the number of arguments (see below). +% +% The following commands are supported: +% - commands which take one (optional) argument in square brackets, +% - commands which take one (optional) argument in square brackets +% followed by one optional argument which has to be delimited with +% curly braces (use an empty argument for '#2' in this case), +% - commands which take one (optional) argument in square brackets +% and *exactly* #2 arguments afterwards. +\def\pgfprofilenewforcommand{\pgfutil@ifnextchar[{\pgfprofilenewforcommand@}{\pgfprofilenewforcommand@[]}} +\def\pgfprofilenewforcommand@[#1]#2#3{% + \def\pgfprofile@temp{#3}% + \ifx\pgfprofile@temp\pgfutil@empty + \pgfprofilenewforcommandpattern[#1]{#2}{<autocheck>}{}% + \else + \ifcase#3\relax + \pgfprofilenewforcommandpattern[#1]{#2}{}{}% + \or + \pgfprofilenewforcommandpattern[#1]{#2}{##1}{{##1}}% + \or + \pgfprofilenewforcommandpattern[#1]{#2}{##1##2}{{##1}{##2}}% + \or + \pgfprofilenewforcommandpattern[#1]{#2}{##1##2##3}{{##1}{##2}{##3}}% + \or + \pgfprofilenewforcommandpattern[#1]{#2}{##1##2##3##4}{{##1}{##2}{##3}{##4}}% + \or + \pgfprofilenewforcommandpattern[#1]{#2}{##1##2##3##4##5}{{##1}{##2}{##3}{##4}{##5}}% + \or + \pgfprofilenewforcommandpattern[#1]{#2}{##1##2##3##4##5##6}{{##1}{##2}{##3}{##4}{##5}{##6}}% + \or + \pgfprofilenewforcommandpattern[#1]{#2}{##1##2##3##4##5##6##7}{{##1}{##2}{##3}{##4}{##5}{##6}{##7}}% + \else + \PackageError{pgf}{library 'profiler' can't replace control sequences with '#3' arguments automatically, sorry.}% + \fi + \fi +}% + +% \pgfprofilenewforcommandpattern[<profile entry name>]{<\CS>}{<definition pattern>}{<invocation pattern>} +% +% example: +% \pgfprofilenewforcommandpattern{\pgfqkeys}{##1##2}{{##1}{##2}} +% +% \def\mymacro##1\to##2\in##3{ .... } +% \pgfprofilenewforcommandpattern{\mymacro}{##1\to##2\in##3}{{##1}\to{##2}\in{##3}} +\def\pgfprofilenewforcommandpattern{\pgfutil@ifnextchar[{\pgfprofilenewforcommandpattern@}{\pgfprofilenewforcommandpattern@[]}} +\def\pgfprofilenewforcommandpattern@[#1]#2#3#4{% + \def\pgfprofile@known{1}% + \ifx#2\undefined + \def\pgfprofile@known{0}% + \else + \ifx#2\relax + \def\pgfprofile@known{0}% + \fi + \fi + \if\pgfprofile@known0% + \PackageError{pgf}{\string\pgfprofilenewforcommandpattern{\string#2} doesn't work: the command `\string#2' is (not yet?) known or not known in this context}{}% + \else + \begingroup + \pgfprofile@cs@to@name{#2}% + \let\pgfprofilenew@cmdname=\pgfretval + % + \def\pgfprofile@temp{#1}% + \ifx\pgfprofile@temp\pgfutil@empty + \edef\pgfprofilenew@profilerentryname{\pgfprofilecs\pgfprofilenew@cmdname}% + \else + \edef\pgfprofilenew@profilerentryname{#1}% + \fi + \expandafter\global\expandafter\let\csname pgfprofile@name@for@\pgfprofilenew@cmdname\endcsname=\pgfprofilenew@profilerentryname + \pgfprofilenew{\pgfprofilenew@profilerentryname}% + \expandafter\gdef\csname b@pgfprofile@show@\pgfprofilenew@profilerentryname\endcsname{0}% + % + \expandafter\global\expandafter\let\csname pgfprofile@orig@\pgfprofilenew@cmdname\endcsname=#2% + \toks0={#3}% + \edef\pgfprofile@temp{\the\toks0}%% + \def\pgfprofile@tempb{<autocheck>}% + \ifx\pgfprofile@temp\pgfprofile@tempb + \expandafter\global\expandafter\let\csname pgfprofile@repl@\pgfprofilenew@cmdname\endcsname=\pgfprofileinvokecommand@uptoonearg + \else + \expandafter\gdef\csname pgfprofile@repl@\pgfprofilenew@cmdname\endcsname#3{% + \pgfprofile@invokeorig{#4}% + }% + \fi + \xdef#2{\noexpand\pgfprofileinvokecommand{\pgfprofilenew@cmdname}}% + \endgroup + \fi +}% + +\def\pgfprofileshowinvocationsfor#1{% + \pgfutil@ifundefined{b@pgfprofile@show@#1}{% + \PackageError{pgf}{\string\pgfprofileshowinvocationsfor{#1} doesn't work: the argument is no profiler entry}{}% + }{% + \expandafter\gdef\csname b@pgfprofile@show@#1\endcsname{1}% + \expandafter\gdef\csname b@pgfprofile@show@edef@#1\endcsname{0}% + }% +}% +\def\pgfprofileshowinvocationsexpandedfor#1{% + \pgfutil@ifundefined{b@pgfprofile@show@#1}{% + \PackageError{pgf}{\string\pgfprofileshowinvocationsfor{#1} doesn't work: the argument is no profiler entry}{}% + }{% + \expandafter\gdef\csname b@pgfprofile@show@#1\endcsname{1}% + \expandafter\gdef\csname b@pgfprofile@show@edef@#1\endcsname{1}% + }% +}% + +\def\pgfprofile@no@optional@arg@text{<noarg>} +\def\pgfprofileinvokecommand#1{% + \pgfutil@ifnextchar[{\pgfprofileinvokecommand@{#1}}{\pgfprofileinvokecommand@{#1}[<noarg>]}% +}% +\def\pgfprofileinvokecommand@#1[#2]{% + \def\pgfprofileinvokecommand@cs{#1}% + \def\pgfprofileinvokecommand@optarg{#2}% + \edef\pgfprofileinvokecommand@profilerentryname{\csname pgfprofile@name@for@#1\endcsname}% + \csname pgfprofile@repl@#1\endcsname% +}% + +% #1 contains ALL arguments, including any braces. +\def\pgfprofile@invokeorig#1{% + % re-insert the control sequence name and the optional argument: + % this wasn't possible directly. + \begingroup + \toks1=\expandafter{\pgfprofileinvokecommand@optarg}% + \toks2={#1}% + \toks3=\expandafter{\csname pgfprofile@orig@\pgfprofileinvokecommand@cs\endcsname}% + % + \ifx\pgfprofileinvokecommand@optarg\pgfprofile@no@optional@arg@text + % no [] argument after original command: + \xdef\pgfprofile@invokeorig@doitfinally{\the\toks3 \the\toks2 }%% + \else + \xdef\pgfprofile@invokeorig@doitfinally{\the\toks3[\the\toks1]\the\toks2 }% + \fi + \if1\csname b@pgfprofile@show@\pgfprofileinvokecommand@profilerentryname\endcsname + \pgfprofile@orig@show + \fi + \endgroup + \edef\pgfprofile@temp{{\pgfprofileinvokecommand@cs}{\pgfprofileinvokecommand@profilerentryname}}% + \expandafter\pgfprofile@invokeorig@\pgfprofile@temp% +}% +\def\pgfprofile@orig@show{% + \toks4=\expandafter{\csname\pgfprofileinvokecommand@cs\endcsname}% + \ifx\pgfprofileinvokecommand@optarg\pgfprofile@no@optional@arg@text + \def\pgfprofile@orig@show@args{\the\toks2 }% + \else + \def\pgfprofile@orig@show@args{[\the\toks1] \the\toks2 }% + \fi + \if1\csname b@pgfprofile@show@edef@\pgfprofileinvokecommand@profilerentryname\endcsname + \edef\pgfprofile@orig@show@args{\pgfprofile@orig@show@args}% + \edef\pgfprofile@orig@show@args{\pgfprofile@orig@show@args}% + \fi + \immediate\write16{pgflibraryprofiler: calling + \#\csname c@pgfprofile@numinvocations@\pgfprofileinvokecommand@profilerentryname\endcsname\space + (\the\toks4 \pgfprofile@orig@show@args)}% +}% + +% #1: control sequence name (without backslash) +% #2: profiler entry name +\def\pgfprofile@invokeorig@#1#2{% + % this check should avoid save stack impact + \pgfprofileifisrunning{#2}{% + \pgfprofile@invokeorig@doitfinally% + }{% + \pgfprofilestart{#2}% + \pgfprofile@invokeorig@doitfinally% + \pgfprofileend{#2}% + }% +}% + + +\def\pgfprofileinvokecommand@uptoonearg{% + \pgfutil@ifnextchar\bgroup{\pgfprofileinvokecommand@onearg}{\pgfprofileinvokecommand@noarg}% +}% +\def\pgfprofileinvokecommand@onearg#1{% + \pgfprofile@invokeorig{{#1}}% +}% +\def\pgfprofileinvokecommand@noarg{% + \pgfprofile@invokeorig{}% +}% + + + +% Starts / Resumes timing of the profiler entry named `#1'. +% +% The timing will continue until \pgfprofileend{#1} is called. +% +% Nested calls of \pgfprofilestart{#1} (with the same argument) will +% result in the same result as if just one \pgfprofilestart command +% has been issued. +\def\pgfprofilestart#1{% + \pgfprofileifisrunning{#1}{% + \relax + }{% + \expandafter\xdef\csname c@pgfprofile@elapsed@at@start@#1\endcsname{\the\pdfelapsedtime}% + \expandafter\gdef\csname c@pgfprofile@subtractforself@#1\endcsname{0}% + \pgfprofile@advance{c@pgfprofile@numinvocations@#1}{1}% + \pgfprofilestackpush{#1}% + }% + \pgfprofile@advance{c@pgfprofile@semaphor@#1}{1}% +}% + +% Stops / Interrupts timing of the profiler entry named `#1'. +\def\pgfprofileend#1{% + \pgfprofile@advance{c@pgfprofile@semaphor@#1}{-1}% + \pgfprofileifisrunning{#1}{% + \relax + }{% + \begingroup + \c@pgf@countb=\pdfelapsedtime\relax + \advance\c@pgf@countb by-\csname c@pgfprofile@elapsed@at@start@#1\endcsname\relax + % + \pgfprofilestackpop\pgfretval + \edef\pgfprofile@temp{#1}% + \ifx\pgfprofile@temp\pgfretval + \else + \immediate\write16{pgflibraryprofiler WARNING: possible error in self time computation...}% + \fi + \pgfprofilestackifempty{% + \relax + }{% + \pgfprofilestacktop\pgfretval + \pgfprofile@advance{c@pgfprofile@subtractforself@\pgfretval}{\c@pgf@countb}% + }% + % + \pgfprofile@advance{c@pgfprofile@elapsedtotal@#1}{\c@pgf@countb}% + \advance\c@pgf@countb by-\csname c@pgfprofile@subtractforself@#1\endcsname\relax + \pgfprofile@advance{c@pgfprofile@elapsedself@#1}{\c@pgf@countb}% + \endgroup + }% +}% + +% invokes '#2' if '#1' is currently running and '#3' if not. +\def\pgfprofileifisrunning#1#2#3{% + \ifnum\csname c@pgfprofile@semaphor@#1\endcsname=0 \def\pgfprofileifisrunning@next{#3}\else \def\pgfprofileifisrunning@next{#2}\fi + \pgfprofileifisrunning@next +}% + +% Sets the profiler entry whose total time is used to compute all +% other relative times. +\def\pgfprofilesetrel#1{\edef\pgfprofile@rel{#1}}% + +% Stops all running timings and postprocesses them. +\def\pgfprofilepostprocess{% + \begingroup + % + % prepare files. + \c@pgf@countb=\time + \divide\c@pgf@countb by60 + \c@pgf@countd=\c@pgf@countb + \multiply\c@pgf@countd by60 + \c@pgf@countc=\time + \advance\c@pgf@countc by-\c@pgf@countd + \immediate\openout\w@pgf@writea=\jobname.profiler.\the\year-\pgfprofiletotwodigitstr\month-\pgfprofiletotwodigitstr\day_\pgfprofiletotwodigitstr\c@pgf@countb h_\pgfprofiletotwodigitstr\c@pgf@countc m.dat + \immediate\write\w@pgf@writea{% + \pgfprofile@percent relative values are measured against the totaltime of `\pgfprofile@rel'.% + }% + \immediate\write16{pgflibraryprofiler: relative values are measured against the totaltime of `\pgfprofile@rel'.}% + \immediate\write\w@pgf@writea{% + profilerentry\pgfprofile@TAB + totaltime[s]\pgfprofile@TAB + totaltime[percent]\pgfprofile@TAB + selftime[s]\pgfprofile@TAB + selftime[percent]\pgfprofile@TAB + numinvocations\pgfprofile@TAB}% + % + % + % compute main time and prepare computation of relative times: + \pgfprofileifisrunning{\pgfprofile@rel}{% + \pgfprofileend{\pgfprofile@rel}% + }{}% + \pgf@xa=\csname c@pgfprofile@elapsedtotal@\pgfprofile@rel\endcsname sp + \edef\pgfprofiletotaltime{\pgf@sys@tonumber\pgf@xa}% + \pgfmathreciprocal@{\pgfprofiletotaltime}% + \let\pgfprofiletotaltime@inv=\pgfmathresult + % + % postprocess each of them: + \pgfprofile@all@registered@list@foreach{% + \pgfprofileifisrunning{##1}{% + \pgfprofileend{##1}% + }{}% + \pgfprofilepostprocess@single{##1}% + }% + \immediate\write\w@pgf@writea{% + \pgfprofile@percent\space vim: ts=40 nowrap nostartofline + }% + \immediate\closeout\w@pgf@writea + \endgroup +}% + +{% +\catcode`\[=1 % +\catcode`\]=2 % +\catcode`\{=12 % +\catcode`\}=12 % +\catcode`\^^I=12 +\gdef\pgfprofile@lbrace[{]% +\gdef\pgfprofile@rbrace[}]% +\gdef\pgfprofile@TAB[^^I]% +] +{ +\catcode`\%=12 \gdef\pgfprofile@percent{%}} + +\def\pgfprofilepostprocess@single#1{% + \begingroup + \pgf@xa=\csname c@pgfprofile@elapsedtotal@#1\endcsname sp + \pgf@xb=\csname c@pgfprofile@elapsedself@#1\endcsname sp + \pgf@ya=\pgfprofiletotaltime@inv\pgf@xa + \pgf@yb=\pgfprofiletotaltime@inv\pgf@xb + \multiply\pgf@ya by100 + \multiply\pgf@yb by100 + \edef\pgfprofilecur@total{\pgf@sys@tonumber\pgf@xa}% + \edef\pgfprofilecur@self{\pgf@sys@tonumber\pgf@xb}% + \edef\pgfprofilecur@total@rel{\pgf@sys@tonumber\pgf@ya}% + \edef\pgfprofilecur@self@rel{\pgf@sys@tonumber\pgf@yb}% + \immediate\write16{ + pgflibraryprofiler(#1) + \pgfprofile@lbrace + total time=\pgfprofilecur@total sec; (\pgfprofilecur@total@rel\pgfprofile@percent) + self time=\pgfprofilecur@self sec; (\pgfprofilecur@self@rel\pgfprofile@percent) + invocations=\csname c@pgfprofile@numinvocations@#1\endcsname; + \pgfprofile@rbrace + }% + \immediate\write\w@pgf@writea{% + #1\pgfprofile@TAB + \pgfprofilecur@total\pgfprofile@TAB + \pgfprofilecur@total@rel\pgfprofile@TAB + \pgfprofilecur@self\pgfprofile@TAB + \pgfprofilecur@self@rel\pgfprofile@TAB + \csname c@pgfprofile@numinvocations@#1\endcsname\pgfprofile@TAB + }% + \endgroup +}% +% Invokes '#2' for each element of the command separated list '#1'. +% the current list element is available as '#1' inside of '#2'. +\long\def\pgfprofileforeachentryinCSV#1#2{% + \long\def\pgfprofileinvokeforeach@@##1{#2}% + \pgfprofileforeachentryinCSVisterminated@loop#1,\pgfeov +}% +\long\def\pgfprofileforeachentryinCSVisterminated@loop{% + \pgfutil@ifnextchar\pgfeov{\pgfutil@gobble}{\pgfprofileforeachentryinCSV@next}% +}% +\long\def\pgfprofileforeachentryinCSV@next#1,{% + \pgfprofileinvokeforeach@@{#1}% + \pgfprofileforeachentryinCSVisterminated@loop% +}% + +\xdef\pgfprofile@all@registered@list{} +\xdef\pgfprofile@currently@running@list{} + +\def\pgfprofile@all@registered@list@add#1{% + \ifx\pgfprofile@all@registered@list\pgfutil@empty + \xdef\pgfprofile@all@registered@list{#1}% + \else + \xdef\pgfprofile@all@registered@list{\pgfprofile@all@registered@list,#1}% + \fi +}% + +\def\pgfprofile@all@registered@list@foreach#1{% + \expandafter\pgfprofileforeachentryinCSV\expandafter{\pgfprofile@all@registered@list}{#1}% +}% + +\def\pgfprofile@advance#1#2{% + \begingroup + \c@pgf@counta=\csname #1\endcsname\relax + \advance\c@pgf@counta by#2\relax + \expandafter\xdef\csname #1\endcsname{\the\c@pgf@counta}% + \endgroup +}% + +\def\pgfprofile@cs@to@name@#1#2\relax{\def\pgfretval{#2}} + +% defines '\pgfretval' to be the control sequences name of '#1' *without* the backslash. +\def\pgfprofile@cs@to@name#1{% + \expandafter\pgfprofile@cs@to@name@\string#1\relax +}% + +\newcount\c@pgfprofile@stacktop + +\c@pgfprofile@stacktop=-1 +\def\pgfprofilestackpush#1{% + \global\advance\c@pgfprofile@stacktop by1 + \expandafter\xdef\csname pgfprofile@stack@\the\c@pgfprofile@stacktop\endcsname{#1}% +}% +% pops the current stack top to macro #1 +\def\pgfprofilestackpop#1{% + \pgfprofilestacktop#1% + \global\advance\c@pgfprofile@stacktop by-1 +}% +% returns the stack's top to macro #1 +\def\pgfprofilestacktop#1{% + \expandafter\let\expandafter#1\csname pgfprofile@stack@\the\c@pgfprofile@stacktop\endcsname +}% +\def\pgfprofilestackifempty#1#2{% + \ifnum\c@pgfprofile@stacktop<0 #1\else #2\fi +}% + + +\def\pgfprofiletotwodigitstr#1{\ifnum#1<10 0\the#1\else\the#1\fi} + +\pgfprofilenew{main job} +\pgfprofilestart{main job} +\expandafter\xdef\csname c@pgfprofile@elapsed@at@start@main job\endcsname{0}% +\pgfprofilesetrel{main job} + +\pgfutil@ifundefined{AtEndDocument}{% + % no latex. ok. +}{% + % do latex specific stuff: + \pgfprofilenew{preamble} + \pgfprofilestart{preamble} + \expandafter\xdef\csname c@pgfprofile@elapsed@at@start@preamble\endcsname{0}% + \AtBeginDocument{\pgfprofileend{preamble}}% + % + \AtEndDocument{\pgfprofilepostprocess}% +}% +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshadings.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshadings.code.tex new file mode 100644 index 00000000000..285f6d21772 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshadings.code.tex @@ -0,0 +1,409 @@ +% Copyright 2008 by Till Tantau and others +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshadings.code.tex,v 1.2 2008/10/29 23:06:34 tantau Exp $ + + +% +% An hsv color wheel. Initial code graciously donated by Ken Starks. +% + +\pgfdeclarefunctionalshading{color wheel white center} +{\pgfpoint{-50bp}{-50bp}} +{\pgfpoint{50bp}{50bp}} +{} +{ % x y + 2 copy % ... x y x y + 2 copy abs exch abs add 0.0001 ge + {atan 360.0 div} % ... x y heading; heading being in + %the interval [0, 1.0] + { pop } % silently deal with error: return + % arbitrary heading of zero for origin + ifelse % because we will use it for 'Hue' + 3 1 roll % ... heading x y + dup mul % ... heading x y*y + exch dup mul % ... heading y*y x*x + add sqrt % ... heading ra_pt (distance from origin in points) + 25.0 div % scale it means a ra of 25bp + dup 1.0 ge % BOOLEAN. ready to clamp to interval [0, 1.0] + { pop 1.0 }{} ifelse % We shall use the scaled ra as 'Saturation' + %2.5 mul 0.25 sub % now, Ra in [0.1, 0.5] --> Saturation + % in [0.0, 1.0]. Saturation varies between the two radii + 1.0 % ... H S V ( with 'Value' set to literal constant of 1.0 ) + % C version to use as model: + % H' = H * 6 + % i = floor(H') + % f = H' - i + % P = V * (1.0 - S) + % Q = V * (1.0 - (S*f)) + % T = V * (1.0 - (S * (1.0 - f))) + 3 2 roll 6.0 mul dup 4 1 roll % H' S V H' + floor cvr % H' S V i + dup 5 1 roll % i H' S V i + 3 index sub neg % i H' S V f + 1.0 3 index sub % i H' S V f (1.0 - S ) + 2 index mul % i H' S V f P + 6 1 roll % P i H' S V f + dup 3 index mul neg 1.0 add % P i H' S V f ( 1.0 - (f*S)) + 2 index mul % P i H' S V f Q + 7 1 roll % Q P i H' S V f + neg 1.0 add % Q P i H' S V (1.0 - f) + 2 index mul neg 1.0 add % Q P i H' S V (1.0 - S * (1.0 - f)) + 1 index mul % Q P i H' S V T + 7 2 roll % V T Q P i H' S + pop pop % V T Q P i + %%% + % end of BLOCK B. The rest is just stack manipulation + dup 0.5 le % TEST II [ i == 0 ] + { % BLOCK C [ take stack to V T P ] + pop exch pop + } + { dup 1.5 le % TEST III [ i == 1 ] + { % BLOCK D [ take stack to Q V P ] + pop exch 4 1 roll exch pop + } + { dup 2.5 le % TEST IV [ i == 2 ] + { % BLOCK E [ take stack to P V T ] + pop 4 1 roll pop + } + { dup 3.5 le % TEST V [ i == 3 ] + { % BLOCK F [ take stack to P Q V ] + pop exch 4 2 roll pop + } + { dup 4.5 le % TEST VI [ i == 4 ] + { % BLOCK G [ take stack to T P V ] + pop exch pop 3 -1 roll + } + { % BLOCK H [ take stack to V P Q ] + pop 3 1 roll exch pop + } + ifelse + } + ifelse % for V + } + ifelse % for IV + } + ifelse % for III + } + ifelse % for II +} + +\pgfdeclarefunctionalshading{color wheel black center} +{\pgfpoint{-50bp}{-50bp}} +{\pgfpoint{50bp}{50bp}} +{} +{ % x y + 2 copy % ... x y x y + 2 copy abs exch abs add 0.0001 ge + {atan 360.0 div} % ... x y heading; heading being in + %the interval [0, 1.0] + { pop } % silently deal with error: return + % arbitrary heading of zero for origin + ifelse % because we will use it for 'Hue' + 3 1 roll % ... heading x y + dup mul % ... heading x y*y + exch dup mul % ... heading y*y x*x + add sqrt % ... heading ra_pt (distance from origin in points) + 25.0 div % scale it means a ra of 25bp + dup 1.0 ge % BOOLEAN. ready to clamp to interval [0, 1.0] + { pop 1.0 }{} ifelse % We shall use the scaled ra as 'Saturation' + %2.5 mul 0.25 sub % now, Ra in [0.1, 0.5] --> Saturation + % in [0.0, 1.0]. Saturation varies between the two radii + 1.0 exch % ... H S V ( with 'Value' set to literal constant of 1.0 ) + % C version to use as model: + % H' = H * 6 + % i = floor(H') + % f = H' - i + % P = V * (1.0 - S) + % Q = V * (1.0 - (S*f)) + % T = V * (1.0 - (S * (1.0 - f))) + 3 2 roll 6.0 mul dup 4 1 roll % H' S V H' + floor cvr % H' S V i + dup 5 1 roll % i H' S V i + 3 index sub neg % i H' S V f + 1.0 3 index sub % i H' S V f (1.0 - S ) + 2 index mul % i H' S V f P + 6 1 roll % P i H' S V f + dup 3 index mul neg 1.0 add % P i H' S V f ( 1.0 - (f*S)) + 2 index mul % P i H' S V f Q + 7 1 roll % Q P i H' S V f + neg 1.0 add % Q P i H' S V (1.0 - f) + 2 index mul neg 1.0 add % Q P i H' S V (1.0 - S * (1.0 - f)) + 1 index mul % Q P i H' S V T + 7 2 roll % V T Q P i H' S + pop pop % V T Q P i + %%% + % end of BLOCK B. The rest is just stack manipulation + dup 0.5 le % TEST II [ i == 0 ] + { % BLOCK C [ take stack to V T P ] + pop exch pop + } + { dup 1.5 le % TEST III [ i == 1 ] + { % BLOCK D [ take stack to Q V P ] + pop exch 4 1 roll exch pop + } + { dup 2.5 le % TEST IV [ i == 2 ] + { % BLOCK E [ take stack to P V T ] + pop 4 1 roll pop + } + { dup 3.5 le % TEST V [ i == 3 ] + { % BLOCK F [ take stack to P Q V ] + pop exch 4 2 roll pop + } + { dup 4.5 le % TEST VI [ i == 4 ] + { % BLOCK G [ take stack to T P V ] + pop exch pop 3 -1 roll + } + { % BLOCK H [ take stack to V P Q ] + pop 3 1 roll exch pop + } + ifelse + } + ifelse % for V + } + ifelse % for IV + } + ifelse % for III + } + ifelse % for II +} + +\pgfdeclarefunctionalshading{color wheel} +{\pgfpoint{-50bp}{-50bp}} +{\pgfpoint{50bp}{50bp}} +{} +{ % x y + 2 copy abs exch abs add 0.0001 ge + {atan 360.0 div} % ... x y heading; heading being in + %the interval [0, 1.0] + { pop } % silently deal with error: return + % arbitrary heading of zero for origin + ifelse % because we will use it for 'Hue' + 1.0 1.0 % ... H S V + % C version to use as model: + % H' = H * 6 + % i = floor(H') + % f = H' - i + % P = V * (1.0 - S) + % Q = V * (1.0 - (S*f)) + % T = V * (1.0 - (S * (1.0 - f))) + 3 2 roll 6.0 mul dup 4 1 roll % H' S V H' + floor cvr % H' S V i + dup 5 1 roll % i H' S V i + 3 index sub neg % i H' S V f + 1.0 3 index sub % i H' S V f (1.0 - S ) + 2 index mul % i H' S V f P + 6 1 roll % P i H' S V f + dup 3 index mul neg 1.0 add % P i H' S V f ( 1.0 - (f*S)) + 2 index mul % P i H' S V f Q + 7 1 roll % Q P i H' S V f + neg 1.0 add % Q P i H' S V (1.0 - f) + 2 index mul neg 1.0 add % Q P i H' S V (1.0 - S * (1.0 - f)) + 1 index mul % Q P i H' S V T + 7 2 roll % V T Q P i H' S + pop pop % V T Q P i + %%% + % end of BLOCK B. The rest is just stack manipulation + dup 0.5 le % TEST II [ i == 0 ] + { % BLOCK C [ take stack to V T P ] + pop exch pop + } + { dup 1.5 le % TEST III [ i == 1 ] + { % BLOCK D [ take stack to Q V P ] + pop exch 4 1 roll exch pop + } + { dup 2.5 le % TEST IV [ i == 2 ] + { % BLOCK E [ take stack to P V T ] + pop 4 1 roll pop + } + { dup 3.5 le % TEST V [ i == 3 ] + { % BLOCK F [ take stack to P Q V ] + pop exch 4 2 roll pop + } + { dup 4.5 le % TEST VI [ i == 4 ] + { % BLOCK G [ take stack to T P V ] + pop exch pop 3 -1 roll + } + { % BLOCK H [ take stack to V P Q ] + pop 3 1 roll exch pop + } + ifelse + } + ifelse % for V + } + ifelse % for IV + } + ifelse % for III + } + ifelse % for II +} + + +% +% A bilinear interpolation. +% + +\colorlet{lower left}{white} +\colorlet{lower right}{white} +\colorlet{upper left}{white} +\colorlet{upper right}{white} + +\pgfdeclarefunctionalshading[lower left,lower right,upper left,upper right]{bilinear interpolation} +{\pgfpointorigin} +{\pgfpoint{100bp}{100bp}} +{ + \pgfshadecolortorgb{lower left}{\pgf@lib@shadings@ll}\pgfshadecolortorgb{lower right}{\pgf@lib@shadings@lr} + \pgfshadecolortorgb{upper right}{\pgf@lib@shadings@ur}\pgfshadecolortorgb{upper left}{\pgf@lib@shadings@ul} +}{ + 25 sub 50 div exch 25 sub 50 div 2 copy % Calculate y/100 x/100. +% 100 div exch 100 div 2 copy % Calculate y/100 x/100. + neg 1 add exch neg 1 add % Calculate 1-y/100 1-x/100. + 3 1 roll 2 copy exch 5 2 roll 6 copy 6 copy % Set up stack. + \pgf@lib@shadings@llred mul exch \pgf@lib@shadings@lrred mul add mul % Process red component. + 4 1 roll + \pgf@lib@shadings@urred mul exch \pgf@lib@shadings@ulred mul add mul + add + 13 1 roll + \pgf@lib@shadings@llgreen mul exch \pgf@lib@shadings@lrgreen mul add mul % Process green component. + 4 1 roll + \pgf@lib@shadings@urgreen mul exch \pgf@lib@shadings@ulgreen mul add mul + add + 7 1 roll + \pgf@lib@shadings@llblue mul exch \pgf@lib@shadings@lrblue mul add mul % Process blue component. + 4 1 roll + \pgf@lib@shadings@urblue mul exch \pgf@lib@shadings@ulblue mul add mul + add +} + + +% +% A Mandelbrot set shading. Just for fun... +% + +\pgfdeclarefunctionalshading{Mandelbrot set} +{\pgfpoint{-50bp}{-50bp}} +{\pgfpoint{50bp}{50bp}}{} +{ + 12.5 div exch 12.5 div exch + 1 index 1 index + % Stack: c_r c_i z_r z_i + % Formula: z' = z^2 + c = (z_r + i z_i)^2 + c_r + i c_i + % = (z_r^2 - z_i^2 + c_r) + i (2 z_r z_i + c_i) + % + % First iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Second iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Third iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Fourth iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Check for break (to avoid too large numbers) + 1 index dup mul 1 index dup mul add + 4 lt { + % Fifth iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Sixth iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Seventh iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Eighth iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Ninth iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + % Tenth iteration + % 1. Compute z_r^2 -z_i^2 + c_r + 1 index dup mul % z_r^2 + 1 index dup mul % z_i^2 + sub % z_r^2 - z_i^2 + 4 index add % z_r^2 -z_i^2 + c_r + % 2. Compute 2 z_r z_i + c_i + 3 1 roll + mul 2 mul % 2 z_r z_i + 2 index add % 2 z_r z_i + c_i + } { pop pop 1000.0 1000.0 } ifelse + % Compute distance + dup mul exch + dup mul + add sqrt + dup 4 1 roll + 2 gt { pop pop 2.0 exch div 1.0 exch sub dup dup} {pop pop 0.0 0.0 0.0} ifelse +} diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.multipart.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.multipart.code.tex deleted file mode 100644 index 41f0fcfb243..00000000000 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.multipart.code.tex +++ /dev/null @@ -1,1097 +0,0 @@ -% Copyright 2007 by Till Tantau and Mark Wibrow -% -% This file may be distributed and/or modified -% -% 1. under the LaTeX Project Public License and/or -% 2. under the GNU Public License. -% -% See the file doc/generic/pgf/licenses/LICENSE for more details. - -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.multipart.code.tex,v 1.7 2008/01/15 15:41:18 vibrovski Exp $ - -\newbox\pgfnodepartlowerbox - -% -% A circle that is split in the middle into an upper and a lower part. -% -% This node consists of two parts: The upper (main) part is shown in -% the upper half of the circle. The second part is the (optional) -% lower part. -% -% Parts: text, lower - -\pgfdeclareshape{circle split} -{ - % - % Node parts - % - \nodeparts{text,lower} - - % - % Anchors - % - \savedanchor\centerpoint{% - \pgf@x=.5\wd\pgfnodeparttextbox% - \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/inner ysep}}% - \pgf@y=-\pgf@y% - \advance\pgf@y by-\dp\pgfnodeparttextbox% - \advance\pgf@y by-.5\pgflinewidth% - }% - \savedanchor\loweranchor{% - \pgf@x=-.5\wd\pgfnodepartlowerbox% - \advance\pgf@x by.5\wd\pgfnodeparttextbox% - \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/inner ysep}}% - \pgf@y=-2\pgf@y% - \advance\pgf@y by-\ht\pgfnodepartlowerbox% - \advance\pgf@y by-.5\pgflinewidth% - \advance\pgf@y by-\dp\pgfnodeparttextbox% - \advance\pgf@y by-.5\pgflinewidth% - } - - \saveddimen\radius{% - % - % Caculate ``height radius'' - % - %\pgf@ya=.5\ht\pgfnodeparttextbox% -% \advance\pgf@ya by.5\dp\pgfnodeparttextbox% -% \advance\pgf@ya by.5\ht\pgfnodepartlowerbox% -% \advance\pgf@ya by.5\dp\pgfnodepartlowerbox% -% \advance\pgf@ya by.5\pgflinewidth% - % - % MW: Suggested correction for above calculation: Use the tallest box * 2. - % - \pgf@ya=.5\ht\pgfnodeparttextbox% - \advance\pgf@ya by.5\dp\pgfnodeparttextbox% - \pgf@yb=.5\ht\pgfnodepartlowerbox% - \advance\pgf@yb by.5\dp\pgfnodepartlowerbox% - \ifdim\pgf@ya>\pgf@yb\relax% - \pgf@ya2.0\pgf@ya\relax% - \else% - \pgf@ya2.0\pgf@yb\relax% - \fi% - \advance\pgf@ya by.5\pgflinewidth% - \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}% - \advance\pgf@ya by2\pgf@yb% - % - % Caculate ``width radius'' - % - \pgf@xa=.5\wd\pgfnodeparttextbox% - \ifdim\pgf@xa<.5\wd\pgfnodepartlowerbox% - \pgf@xa=.5\wd\pgfnodepartlowerbox% - \fi% - \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}% - \advance\pgf@xa by\pgf@xb% - % - % Calculate length of radius vector: - % - \pgf@process{\pgfpointnormalised{\pgfqpoint{\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: - % - \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/minimum width}}% - \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/minimum height}}% - \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. - % - \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% - \ifdim\pgf@xb<\pgf@yb% - \advance\pgf@x by\pgf@yb% - \else% - \advance\pgf@x by\pgf@xb% - \fi% - } - - % - % Anchors - % - \inheritanchorborder[from=circle] - \inheritanchor[from=circle]{north} - \inheritanchor[from=circle]{north west} - \inheritanchor[from=circle]{north east} - \inheritanchor[from=circle]{center} - \inheritanchor[from=circle]{west} - \inheritanchor[from=circle]{east} - \inheritanchor[from=circle]{mid} - \inheritanchor[from=circle]{mid west} - \inheritanchor[from=circle]{mid east} - \inheritanchor[from=circle]{base} - \inheritanchor[from=circle]{base west} - \inheritanchor[from=circle]{base east} - \inheritanchor[from=circle]{south} - \inheritanchor[from=circle]{south west} - \inheritanchor[from=circle]{south east} - \anchor{lower}{\loweranchor} - - % - % Background path - % - \inheritbackgroundpath[from=circle] - \beforebackgroundpath{ - \pgfutil@tempdima=\radius% - \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% - \ifdim\pgf@xb<\pgf@yb% - \advance\pgfutil@tempdima by-\pgf@yb% - \else% - \advance\pgfutil@tempdima by-\pgf@xb% - \fi% - \advance\pgfutil@tempdima by-.5\pgflinewidth% - \pgfsetshortenstart{0pt}% - \pgfsetshortenend{0pt}% - \pgfsetarrows{-}% - \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfqpoint{-1\pgfutil@tempdima}{0pt}}}% - \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpoint{\pgfutil@tempdima}{0pt}}}% - \pgfusepath{stroke}% - } -} - - - - - -% (Most) keys for shape rectangle split. -% -% /pgf/rectangle split parts : Set the number of rectangles to split into. -% /pgf/rectangle split part align : Align the for the boxes in each part -% (also keys for each part) -% /pgf/rectangle split use custom fill : Use a custom (behindbackground path) fill. -% /pgf/rectangle split part fill : Custom fill for ech part. -% (also keys for each part) -% /pgf/rectangle split draw splits : Draw the line between node parts. -% /pgf/rectangle split empty part height : Set the default height for empty boxes. - - -\newif\ifpgfrectanglesplitdrawsplits -\pgfrectanglesplitdrawsplitstrue - -\newif\ifpgfrectanglesplitusecustomfill -\pgfrectanglesplitusecustomfillfalse - -\pgfkeys{/pgf/.cd, - rectangle split parts/.initial=4, - rectangle split empty part height/.initial=1ex, - rectangle split draw splits/.is if=pgfrectanglesplitdrawsplits, - % - rectangle split part align/.code=\pgf@lib@shapes@rectanglesplit@assigntoparts{#1}{align}, - rectangle split text part align/.initial=center, - rectangle split second part align/.initial=center, - rectangle split third part align/.initial=center, - rectangle split fourth part align/.initial=center, - % - rectangle split use custom fill/.is if=pgfrectanglesplitusecustomfill, - rectangle split part fill/.code={% - \pgfrectanglesplitusecustomfilltrue% - \pgf@lib@shapes@rectanglesplit@assigntoparts{#1}{fill}% - }, - rectangle split text part fill/.initial=white, - rectangle split second part fill/.initial=white, - rectangle split third part fill/.initial=white, - rectangle split fourth part fill/.initial=white -} - -% Internal macros for the rectangle split shape. -% -\def\pgf@lib@shapes@rectanglesplit@left{left} -\def\pgf@lib@shapes@rectanglesplit@right{right} - -\def\pgf@lib@shapes@rectanglesplit@assigntoparts#1#2{% - \expandafter\pgf@lib@shapes@rectanglesplit@@assigntoparts#1,\@@,\@@,\@@,\@@,\pgf@lib#2\pgf@lib} -\def\pgf@lib@shapes@rectanglesplit@@assigntoparts#1,#2,#3,#4,#5\pgf@lib#6\pgf@lib{% - \pgfkeys{/pgf/.cd,% - rectangle split text part #6=#1, - rectangle split second part #6=#1, - rectangle split third part #6=#1, - rectangle split fourth part #6=#1 - }% - \ifx#2\@@\else% - \pgfkeys{/pgf/.cd,% - rectangle split second part #6=#2, - rectangle split third part #6=#2, - rectangle split fourth part #6=#2 - }% - \fi% - \ifx#3\@@\else% - \pgfkeys{/pgf/.cd,% - rectangle split third part #6=#3, - rectangle split fourth part #6=#3 - }% - \fi% - \ifx#4\@@\else% - \pgfkeys{/pgf/rectangle split fourth part #6=#4}% - \fi% -}% - -\newbox\pgfnodepartsecondbox -\newbox\pgfnodepartthirdbox -\newbox\pgfnodepartfourthbox - -\pgfdeclareshape{rectangle split}{% - \nodeparts{text,second,third,fourth} - \savedmacro\getrectanglesplitparameters{% - % - % If the height+depth of any box is 0pt use the default empty height. - % - \pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/rectangle split empty part height}} - \pgf@y\ht\pgfnodeparttextbox% - \advance\pgf@y\dp\pgfnodeparttextbox% - \ifdim\pgf@y=0pt\relax% - \setbox\pgfnodeparttextbox=\hbox{% - \vrule width0pt height\the\pgfutil@tempdima depth0pt% - }% - \fi% - \pgf@y\ht\pgfnodepartsecondbox% - \advance\pgf@y\dp\pgfnodepartsecondbox% - \ifdim\pgf@y=0pt\relax% - \setbox\pgfnodepartsecondbox=\hbox{% - \vrule width0pt height\the\pgfutil@tempdima depth0pt% - }% - \fi% - \pgf@y\ht\pgfnodepartthirdbox% - \advance\pgf@y\dp\pgfnodepartthirdbox% - \ifdim\pgf@y=0pt\relax% - \setbox\pgfnodepartthirdbox=\hbox{% - \vrule width0pt height\the\pgfutil@tempdima depth0pt% - }% - \fi% - \pgf@y\ht\pgfnodepartfourthbox% - \advance\pgf@y\dp\pgfnodepartfourthbox% - \ifdim\pgf@y=0pt\relax% - \setbox\pgfnodepartfourthbox=\hbox{% - \vrule width0pt height\the\pgfutil@tempdima depth0pt% - }% - \fi% - % - % Empty boxes (without voiding them) if they are not used. - % - \pgfmathtruncatemacro\parts{\pgfkeysvalueof{/pgf/rectangle split parts}}% - \addtosavedmacro{\parts}% - \ifnum\parts<2\relax% - \setbox\pgfnodepartsecondbox=\hbox{}% - \fi% - \ifnum\parts<3\relax% - \setbox\pgfnodepartthirdbox=\hbox{}% - \fi% - \ifnum\parts<4\relax% - \setbox\pgfnodepartfourthbox=\hbox{}% - \fi% - % - % Save the line width. - % - \pgfmathsetlength\pgf@x{\pgflinewidth} - \edef\linewidth{\the\pgf@x}% - \addtosavedmacro{\linewidth}% - % - \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% - \edef\innerysep{\the\pgf@y}% - % - \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}% - \edef\innerxsep{\the\pgf@x}% - % - % Get the widths. - % - \pgf@x.5\wd\pgfnodeparttextbox% - \pgf@xa.5\wd\pgfnodepartsecondbox% - \pgf@xb.5\wd\pgfnodepartthirdbox% - \pgf@xc.5\wd\pgfnodepartfourthbox% - % - % Find the maximum width% - % - \pgfutil@tempdima\pgf@x% - \ifdim\pgfutil@tempdima<\pgf@xa% - \pgfutil@tempdima\pgf@xa% - \fi% - \ifdim\pgfutil@tempdima<\pgf@xb% - \pgfutil@tempdima\pgf@xb% - \fi% - \ifdim\pgfutil@tempdima<\pgf@xc% - \pgfutil@tempdima\pgf@xc% - \fi% - % - % Adjust for alignment. - % - \edef\pgf@lib@temp{\pgfkeysvalueof{/pgf/rectangle split text part align}}% - \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@left% - \pgf@x-\pgfutil@tempdima% - \else% - \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@right% - \pgf@x-2.0\pgf@x% - \advance\pgf@x\pgfutil@tempdima% - \else% - \pgf@x-\pgf@x% - \fi% - \fi% - % - \edef\pgf@lib@temp{\pgfkeysvalueof{/pgf/rectangle split second part align}}% - \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@left% - \pgf@xa-\pgfutil@tempdima% - \else% - \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@right% - \pgf@xa-2.0\pgf@xa% - \advance\pgf@xa\pgfutil@tempdima% - \else% - \pgf@xa-\pgf@xa% - \fi% - \fi% - % - \edef\pgf@lib@temp{\pgfkeysvalueof{/pgf/rectangle split third part align}}% - \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@left% - \pgf@xb-\pgfutil@tempdima% - \else% - \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@right% - \pgf@xb-2.0\pgf@xb% - \advance\pgf@xb\pgfutil@tempdima% - \else% - \pgf@xb-\pgf@xb% - \fi% - \fi% - % - \edef\pgf@lib@temp{\pgfkeysvalueof{/pgf/rectangle split fourth part align}}% - \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@left% - \pgf@xc-\pgfutil@tempdima% - \else% - \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@right% - \pgf@xc-2.0\pgf@xc% - \advance\pgf@xc\pgfutil@tempdima% - \else% - \pgf@xc-\pgf@xc% - \fi% - \fi% - % - % Make relative to x. - % - \advance\pgf@xa-\pgf@x% - \advance\pgf@xb-\pgf@x% - \advance\pgf@xc-\pgf@x% - \pgf@x0pt% - % - % Find the minimum. - % - \pgfutil@tempdimb\pgf@x% - \ifdim\pgfutil@tempdimb>\pgf@xa% - \pgfutil@tempdimb\pgf@xa% - \fi% - \ifdim\pgfutil@tempdimb>\pgf@xb% - \pgfutil@tempdimb\pgf@xb% - \fi% - \ifdim\pgfutil@tempdimb>\pgf@xc% - \pgfutil@tempdimb\pgf@xc% - \fi% - % - % Anchor for the text box is (0pt, 0pt) - % - \pgfsavepgf@process\textanchor{\pgfqpoint{0pt}{0pt}}% - % - % Anchor for second box. - % - \pgfsavepgf@process\lowestanchor{\pgfqpoint{0pt}{0pt}}% - \let\lowestbox\pgfnodeparttextbox% - \ifnum\parts>1\relax% - \pgfsavepgf@process\secondanchor{% - \pgf@x\pgf@xa% - \pgf@y-\dp\pgfnodeparttextbox% - \advance\pgf@y-\innerysep\relax% - \advance\pgf@y-\pgflinewidth% - \advance\pgf@y-\innerysep\relax% - \advance\pgf@y-\ht\pgfnodepartsecondbox% - }% - \let\lowestanchor\secondanchor% - \let\lowestbox\pgfnodepartsecondbox% - \else% - \let\secondanchor\textanchor% - \fi% - % - % Anchor for third box. - % - \ifnum\parts>2\relax% - \pgfsavepgf@process\thirdanchor{% - \lowestanchor% - \pgf@x\pgf@xb% - \advance\pgf@y-\dp\pgfnodepartsecondbox% - \advance\pgf@y-\innerysep\relax% - \advance\pgf@y-\pgflinewidth% - \advance\pgf@y-\innerysep\relax% - \advance\pgf@y-\ht\pgfnodepartthirdbox% - }% - \let\lowestanchor\thirdanchor% - \let\lowestbox\pgfnodepartthirdbox% - \else% - \let\thirdanchor\secondanchor% - \fi% - % - % Anchor for fourth box. - % - \ifnum\parts>3\relax% - \pgfsavepgf@process\fourthanchor{% - \lowestanchor% - \pgf@x\pgf@xc% - \advance\pgf@y-\dp\lowestbox% - \advance\pgf@y-\innerysep\relax% - \advance\pgf@y-\pgflinewidth% - \advance\pgf@y-\innerysep\relax% - \advance\pgf@y-\ht\pgfnodepartfourthbox% - }% - \let\lowestanchor\fourthanchor% - \let\lowestbox\pgfnodepartfourthbox% - \else% - \let\fourthanchor\thirdanchor% - \fi% - % - \addtosavedmacro{\textanchor}% - \addtosavedmacro{\secondanchor}% - \addtosavedmacro{\thirdanchor}% - \addtosavedmacro{\fourthanchor}% - % - % Adjust the boxwidth for minimum width - % - \pgfmathaddtolength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/inner xsep}}% - \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/minimum width}}% - \ifdim\pgfutil@tempdima<.5\pgf@x% - \pgfutil@tempdima.5\pgf@x% - \fi% - \pgfmathaddtolength\pgfutil@tempdima{-\pgfkeysvalueof{/pgf/inner xsep}}% - % - % Get some important points. - % - \pgfsavepgf@process\southwest{% - \lowestanchor% - \pgf@x\pgfutil@tempdimb% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/inner xsep}}% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% - \pgf@ya\linewidth\relax% - \advance\pgf@x-.5\pgf@ya% - \advance\pgf@y-\dp\lowestbox% - \advance\pgf@y-.5\pgf@ya% - \pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/inner ysep}}% - \pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}% - }% - \pgfsavepgf@process\northeast{% - \pgf@x\pgfutil@tempdimb% - \advance\pgf@x2.0\pgfutil@tempdima% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - \pgf@ya\linewidth\relax% - \advance\pgf@x.5\pgf@ya% - \pgf@y\ht\pgfnodeparttextbox% - \advance\pgf@y.5\pgf@ya% - \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% - \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}% - }% - \addtosavedmacro{\northeast}% - \addtosavedmacro{\southwest}% - \pgfsavepgf@process\centerpoint{% - \pgfpointadd{\southwest}{% - \pgfpointdiff{\southwest}{\northeast}% - \pgf@x.5\pgf@x% - \pgf@y.5\pgf@y% - }% - }% - \addtosavedmacro{\centerpoint}% - \pgfsavepgf@process\south{% - \centerpoint% - \pgf@xa\pgf@x% - \southwest% - \pgf@x\pgf@xa% - }% - % - % Get the split points. - % - \let\lastsplit\south% - \ifnum\parts>1\relax% - \pgfsavepgf@process\textsplit{% - \pgf@x\pgfutil@tempdimb% - \advance\pgf@x\pgfutil@tempdima% - \pgf@y-\dp\pgfnodeparttextbox% - \advance\pgf@y-\innerysep% - \advance\pgf@y-.5\pgflinewidth% - }% - \else% - \let\textsplit\south% - \fi% - \addtosavedmacro{\textsplit}% - \pgfsavepgf@process\textspliteast{% - \textsplit% - \pgf@ya\pgf@y% - \northeast% - \pgf@y\pgf@ya% - }% - \addtosavedmacro{\textspliteast}% - \pgfsavepgf@process\textsplitwest{% - \textsplit% - \pgf@ya\pgf@y% - \southwest% - \pgf@y\pgf@ya% - }% - \addtosavedmacro{\textsplitwest}% - \ifnum\parts>2\relax% - \pgfsavepgf@process\secondsplit{% - \secondanchor% - \pgf@x\pgfutil@tempdimb% - \advance\pgf@x\pgfutil@tempdima% - \advance\pgf@y-\dp\pgfnodepartsecondbox% - \advance\pgf@y-\innerysep% - \advance\pgf@y-.5\pgflinewidth% - }% - \else% - \let\secondsplit\south% - \fi% - \addtosavedmacro{\secondsplit}% - \pgfsavepgf@process\secondspliteast{% - \secondsplit% - \pgf@ya\pgf@y% - \northeast% - \pgf@y\pgf@ya% - }% - \addtosavedmacro{\secondspliteast}% - \pgfsavepgf@process\secondsplitwest{% - \secondsplit% - \pgf@ya\pgf@y% - \southwest% - \pgf@y\pgf@ya% - }% - \addtosavedmacro{\secondsplitwest}% - \ifnum\parts>3\relax% - \pgfsavepgf@process\thirdsplit{% - \thirdanchor% - \pgf@x\pgfutil@tempdimb% - \advance\pgf@x\pgfutil@tempdima% - \advance\pgf@y-\dp\pgfnodepartthirdbox% - \advance\pgf@y-\innerysep% - \advance\pgf@y-.5\pgflinewidth% - }% - \let\lastsplit\thirdsplit% - \else% - \let\thirdsplit\south% - \fi% - \addtosavedmacro{\thirdsplit}% - \pgfsavepgf@process\thirdspliteast{% - \thirdsplit% - \pgf@ya\pgf@y% - \northeast% - \pgf@y\pgf@ya% - }% - \addtosavedmacro{\thirdspliteast}% - \pgfsavepgf@process\thirdsplitwest{% - \thirdsplit% - \pgf@ya\pgf@y% - \southwest% - \pgf@y\pgf@ya% - }% - \addtosavedmacro{\thirdsplitwest}% - }% - \savedanchor\basepoint{% - \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}% - \pgfmathsetlength\pgf@y{+.5\ht\pgfnodeparttextbox}% - \pgf@y0pt\relax% - }% - \savedanchor\midpoint{% - \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}% - \pgfmathsetlength\pgf@y{+.5ex}% - }% - \anchor{center}{\getrectanglesplitparameters\centerpoint}% - \anchor{base}{\basepoint}% - \anchor{mid}{\midpoint}% - \anchor{second}{\getrectanglesplitparameters\secondanchor}% - \anchor{third}{\getrectanglesplitparameters\thirdanchor}% - \anchor{fourth}{\getrectanglesplitparameters\fourthanchor}% - \anchor{north east}{\getrectanglesplitparameters\northeast} - \anchor{south west}{\getrectanglesplitparameters\southwest} - \anchor{south east}{% - \getrectanglesplitparameters% - \northeast% - \pgf@xa\pgf@x% - \southwest% - \pgf@x\pgf@xa} - \anchor{north west}{% - \getrectanglesplitparameters% - \northeast% - \pgf@ya\pgf@y% - \southwest% - \pgf@y\pgf@ya} - \anchor{south}{% - \getrectanglesplitparameters% - \centerpoint% - \pgf@xa\pgf@x% - \southwest% - \pgf@x\pgf@xa} - \anchor{north}{% - \getrectanglesplitparameters% - \centerpoint% - \pgf@xa\pgf@x% - \northeast% - \pgf@x\pgf@xa} - \anchor{west}{% - \getrectanglesplitparameters% - \centerpoint% - \pgf@ya\pgf@y% - \southwest% - \pgf@y\pgf@ya} - \anchor{east}{% - \getrectanglesplitparameters% - \centerpoint% - \pgf@ya\pgf@y% - \northeast% - \pgf@y\pgf@ya} - \anchor{text split}{\getrectanglesplitparameters\textsplit} - \anchor{text split east}{\getrectanglesplitparameters\textspliteast} - \anchor{text split west}{\getrectanglesplitparameters\textsplitwest} - \anchor{second split}{\getrectanglesplitparameters\secondsplit} - \anchor{second split east}{\getrectanglesplitparameters\secondspliteast} - \anchor{second split west}{\getrectanglesplitparameters\secondsplitwest} - \anchor{third split}{\getrectanglesplitparameters\thirdsplit} - \anchor{third split east}{\getrectanglesplitparameters\thirdspliteast} - \anchor{third split west}{\getrectanglesplitparameters\thirdsplitwest} - \anchor{text east}{% - \getrectanglesplitparameters% - \ifnum\parts>1\relax% - \textsplit% - \pgf@ya\pgf@y - \northeast% - \advance\pgf@y\pgf@ya% - \pgf@y.5\pgf@y% - \pgf@ya\linewidth\relax% - \advance\pgf@y-.25\pgf@ya% - \else% - \centerpoint% - \pgf@ya\pgf@y% - \northeast% - \pgf@y\pgf@ya% - \fi% - } - \anchor{text west}{% - \getrectanglesplitparameters% - \ifnum\parts>1\relax% - \textsplit% - \pgf@ya\pgf@y - \southwest% - \pgf@xa\pgf@x% - \northeast% - \pgf@x\pgf@xa% - \advance\pgf@y\pgf@ya% - \pgf@y.5\pgf@y% - \pgf@ya\linewidth\relax% - \advance\pgf@y-.25\pgf@ya% - \else% - \centerpoint% - \pgf@ya\pgf@y% - \southwest% - \pgf@y\pgf@ya% - \fi% - } - \anchor{second east}{% - \getrectanglesplitparameters% - \ifnum\parts>1\relax% - \northeast% - \pgf@xa\pgf@x% - \secondsplit% - \pgf@ya\pgf@y - \textsplit% - \advance\pgf@y\pgf@ya% - \pgf@y.5\pgf@y% - \pgf@x\pgf@xa% - \else% - \southwest% - \pgf@ya\pgf@y% - \northeast% - \pgf@y\pgf@ya% - \fi% - } - \anchor{second west}{% - \getrectanglesplitparameters% - \ifnum\parts>1\relax% - \southwest% - \pgf@xa\pgf@x% - \secondsplit% - \pgf@ya\pgf@y - \textsplit% - \advance\pgf@y\pgf@ya% - \pgf@y.5\pgf@y% - \pgf@x\pgf@xa% - \else% - \southwest% - \fi% - } - \anchor{third east}{% - \getrectanglesplitparameters% - \ifnum\parts>2\relax% - \northeast% - \pgf@xa\pgf@x% - \thirdsplit% - \pgf@ya\pgf@y - \secondsplit% - \advance\pgf@y\pgf@ya% - \pgf@y.5\pgf@y% - \pgf@x\pgf@xa% - \else% - \southwest% - \pgf@ya\pgf@y% - \northeast% - \pgf@y\pgf@ya% - \fi% - } - \anchor{third west}{% - \getrectanglesplitparameters% - \ifnum\parts>2\relax% - \southwest% - \pgf@xa\pgf@x% - \thirdsplit% - \pgf@ya\pgf@y - \secondsplit% - \advance\pgf@y\pgf@ya% - \pgf@y.5\pgf@y% - \pgf@x\pgf@xa% - \else% - \southwest - \fi% - } - \anchor{fourth east}{% - \getrectanglesplitparameters% - \ifnum\parts>3\relax% - \northeast% - \pgf@xa\pgf@x% - \southwest% - \pgf@ya\linewidth\relax% - \pgf@ya.5\pgf@ya% - \advance\pgf@ya\pgf@y% - \thirdsplit% - \advance\pgf@y\pgf@ya% - \pgf@y.5\pgf@y% - \pgf@x\pgf@xa% - \else% - \northeast% - \pgf@xa\pgf@x% - \southwest% - \pgf@x\pgf@xa% - \fi% - } - \anchor{fourth west}{% - \getrectanglesplitparameters% - \ifnum\parts>3\relax% - \southwest% - \pgf@xa\pgf@x% - \pgf@ya\linewidth\relax% - \pgf@ya.5\pgf@ya% - \advance\pgf@ya\pgf@y% - \thirdsplit% - \advance\pgf@y\pgf@ya% - \pgf@y.5\pgf@y% - \pgf@x\pgf@xa% - \else% - \southwest% - \fi% - } - \backgroundpath{% - \getrectanglesplitparameters% - % - % Remove outer sep. - % - \pgfsavepgf@process\southwest{% - \southwest% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}% - }% - \pgfsavepgf@process\northeast{% - \northeast% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}% - }% - \pgfsavepgf@process\textsplit{% - \textsplit% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - }% - \pgfsavepgf@process\secondsplit{% - \secondsplit% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% - }% - \pgfsavepgf@process\thirdsplit{% - \thirdsplit% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - }% - \pgfpathrectangle{\southwest}{\pgfpointdiff{\southwest}{\northeast}}% - {% - \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}% - \ifnum\parts>1\relax% - \pgfpathmoveto{\textsplit\pgf@ya\pgf@y\southwest\pgf@y\pgf@ya}% - \pgfpathlineto{\textsplit\pgf@ya\pgf@y\northeast\pgf@y\pgf@ya}% - \fi% - \ifnum\parts>2\relax% - \pgfpathmoveto{\secondsplit\pgf@ya\pgf@y\southwest\pgf@y\pgf@ya}% - \pgfpathlineto{\secondsplit\pgf@ya\pgf@y\northeast\pgf@y\pgf@ya}% - \fi% - \ifnum\parts>3\relax% - \pgfpathmoveto{\thirdsplit\pgf@ya\pgf@y\southwest\pgf@y\pgf@ya}% - \pgfpathlineto{\thirdsplit\pgf@ya\pgf@y\northeast\pgf@y\pgf@ya}% - \fi% - }% - } - \behindbackgroundpath{% - \ifpgfrectanglesplitusecustomfill% - % - % Remove outer sep. - % - \getrectanglesplitparameters% - \pgfsavepgf@process\southwest{% - \southwest% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}% - }% - \pgfsavepgf@process\northeast{% - \northeast% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}% - }% - \pgfsavepgf@process\textspliteast{% - \textspliteast% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% - }% - \pgfsavepgf@process\textsplitwest{% - \textsplitwest% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - }% - \pgfsavepgf@process\secondspliteast{% - \secondspliteast% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% - }% - \pgfsavepgf@process\secondsplitwest{% - \secondsplitwest% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - }% - \pgfsavepgf@process\thirdspliteast{% - \thirdspliteast% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% - }% - \pgfsavepgf@process\thirdsplitwest{% - \thirdsplitwest% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - }% - % - % Always fill the text box. - % - \pgfpathmoveto{\textsplitwest}% - \pgfpathlineto{\northeast\pgf@ya\pgf@y\southwest\pgf@y\pgf@ya}% - \pgfpathlineto{\northeast}% - \ifnum\parts>1\relax% - \bgroup% - \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}% - \fi% - \pgfpathlineto{\textspliteast}% - \pgfpathclose% - \ifnum\parts>1\relax% - \egroup% - \fi% - \pgfsetfillcolor{\pgfkeysvalueof{/pgf/rectangle split text part fill}}% - \pgfusepath{fill}% - % - % Second box. - % - \ifnum\parts>1\relax% - \bgroup% - \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}% - \pgfpathmoveto{\textsplitwest}% - \pgfpathlineto{\textspliteast}% - \ifnum\parts=2\relax% - \egroup% - \fi% - \pgfpathlineto{\secondspliteast}% - \pgfpathlineto{\secondsplitwest}% - \ifnum\parts=2\relax% - \bgroup% - \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}% - \fi% - \pgfpathclose% - \pgfsetfillcolor{\pgfkeysvalueof{/pgf/rectangle split second part fill}}% - \pgfusepath{fill}% - \egroup% - \fi% - % - % Third box. - % - \ifnum\parts>2\relax% - \bgroup% - \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}% - \pgfpathmoveto{\secondsplitwest}% - \pgfpathlineto{\secondspliteast}% - \ifnum\parts=3\relax% - \egroup% - \fi% - \pgfpathlineto{\thirdspliteast}% - \pgfpathlineto{\thirdsplitwest}% - \ifnum\parts=3\relax% - \bgroup% - \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}% - \fi% - \pgfpathclose% - \pgfsetfillcolor{\pgfkeysvalueof{/pgf/rectangle split third part fill}}% - \pgfusepath{fill}% - \egroup% - \fi% - % - % And the fourth box. - % - \ifnum\parts>3\relax% - \pgfpathmoveto{\thirdsplitwest}% - \pgfpathlineto{\southwest}% - \pgfpathlineto{\southwest\pgf@ya\pgf@y\northeast\pgf@y\pgf@ya}% - \bgroup% - \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}% - \pgfpathlineto{\thirdspliteast}% - \pgfpathclose% - \egroup% - \pgfsetfillcolor{\pgfkeysvalueof{/pgf/rectangle split fourth part fill}}% - \pgfusepath{fill}% - \fi% - \fi% - } - \anchorborder{% - \pgfutil@tempdima\pgf@x% - \pgfutil@tempdimb\pgf@y% - \getrectanglesplitparameters% - \pgfpointdiff{\southwest}{\northeast}% - \pgf@x.5\pgf@x% - \pgf@y.5\pgf@y% - \edef\pgf@marshall{% - \noexpand\pgfpointborderrectangle{% - \noexpand\pgfqpoint{\the\pgfutil@tempdima}{\the\pgfutil@tempdimb}% - }% - {% - \noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}% - }% - }% - \pgf@marshall% - \pgf@xa\pgf@x% - \pgf@ya\pgf@y% - \centerpoint% - \advance\pgf@x\pgf@xa% - \advance\pgf@y\pgf@ya% - }% -} - - -% Shape: ellipse split. -% -\pgfdeclareshape{ellipse split}{% - \nodeparts{text,lower} - \savedanchor\radii{% - \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}% - \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% - \pgf@y2.0\pgf@y% - \advance\pgf@y.5\pgflinewidth% - \pgf@xa.5\wd\pgfnodeparttextbox% - \pgf@xb.5\wd\pgfnodepartlowerbox% - \advance\pgf@xa\pgf@x% - \advance\pgf@xb\pgf@x% - \pgf@ya\ht\pgfnodeparttextbox% - \advance\pgf@ya\dp\pgfnodeparttextbox% - \pgf@yb\ht\pgfnodepartlowerbox% - \advance\pgf@yb\dp\pgfnodepartlowerbox% - \advance\pgf@ya\pgf@y% - \advance\pgf@yb\pgf@y% - \ifdim\pgf@xa>\pgf@xb% - \pgf@x1.414213\pgf@xa% - \else% - \pgf@x1.414213\pgf@xb% - \fi% - \ifdim\pgf@ya>\pgf@yb% - \pgf@y1.414213\pgf@ya% - \else% - \pgf@y1.414213\pgf@yb% - \fi% - \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}% - \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}% - \ifdim\pgf@x<.5\pgf@xa% - \pgf@x.5\pgf@xa% - \fi% - \ifdim\pgf@y<.5\pgf@ya% - \pgf@y.5\pgf@ya% - \fi% - \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}% - } - \savedanchor\lower{% - \pgf@x-.5\wd\pgfnodepartlowerbox% - \advance\pgf@x.5\wd\pgfnodeparttextbox% - \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% - \pgf@y-2.0\pgf@y% - \advance\pgf@y-\pgflinewidth% - \advance\pgf@y-\dp\pgfnodeparttextbox% - \advance\pgf@y-\ht\pgfnodepartlowerbox% - } - \savedanchor\centerpoint{% - \pgf@x.5\wd\pgfnodeparttextbox% - \pgfmathsetlength\pgf@y{-\pgfkeysvalueof{/pgf/inner ysep}}% - \advance\pgf@y-\dp\pgfnodeparttextbox% - \advance\pgf@y-.5\pgflinewidth% - }% - \savedanchor\basepoint{% - \pgf@x.5\wd\pgfnodeparttextbox% - \pgf@y0pt\relax% - }% - \savedanchor\midpoint{% - \pgf@x.5\wd\pgfnodeparttextbox% - \pgfmathsetlength\pgf@y{.5ex}% - }% - \anchor{center}{\centerpoint} - \anchor{lower}{\lower} - \anchor{mid}{\midpoint} - \anchor{mid east}{\radii\pgf@xa\pgf@x\midpoint\advance\pgf@x\pgf@xa} - \anchor{mid west}{\radii\pgf@xa\pgf@x\midpoint\advance\pgf@x-\pgf@xa} - \anchor{base}{\basepoint} - \anchor{base east}{\radii\pgf@xa\pgf@x\basepoint\advance\pgf@x\pgf@xa} - \anchor{base west}{\radii\pgf@xa\pgf@x\basepoint\advance\pgf@x-\pgf@xa} - \anchor{north}{\pgfpointadd{\centerpoint}{\radii\pgf@x0pt}}% - \anchor{south}{\pgfpointadd{\centerpoint}{\radii\pgf@x0pt\pgf@y-\pgf@y}}% - \anchor{east}{\pgfpointadd{\centerpoint}{\radii\pgf@y0pt}}% - \anchor{west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-\pgf@x\pgf@y0pt}}% - \anchor{north west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-0.707106\pgf@x\pgf@y0.707106\pgf@y}}% - \anchor{south west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-0.707106\pgf@x\pgf@y-0.707106\pgf@y}}% - \anchor{north east}{\pgfpointadd{\centerpoint}{\radii\pgf@x0.707106\pgf@x\pgf@y0.707106\pgf@y}}% - \anchor{south east}{\pgfpointadd{\centerpoint}{\radii\pgf@x0.707106\pgf@x\pgf@y-0.707106\pgf@y}}% - \backgroundpath{% - \radii% - \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}% - \pgfutil@tempdima\pgf@x% - \pgfutil@tempdimb\pgf@y% - \pgfpathellipse{\centerpoint}{\pgfqpoint{\the\pgfutil@tempdima}{0pt}}{\pgfqpoint{0pt}{\the\pgfutil@tempdimb}}% - \pgfpathmoveto{\centerpoint\advance\pgf@x-\pgfutil@tempdima}% - \pgfpathlineto{\centerpoint\advance\pgf@x\pgfutil@tempdima}% - } - \anchorborder{% - \pgfextract@process\externalpoint{}% - \radii% - \edef\pgf@marshal{% - \noexpand\pgfpointadd{\noexpand\pgfpointborderellipse{\noexpand\externalpoint}% - {\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}}{\noexpand\centerpoint}% - }% - \pgf@marshal% - }% -} - -\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarysvg.path.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarysvg.path.code.tex new file mode 100644 index 00000000000..16d1b2eab0e --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarysvg.path.code.tex @@ -0,0 +1,681 @@ +% Copyright 2009 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibrarysvg.path.code.tex,v 1.6 2009/01/24 17:07:14 tantau Exp $ + + +\usepgfmodule{parser} + + + + +% Scan an SVG-Path +% +% #1 = the path +% +% Description: +% +% This command takes a path in the compressed SVG-syntax. It then +% issues a sequences of appropriate \pgfpath commands for this +% path. For a description of the compressed svg path syntax, see a +% book on svg. +% +% The notion of a pixel used by svg makes no sense in pgf (actually +% it does not really make sense in svg either, but never mind), and +% instead of pixels "pt" is used as the basic unit. Use coordinate +% transformation to change this. +% +% Example: +% +% \pgfpathsvg{M10 20 L 30-20 0 1} +% +% % this has the same effect as +% +% \pgfpathmoveto{\pgfpoint{10pt}{20pt}} +% \pgfpathlineto{\pgfpint{30pt}{-20pt}} +% \pgfpathlineto{\pgfpint{0pt}{1pt}} +% + +\def\pgfpathsvg#1{% + \let\pgf@lib@svg@finish@prev\relax% + {% + \pgftransforminvert% + \pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@path@lastx}{\pgf@path@lasty}}} + } + \pgf@lib@svg@last@x\pgf@x% + \pgf@lib@svg@last@y\pgf@y% + \let\pgf@lib@svg@num=\pgfutil@empty% + \pgfparserparse{svgpath}#1"% +} + + + +\newdimen\pgf@lib@svg@last@x +\newdimen\pgf@lib@svg@last@y +\newdimen\pgf@lib@svg@last@c@x +\newdimen\pgf@lib@svg@last@c@y + +\newcount\pgf@lib@svg@count +\newcount\pgf@lib@svg@max@num + +\newif\pgf@lib@svg@relative + + + +% For the smooth commands (S, s, T, t) we need to keep track of the +% previous control points. This is done in the following two +% variables. If they are empty, there was no previous control point of +% the desired kind, in which case the specification prescribes that +% the start point is used. + +\def\pgf@lib@svg@clear@bezier@quad{ + \let\pgf@lib@svg@bezier@last=\pgfutil@empty + \let\pgf@lib@svg@quad@last=\pgfutil@empty +} +\pgf@lib@svg@clear@bezier@quad + +% +% Here comes the DFA: +% + +% Handle a moveto: + +\pgfparserdef{svgpath}{all}{the letter M} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@moveto} +} + +\def\pgf@lib@svg@moveto{% + \pgf@lib@svg@clear@bezier@quad% + \pgf@lib@svg@last@x=\pgf@lib@svg@get@num{0}pt% + \pgf@lib@svg@last@y=\pgf@lib@svg@get@num{1}pt% + \pgfpathmoveto{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@lineto} +} + + +% Handle a relative moveto: + +\pgfparserdef{svgpath}{all}{the letter m} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@moveto@rel} +} + +\def\pgf@lib@svg@moveto@rel{% + \pgf@lib@svg@clear@bezier@quad% + \advance\pgf@lib@svg@last@x by\pgf@lib@svg@get@num{0}pt% + \advance\pgf@lib@svg@last@y by\pgf@lib@svg@get@num{1}pt% + \pgfpathmoveto{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@lineto@rel} +} + + +% Handle a lineto: + +\pgfparserdef{svgpath}{all}{the letter L} +{ + \pgf@lib@svg@finish@prev% + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@lineto} +} + +\def\pgf@lib@svg@lineto{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + \pgf@lib@svg@clear@bezier@quad% + \pgf@lib@svg@last@x=\pgf@lib@svg@get@num{0}pt% + \pgf@lib@svg@last@y=\pgf@lib@svg@get@num{1}pt% + \pgfpathlineto{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@lineto}% + \fi +} + + +% Handle a relative lineto: + +\pgfparserdef{svgpath}{all}{the letter l} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@lineto@rel} +} + +\def\pgf@lib@svg@lineto@rel{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + \pgf@lib@svg@clear@bezier@quad% + \advance\pgf@lib@svg@last@x by\pgf@lib@svg@get@num{0}pt% + \advance\pgf@lib@svg@last@y by\pgf@lib@svg@get@num{1}pt% + \pgfpathlineto{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@lineto@rel}% + \fi +} + + +% Handle a closepath: + +\pgfparserdef{svgpath}{all}{the letter Z} +{ + \pgf@lib@svg@closepath +} + +\pgfparserdef{svgpath}{all}{the letter z} +{ + \pgf@lib@svg@closepath +} + +\def\pgf@lib@svg@closepath{ + \pgf@lib@svg@finish@prev + \pgfpathclose + \let\pgf@lib@svg@finish@prev=\relax + \pgf@lib@svg@clear@bezier@quad% + \pgfparserswitch{initial}% +} + + + + + +% Handle a horizontal lineto: + +\pgfparserdef{svgpath}{all}{the letter H} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{1}{\pgf@lib@svg@hlineto} +} + +\def\pgf@lib@svg@hlineto{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + \pgf@lib@svg@clear@bezier@quad% + \pgf@lib@svg@last@x=\pgf@lib@svg@get@num{0}pt% + \pgfpathlineto{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + \pgf@lib@svg@read@nums{1}{\pgf@lib@svg@hlineto} + \fi +} + +\pgfparserdef{svgpath}{all}{the letter h} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{1}{\pgf@lib@svg@hlineto@rel} +} + +\def\pgf@lib@svg@hlineto@rel{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + \pgf@lib@svg@clear@bezier@quad% + \advance\pgf@lib@svg@last@x by\pgf@lib@svg@get@num{0}pt% + \pgfpathlineto{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + \pgf@lib@svg@read@nums{1}{\pgf@lib@svg@hlineto@rel} + \fi +} + + +% Handle a horizontal lineto: + +\pgfparserdef{svgpath}{all}{the letter V} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{1}{\pgf@lib@svg@vlineto} +} + +\def\pgf@lib@svg@vlineto{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + \pgf@lib@svg@clear@bezier@quad% + \pgf@lib@svg@last@y=\pgf@lib@svg@get@num{0}pt% + \pgfpathlineto{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + \pgf@lib@svg@read@nums{1}{\pgf@lib@svg@vlineto} + \fi +} + +\pgfparserdef{svgpath}{all}{the letter v} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{1}{\pgf@lib@svg@vlineto@rel} +} + +\def\pgf@lib@svg@vlineto@rel{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + \pgf@lib@svg@clear@bezier@quad% + \advance\pgf@lib@svg@last@y by\pgf@lib@svg@get@num{0}pt% + \pgfpathlineto{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + \pgf@lib@svg@read@nums{1}{\pgf@lib@svg@vlineto@rel} + \fi +} + + + + +% Handle a Bezier curve: + +\pgfparserdef{svgpath}{all}{the letter C} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{6}{\pgf@lib@svg@curveto} +} + +\def\pgf@lib@svg@curveto{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Clear quadratic last point and save new last control point: + \let\pgf@lib@svg@quad@last=\pgfutil@empty% + \edef\pgf@lib@svg@bezier@last{% + \noexpand\pgfqpoint{\pgf@lib@svg@get@num{2}pt}{\pgf@lib@svg@get@num{3}pt}}% + % Draw curve + \pgf@lib@svg@last@x=\pgf@lib@svg@get@num{4}pt% + \pgf@lib@svg@last@y=\pgf@lib@svg@get@num{5}pt% + \pgfpathcurveto + {\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}% + {\pgfqpoint{\pgf@lib@svg@get@num{2}pt}{\pgf@lib@svg@get@num{3}pt}}% + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + % Go on + \pgf@lib@svg@read@nums{6}{\pgf@lib@svg@curveto} + \fi +} + + +\pgfparserdef{svgpath}{all}{the letter c} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{6}{\pgf@lib@svg@curveto@rel} +} + +\def\pgf@lib@svg@curveto@rel{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Clear quadratic last point and save new last control point: + \let\pgf@lib@svg@quad@last=\pgfutil@empty% + \pgf@process{\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{2}pt}{\pgf@lib@svg@get@num{3}pt}}} + \edef\pgf@lib@svg@bezier@last{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % Draw curve + \pgfpathcurveto + {\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}}% + {\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{2}pt}{\pgf@lib@svg@get@num{3}pt}}}% + {\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{4}pt}{\pgf@lib@svg@get@num{5}pt}}}% + \advance\pgf@lib@svg@last@x by\pgf@lib@svg@get@num{4}pt% + \advance\pgf@lib@svg@last@y by\pgf@lib@svg@get@num{5}pt% + \pgf@lib@svg@read@nums{6}{\pgf@lib@svg@curveto@rel} + \fi +} + + + + + +\pgfparserdef{svgpath}{all}{the letter S} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{4}{\pgf@lib@svg@curveto@smooth} +} + +\def\pgf@lib@svg@curveto@smooth{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Draw curve + % Compute first control point + \ifx\pgf@lib@svg@bezier@last\pgfutil@empty% + \def\pgf@lib@svg@first@cp{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + \else + \def\pgf@lib@svg@first@cp{ + \pgfpointadd + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + {\pgfpointdiff + {\pgf@lib@svg@bezier@last} + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + } + } + \fi + \pgfpathcurveto + {\pgf@lib@svg@first@cp} + {\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}% + {\pgfqpoint{\pgf@lib@svg@get@num{2}pt}{\pgf@lib@svg@get@num{3}pt}}% + % Clear quadratic last point and save new last control point: + \let\pgf@lib@svg@quad@last=\pgfutil@empty% + \edef\pgf@lib@svg@bezier@last{% + \noexpand\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}% + % Update + \pgf@lib@svg@last@x=\pgf@lib@svg@get@num{2}pt% + \pgf@lib@svg@last@y=\pgf@lib@svg@get@num{3}pt% + % Go on + \pgf@lib@svg@read@nums{4}{\pgf@lib@svg@curveto@smooth} + \fi +} + + +\pgfparserdef{svgpath}{all}{the letter s} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{4}{\pgf@lib@svg@curveto@rel@smooth} +} + +\def\pgf@lib@svg@curveto@rel@smooth{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Draw curve + % Compute first control point + \ifx\pgf@lib@svg@bezier@last\pgfutil@empty% + \def\pgf@lib@svg@first@cp{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + \else + \def\pgf@lib@svg@first@cp{ + \pgfpointadd + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + {\pgfpointdiff + {\pgf@lib@svg@bezier@last} + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + } + } + \fi + \pgfpathcurveto + {\pgf@lib@svg@first@cp} + {\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}}% + {\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{2}pt}{\pgf@lib@svg@get@num{3}pt}}}% + % Clear quadratic last point and save new last control point: + \let\pgf@lib@svg@quad@last=\pgfutil@empty% + \pgf@process{\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{2}pt}{\pgf@lib@svg@get@num{3}pt}}} + \edef\pgf@lib@svg@bezier@last{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % update + \advance\pgf@lib@svg@last@x by\pgf@lib@svg@get@num{2}pt% + \advance\pgf@lib@svg@last@y by\pgf@lib@svg@get@num{3}pt% + % Go on + \pgf@lib@svg@read@nums{4}{\pgf@lib@svg@curveto@rel@smooth} + \fi +} + + + + +% Handle a quadratic curve: + +\pgfparserdef{svgpath}{all}{the letter Q} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{4}{\pgf@lib@svg@quad@curveto} +} + +\def\pgf@lib@svg@quad@curveto{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Clear bezier last point and save new last control point: + \let\pgf@lib@svg@bezier@last=\pgfutil@empty% + \edef\pgf@lib@svg@quad@last{% + \noexpand\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}% + % Draw curve + \pgf@lib@svg@last@x=\pgf@lib@svg@get@num{2}pt% + \pgf@lib@svg@last@y=\pgf@lib@svg@get@num{3}pt% + \pgfpathquadraticcurveto + {\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}% + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + % Go on + \pgf@lib@svg@read@nums{4}{\pgf@lib@svg@quad@curveto} + \fi +} + + +\pgfparserdef{svgpath}{all}{the letter q} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{4}{\pgf@lib@svg@quad@curveto@rel} +} + +\def\pgf@lib@svg@quad@curveto@rel{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Clear quadratic last point and save new last control point: + \let\pgf@lib@svg@bezier@last=\pgfutil@empty% + \pgf@process{\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}} + \edef\pgf@lib@svg@quad@last{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % Draw curve + \pgfpathquadraticcurveto + {\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}}% + {\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{2}pt}{\pgf@lib@svg@get@num{3}pt}}}% + \advance\pgf@lib@svg@last@x by\pgf@lib@svg@get@num{2}pt% + \advance\pgf@lib@svg@last@y by\pgf@lib@svg@get@num{3}pt% + \pgf@lib@svg@read@nums{4}{\pgf@lib@svg@quad@curveto@rel} + \fi +} + + + + +\pgfparserdef{svgpath}{all}{the letter T} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@quad@curveto@smooth} +} + +\def\pgf@lib@svg@quad@curveto@smooth{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Draw curve + % Compute first control point + \pgf@process{ + \ifx\pgf@lib@svg@quad@last\pgfutil@empty% + \pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y} + \else + \pgfpointadd + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + {\pgfpointdiff + {\pgf@lib@svg@quad@last} + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + } + \fi + } + \edef\pgf@lib@svg@first@cp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfpathquadraticcurveto + {\pgf@lib@svg@first@cp} + {\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}% + % Clear quadratic last point and save new last control point: + \let\pgf@lib@svg@bezier@last=\pgfutil@empty% + \let\pgf@lib@svg@quad@last=\pgf@lib@svg@first@cp% + % Update + \pgf@lib@svg@last@x=\pgf@lib@svg@get@num{0}pt% + \pgf@lib@svg@last@y=\pgf@lib@svg@get@num{1}pt% + % Go on + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@quad@curveto@smooth} + \fi +} + + +\pgfparserdef{svgpath}{all}{the letter t} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@quad@curveto@rel@smooth} +} + +\def\pgf@lib@svg@quad@curveto@rel@smooth{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Draw curve + % Compute first control point + \pgf@process{ + \ifx\pgf@lib@svg@quad@last\pgfutil@empty% + \pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y} + \else + \pgfpointadd + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + {\pgfpointdiff + {\pgf@lib@svg@quad@last} + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}} + } + \fi + } + \edef\pgf@lib@svg@first@cp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfpathquadraticcurveto + {\pgf@lib@svg@first@cp} + {\pgfpointadd{\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}{\pgfqpoint{\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt}}}% + % Clear quadratic last point and save new last control point: + \let\pgf@lib@svg@bezier@last=\pgfutil@empty% + \let\pgf@lib@svg@quad@last=\pgf@lib@svg@first@cp% + % update + \advance\pgf@lib@svg@last@x by\pgf@lib@svg@get@num{0}pt% + \advance\pgf@lib@svg@last@y by\pgf@lib@svg@get@num{1}pt% + % Go on + \pgf@lib@svg@read@nums{2}{\pgf@lib@svg@quad@curveto@rel@smooth} + \fi +} + + + +% Handle an arcto: + +\pgfparserdef{svgpath}{all}{the letter A} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{7}{\pgf@lib@svg@arcto} +} + +\def\pgf@lib@svg@arcto{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Clear bezier last point and save new last control point: + \pgf@lib@svg@clear@bezier@quad% + % Draw curve + \pgf@lib@svg@last@x=\pgf@lib@svg@get@num{5}pt% + \pgf@lib@svg@last@y=\pgf@lib@svg@get@num{6}pt% + \pgfpatharcto + {\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt} + {\pgf@lib@svg@get@num{2}} + {\pgf@lib@svg@get@num{3}} + {\pgf@lib@svg@get@num{4}} + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + % Go on + \pgf@lib@svg@read@nums{7}{\pgf@lib@svg@arcto} + \fi +} + +\pgfparserdef{svgpath}{all}{the letter a} +{ + \pgf@lib@svg@finish@prev + \pgf@lib@svg@read@nums{7}{\pgf@lib@svg@arcto@rel} +} + +\def\pgf@lib@svg@arcto@rel{% + \ifnum\pgf@lib@svg@count=0\relax% nothing read + \else% + % Clear bezier last point and save new last control point: + \pgf@lib@svg@clear@bezier@quad% + % Draw curve + \advance\pgf@lib@svg@last@x by\pgf@lib@svg@get@num{5}pt% + \advance\pgf@lib@svg@last@y by\pgf@lib@svg@get@num{6}pt% + \pgfpatharcto + {\pgf@lib@svg@get@num{0}pt}{\pgf@lib@svg@get@num{1}pt} + {\pgf@lib@svg@get@num{2}} + {\pgf@lib@svg@get@num{3}} + {\pgf@lib@svg@get@num{4}} + {\pgfqpoint{\pgf@lib@svg@last@x}{\pgf@lib@svg@last@y}}% + % Go on + \pgf@lib@svg@read@nums{7}{\pgf@lib@svg@arcto@rel} + \fi +} + + + + + +% Handle to end of the world + +\pgfparserdef{svgpath}{all}{the character "} +{ + \pgf@lib@svg@finish@prev + \pgfparserswitch{final} +} + + + + +% Handle spacers for numbers + +\def\pgf@lib@svg@read@nums#1#2{% get #1 number symbols, then do #2 + \pgf@lib@svg@count=0\relax + \pgf@lib@svg@max@num=#1\relax + \pgfparserswitch{num} + \def\pgf@lib@svg@finish@prev{ + \ifx\pgf@lib@svg@num\pgfutil@empty% + \else% + \expandafter\let\csname pgf@lib@svg@num@\the\pgf@lib@svg@count\endcsname=\pgf@lib@svg@num + \advance\pgf@lib@svg@count by1\relax% + \let\pgf@lib@svg@num=\pgfutil@empty% + \fi + #2 + } +} + +\def\pgf@lib@svg@get@num#1{\csname pgf@lib@svg@num@#1\endcsname} + + +\pgfparserdef{svgpath}{num}{the character ,} +{ + \pgf@lib@svg@handle@spacer +} + +\pgfparserdef{svgpath}{num}{\meaning\pgfutil@sptoken} +{ + \pgf@lib@svg@handle@spacer +} + +\pgfparserdef{svgpath}{num}{the character -} +{ + \pgf@lib@svg@handle@spacer + \def\pgf@lib@svg@num{-}% +} + +\def\pgf@lib@svg@handle@spacer{ + \ifx\pgf@lib@svg@num\pgfutil@empty% + % ignore + \else + \expandafter\let\csname pgf@lib@svg@num@\the\pgf@lib@svg@count\endcsname=\pgf@lib@svg@num + \advance\pgf@lib@svg@count by1\relax% + \ifnum\pgf@lib@svg@count=\pgf@lib@svg@max@num\relax% + \pgf@lib@svg@finish@prev% + \fi + \let\pgf@lib@svg@num=\pgfutil@empty% + \fi +} + + +% Handle digits + +\pgfparserdef{svgpath}{all}{the character .} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num.}} + +\pgfparserdef{svgpath}{all}{the character 0} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num0}} + +\pgfparserdef{svgpath}{all}{the character 1} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num1}} + +\pgfparserdef{svgpath}{all}{the character 2} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num2}} + +\pgfparserdef{svgpath}{all}{the character 3} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num3}} + +\pgfparserdef{svgpath}{all}{the character 4} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num4}} + +\pgfparserdef{svgpath}{all}{the character 5} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num5}} + +\pgfparserdef{svgpath}{all}{the character 6} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num6}} + +\pgfparserdef{svgpath}{all}{the character 7} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num7}} + +\pgfparserdef{svgpath}{all}{the character 8} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num8}} + +\pgfparserdef{svgpath}{all}{the character 9} +{\expandafter\def\expandafter\pgf@lib@svg@num\expandafter{\pgf@lib@svg@num9}} + + + + diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.ee.IEC.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.ee.IEC.code.tex new file mode 100644 index 00000000000..e79634a06ea --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.ee.IEC.code.tex @@ -0,0 +1,680 @@ +% Copyright 2008 by Till Tantau and others Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + + +% +% Resistor shape based on a zig-zag-line +% + +\pgfdeclareshape{var resistor IEC} +{ + \inheritsavedanchors[from=rectangle ee] + \inheritanchor[from=rectangle ee]{center} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + \inheritanchorborder[from=rectangle ee] + + \backgroundpath{ + \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} + \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + % Middle line + \pgf@yc=.5\pgf@ya + \advance\pgf@yc by.5\pgf@yb + % Height + \pgf@xc=-.5\pgf@ya + \advance\pgf@xc by.5\pgf@yb + % Start point + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yc}} + % Lines + \advance\pgf@xb by.1pt% + \pgfutil@loop% + \advance\pgf@xa by4\pgf@xc\relax% + \ifdim\pgf@xa<\pgf@xb% + \advance\pgf@xa by-3\pgf@xc% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \advance\pgf@xa by2\pgf@xc% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \advance\pgf@xa by\pgf@xc% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yc}}% + \pgfutil@repeat% + \advance\pgf@xb by-.1pt% + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yc}}% + } +} + + + +% +% Inductor shape based on a bumpy line +% + +\pgfdeclareshape{inductor IEC} +{ + \savedanchor\northeast{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \pgf@x=\pgf@xa% + \advance\pgf@x by .5\pgf@xb% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% + \pgf@y=\pgf@ya% + \advance\pgf@y by\pgf@yb% + } + \savedanchor\southwest{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \pgf@x=-\pgf@xa% + \advance\pgf@x by -.5\pgf@xb% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \pgf@y=-\pgf@ya% + } + + \anchor{center}{\pgfpointorigin} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + + \anchorborder{% + \ifdim\pgf@y<0pt% + % tricky... simpilfy to the origin... + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\southwest}% + \advance\pgf@y by-0.5pt% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgfpointborderrectangle{\pgfqpoint{\pgf@xc}{\the\pgf@yc}}{\pgfqpoint{-\pgf@xa}{-\pgf@ya}}}% + \else% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\pgfpointborderrectangle{\pgfqpoint{\pgf@xc}{\the\pgf@yc}}{\northeast}}% + \fi% + } + + \backgroundpath{ + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xa=-\pgf@x \pgf@ya=0pt + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + % Height + \pgf@xc=\pgf@yb% + % Start point + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{0pt}} + % Lines + \advance\pgf@xb by.1pt% + \pgfutil@loop% + \advance\pgf@xa by2\pgf@xc\relax% + \ifdim\pgf@xa<\pgf@xb% + \pgfpatharc{180}{0}{\pgf@xc}% + \pgfutil@repeat% + \advance\pgf@xb by-.1pt% + \pgfpathlineto{\pgfqpoint{\pgf@xb}{0pt}}% + } +} + + + + +% +% Simple capacitor, consisting of two parallel lines +% + +\pgfdeclareshape{capacitor IEC} +{ + \inheritsavedanchors[from=rectangle ee] + \inheritanchor[from=rectangle ee]{center} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + \inheritanchorborder[from=rectangle ee] + + \backgroundpath{ + \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} + \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} + \pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} + } +} + + + + +% +% Simple ground, consisting of three lines, getting smaller +% + +\pgfdeclareshape{ground IEC} +{ + \inheritsavedanchors[from=rectangle ee] + \inheritanchor[from=rectangle ee]{center} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + \inheritanchorborder[from=rectangle ee] + + \backgroundpath{ + \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} + \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + % First line, simple + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} + % Advance to middle + \pgfmathsetlength\pgf@xa{.5\pgf@xa+.5\pgf@xb} + % Make smaller + \pgfmathsetlength\pgf@yc{.16666\pgf@yb-.16666\pgf@ya} + \advance\pgf@ya by\pgf@yc + \advance\pgf@yb by-\pgf@yc + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} + % Make even smaller + \advance\pgf@ya by\pgf@yc + \advance\pgf@yb by-\pgf@yc + \pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} + } +} + + + +% +% Battery, consisting of two parallel lines, one smaller than +% the other +% + +\pgfdeclareshape{battery IEC} +{ + \inheritsavedanchors[from=rectangle ee] + \inheritanchor[from=rectangle ee]{center} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + \inheritanchorborder[from=rectangle ee] + + \backgroundpath{ + \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} + \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + % First line, simple + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} + % Make smaller + \pgfmathsetlength\pgf@yc{.25\pgf@yb-.25\pgf@ya} + \advance\pgf@ya by\pgf@yc + \advance\pgf@yb by-\pgf@yc + \pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} + } +} + + +% +% Special diodes +% + + +\pgfdeclareshape{breakdown diode IEC} +{ + \inheritsavedanchors[from=rectangle ee] + \inheritanchor[from=rectangle ee]{center} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + \inheritanchorborder[from=rectangle ee] + + \backgroundpath{ + \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} + \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + \pgf@xc=.5\pgf@xa \advance\pgf@xc by.5\pgf@xb + \pgf@yc=.5\pgf@ya + \advance\pgf@yc by .5\pgf@yb + % Triangles: + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@yc}} + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} + \pgfpathclose + \pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@yc}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} + \pgfpathclose + } + + + \beforebackgroundpath{ + { + \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} + \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + \pgf@yc=.5\pgf@ya + \advance\pgf@yc by.5\pgf@yb + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yc}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yc}} + \pgfusepathqstroke + \pgf@xc=.5\pgf@xa + \advance\pgf@xc by.5\pgf@xb + \pgftransformshift{\pgfqpoint{\pgf@xc}{\pgf@yc}} + \pgf@yc=.5\pgf@yb + \advance\pgf@yc by-.5\pgf@ya + \pgftransformscale{\pgf@sys@tonumber{\pgf@yc}} + \pgfpathmoveto{\pgfqpoint{-.5pt}{-1pt}} + \pgfpathlineto{\pgfqpoint{0pt}{-1pt}} + \pgfpathlineto{\pgfqpoint{0pt}{1pt}} + \pgfpathlineto{\pgfqpoint{.5pt}{1pt}} + \pgfusepathqstroke + } + } +} + + + + + + +% Generic shapes +% +% When these shapes are used, you can set a key derived form the +% shapes name to some code that will be executed as the before +% background path. This means that the basic shape is fixed, but +% things like a special line inside the shape or at the border can be +% added without having to define a whole new shape. + + +\pgfdeclareshape{generic circle IEC} +{ + % This shape is a generic circle, to which you can add something to + % the before background path using the key + % /pgf/generic circle IEC/before background + % When this key is invoked, the transformation matrix will have been + % setup such that the circle's center is at the origin and that the + % position \pgfpoint{1pt}{0pt} lies exactly on the top of the circle + % (and, there, on the middle of the line). + + \inheritsavedanchors[from=circle ee] + \inheritanchorborder[from=circle ee] + \inheritanchor[from=circle ee]{north} + \inheritanchor[from=circle ee]{north west} + \inheritanchor[from=circle ee]{north east} + \inheritanchor[from=circle ee]{center} + \inheritanchor[from=circle ee]{west} + \inheritanchor[from=circle ee]{east} + \inheritanchor[from=circle ee]{south} + \inheritanchor[from=circle ee]{south west} + \inheritanchor[from=circle ee]{south east} + \inheritanchor[from=circle ee]{input} + \inheritanchor[from=circle ee]{output} + \inheritbackgroundpath[from=circle ee] + + \beforebackgroundpath{ + { + \centerpoint% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgftransformshift{} + \pgfutil@tempdima=\radius% + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb% + \advance\pgfutil@tempdima by-\pgf@yb% + \else% + \advance\pgfutil@tempdima by-\pgf@xb% + \fi% + \pgftransformscale{\pgf@sys@tonumber{\pgfutil@tempdima}} + \pgfkeysvalueof{/pgf/generic circle IEC/before background} + } + } +} + + + +% +% Generic diode, based on a rectangle +% + +\pgfdeclareshape{generic diode IEC} +{ + % This shape is a generic diode, to which you can add something to + % the before background path using the key + % /pgf/generic diode IEC/before background + % When this key is invoked, the transformation matrix will have been + % setup such that the center is at the tip of the diode. The + % position \pgfpoint{1pt}{0pt} lies exactly on the top of the + % (suggested) line before the diode. + + \inheritsavedanchors[from=rectangle ee] + \inheritanchor[from=rectangle ee]{center} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + \inheritanchorborder[from=rectangle ee] + + \backgroundpath{ + \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} + \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + % Move tip back a little bit + \advance\pgf@xb by-.5\pgflinewidth + % Triangle triangle: + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}} + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} + \pgf@yc=.5\pgf@ya + \advance\pgf@yc by .5\pgf@yb + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yc}} + \pgfpathclose + } + + + \beforebackgroundpath{ + { + \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} + \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + \pgf@yc=.5\pgf@ya + \advance\pgf@yc by.5\pgf@yb + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yc}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yc}} + \pgfusepathqstroke + \pgftransformshift{\pgfqpoint{\pgf@xb}{\pgf@yc}} + \pgf@yc=.5\pgf@yb + \advance\pgf@yc by-.5\pgf@ya + \pgftransformscale{\pgf@sys@tonumber{\pgf@yc}} + \pgfkeysvalueof{/pgf/generic diode IEC/before background} + } + } +} + + +\pgfkeys{ + /pgf/generic circle IEC/before background/.initial=, + /pgf/generic diode IEC/before background/.initial=, +} + + + + + +% +% Concacts +% + +\pgfdeclareshape{make contact IEC} +{ + \savedanchor\northeast{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \pgf@x=\pgf@xa% + \advance\pgf@x by .5\pgf@xb% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% + \pgf@y=\pgf@ya% + \advance\pgf@y by\pgf@yb% + } + \savedanchor\southwest{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \pgf@x=-.5\pgf@xa% + \advance\pgf@x by -.5\pgf@xb% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \pgf@y=-\pgf@ya% + } + + \anchor{center}{\pgfpointorigin} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + + \anchorborder{% + \ifdim\pgf@y<0pt% + % tricky... simpilfy to the origin... + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\southwest}% + \advance\pgf@y by-0.5pt% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgfpointborderrectangle{\pgfqpoint{\pgf@xc}{\the\pgf@yc}}{\pgfqpoint{-\pgf@xa}{-\pgf@ya}}}% + \else% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\pgfpointborderrectangle{\pgfqpoint{\pgf@xc}{\the\pgf@yc}}{\northeast}}% + \fi% + } + + \backgroundpath{ + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xa=-\pgf@x \pgf@ya=0pt + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + % Start point + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{0pt}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} + } +} + + + +% +% Concacts +% + +\pgfdeclareshape{var make contact IEC} +{ + \savedanchor\northeast{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \pgf@x=\pgf@xa% + \advance\pgf@x by .5\pgf@xb% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% + \pgf@y=\pgf@ya% + \advance\pgf@y by\pgf@yb% + } + \savedanchor\southwest{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \pgf@x=-.5\pgf@xa% + \advance\pgf@x by -.5\pgf@xb% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \pgf@y=-\pgf@ya% + \pgf@xc=0.083333\pgf@x% + \advance\pgf@y by\pgf@xc% + } + + \anchor{center}{\pgfpointorigin} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + + \anchorborder{% + \ifdim\pgf@y<0pt% + % tricky... simpilfy to the origin... + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\southwest}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgfpointborderrectangle{\pgfqpoint{\pgf@xc}{\the\pgf@yc}}{\pgfqpoint{-\pgf@xa}{-\pgf@ya}}}% + \else% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\pgfpointborderrectangle{\pgfqpoint{\pgf@xc}{\the\pgf@yc}}{\northeast}}% + \fi% + } + + \backgroundpath{ + \pgf@process{\pgfpointadd{\northeast}{ + \pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xa=-\pgf@x \pgf@ya=0pt + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + \pgf@xc=\pgf@xa + \pgfutil@tempdima=2\pgf@xb% + \pgfutil@tempdima=0.083333\pgfutil@tempdima% + \advance\pgf@xa by \pgfutil@tempdima + % Circle + {\pgfpathcircle{\pgfqpoint{\pgf@xa}{0pt}}{\pgfutil@tempdima}} + % Height + % Start point + \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgfqpoint{\pgf@xa}{0pt}}{\pgfqpoint{\pgf@xb}{\pgf@yb}}}} + \pgf@xc=\pgf@x + \pgf@yc=\pgf@y + \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xa}{0pt}}{% + \pgfpointscale{\pgfutil@tempdima}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} + } +} + + + +\pgfdeclareshape{break contact IEC} +{ + \savedanchor\northeast{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \pgf@x=\pgf@xa% + \advance\pgf@x by .5\pgf@xb% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% + \pgf@y=\pgf@ya% + \advance\pgf@y by\pgf@yb% + } + \savedanchor\southwest{% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% + \pgf@x=-.5\pgf@xa% + \advance\pgf@x by -.5\pgf@xb% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% + \pgf@y=-\pgf@ya% + } + + \anchor{center}{\pgfpointorigin} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + + \anchorborder{% + \ifdim\pgf@y<0pt% + % tricky... simpilfy to the origin... + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\southwest}% + \advance\pgf@y by-0.5pt% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgfpointborderrectangle{\pgfqpoint{\pgf@xc}{\the\pgf@yc}}{\pgfqpoint{-\pgf@xa}{-\pgf@ya}}}% + \else% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\pgfpointborderrectangle{\pgfqpoint{\pgf@xc}{\the\pgf@yc}}{\northeast}}% + \fi% + } + + \backgroundpath{ + \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} + \pgf@xa=-\pgf@x \pgf@ya=0pt + \pgf@xb=\pgf@x \pgf@yb=\pgf@y + % Start point + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{0pt}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} + % Break point + \pgf@xc=.2\pgf@xb + \advance\pgf@xc by-.2\pgf@xa + \pgfpathmoveto{\pgfqpoint{\pgf@xb}{0pt}} + \advance\pgf@xb by-\pgf@xc + \pgfpathlineto{\pgfqpoint{\pgf@xb}{0pt}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} + } +} + + + + + +\endinput + diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.ee.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.ee.code.tex new file mode 100644 index 00000000000..ddf8a29f629 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.ee.code.tex @@ -0,0 +1,176 @@ +% Copyright 2008 by Till Tantau and others Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + + + +% +% Base shapes +% +% These shapes are identical to the shapes without "ee", only an "input" +% and an "output" anchor have been added at the left and right end. + +\pgfdeclareshape{rectangle ee} +{ + \inheritsavedanchors[from=rectangle] + \inheritanchorborder[from=rectangle] + \inheritanchor[from=rectangle]{north} + \inheritanchor[from=rectangle]{north west} + \inheritanchor[from=rectangle]{north east} + \inheritanchor[from=rectangle]{center} + \inheritanchor[from=rectangle]{west} + \inheritanchor[from=rectangle]{east} + \inheritanchor[from=rectangle]{mid} + \inheritanchor[from=rectangle]{mid west} + \inheritanchor[from=rectangle]{mid east} + \inheritanchor[from=rectangle]{base} + \inheritanchor[from=rectangle]{base west} + \inheritanchor[from=rectangle]{base east} + \inheritanchor[from=rectangle]{south} + \inheritanchor[from=rectangle]{south west} + \inheritanchor[from=rectangle]{south east} + \inheritbackgroundpath[from=rectangle] + % New: + \anchor{input}{ + \pgf@process{\northeast}% + \pgf@ya=.5\pgf@y% + \pgf@process{\southwest}% + \pgf@y=.5\pgf@y% + \advance\pgf@y by \pgf@ya% + } + \anchor{output}{% + \pgf@process{\southwest}% + \pgf@ya=.5\pgf@y% + \pgf@process{\northeast}% + \pgf@y=.5\pgf@y% + \advance\pgf@y by \pgf@ya% + } +} + +\pgfdeclareshape{circle ee} +{ + \inheritsavedanchors[from=circle] + \inheritanchorborder[from=circle] + \inheritanchor[from=circle]{north} + \inheritanchor[from=circle]{north west} + \inheritanchor[from=circle]{north east} + \inheritanchor[from=circle]{center} + \inheritanchor[from=circle]{west} + \inheritanchor[from=circle]{east} + \inheritanchor[from=circle]{mid} + \inheritanchor[from=circle]{mid west} + \inheritanchor[from=circle]{mid east} + \inheritanchor[from=circle]{base} + \inheritanchor[from=circle]{base west} + \inheritanchor[from=circle]{base east} + \inheritanchor[from=circle]{south} + \inheritanchor[from=circle]{south west} + \inheritanchor[from=circle]{south east} + \inheritbackgroundpath[from=circle] + % New: + \anchor{input}{\centerpoint\advance\pgf@x by-\radius} + \anchor{output}{\centerpoint\advance\pgf@x by\radius} +} + + + +% +% Current direction indicator. This shape uses the current setting of +% the current direction arrow tip for the arrow. The shape is a +% rectangle around the arrow tip. +% + +\pgfdeclareshape{direction ee} +{ + \savedanchor\northeast{ + % Right border is given by right extend + \pgf@x=0pt% + \csname pgf@arrow@right@\pgfkeysvalueof{/pgf/direction ee arrow}\endcsname + % Height is given by minimum height/2 + \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/minimum height}}% + \pgf@y=.5\pgf@y + } + \savedanchor\southwest{ + % Left border is given by left extend + \pgf@x=0pt% + \csname pgf@arrow@left@\pgfkeysvalueof{/pgf/direction ee arrow}\endcsname + \pgf@x=-\pgf@x% + % Height is given by minimum height/2 + \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/minimum height}}% + \pgf@y=-.5\pgf@y + } + + \inheritanchor[from=rectangle ee]{center} + \inheritanchor[from=rectangle ee]{north} + \inheritanchor[from=rectangle ee]{south} + \inheritanchor[from=rectangle ee]{east} + \inheritanchor[from=rectangle ee]{west} + \inheritanchor[from=rectangle ee]{north east} + \inheritanchor[from=rectangle ee]{north west} + \inheritanchor[from=rectangle ee]{south east} + \inheritanchor[from=rectangle ee]{south west} + \inheritanchor[from=rectangle ee]{input} + \inheritanchor[from=rectangle ee]{output} + \inheritanchorborder[from=rectangle ee] + \nodeparts{}% no text + + \behindbackgroundpath{ + \pgf@process{\southwest} + \pgf@xa=\pgf@x + \pgf@process{\northeast} + \pgf@xb=\pgf@x + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{0pt}} + \pgfpathlineto{\pgfqpoint{\pgf@xb}{0pt}} + \pgfusepathqstroke + } + + \beforebackgroundpath{ + { + \pgfsetarrowsend{\pgfkeysvalueof{/pgf/direction ee arrow}} + \pgfsys@beginscope + \pgflowlevelsynccm% + \pgflowlevelobj{}{\pgf@endarrow}% + \pgfsys@endscope + } + } +} + +\pgfkeys{ + /pgf/direction ee arrow/.initial=direction ee, +} + + + +% Special arrow for ee directions: + +\pgfarrowsdeclare{direction ee}{direction ee} +{ + \pgfmathsetlength\pgfutil@tempdima{\pgfgetarrowoptions{direction ee}}% + \pgfutil@tempdima=.5\pgfutil@tempdima + \pgfarrowsleftextend{+-\pgfutil@tempdima} + \pgfarrowsrightextend{+\pgfutil@tempdima} +} +{ + \pgfmathsetlength\pgfutil@tempdima{\pgfgetarrowoptions{direction ee}}% + \pgfsetdash{}{+0pt} + \pgfsetroundjoin + \pgfpathmoveto{\pgfqpoint{-0.5\pgfutil@tempdima}{0.38268343237\pgfutil@tempdima}} + \pgfpathlineto{\pgfqpoint{0.5\pgfutil@tempdima}{0\pgfutil@tempdima}} + \pgfpathlineto{\pgfqpoint{-0.5\pgfutil@tempdima}{-0.38268343237\pgfutil@tempdima}} + \pgfpathclose + \pgfusepathqfillstroke +} + +\pgfsetarrowoptions{direction ee}{4pt} + + + + + +\endinput + diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.gates.logic.IEC.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.logic.IEC.code.tex index 881cda69d98..5b2beb2b0fb 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.gates.logic.IEC.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.logic.IEC.code.tex @@ -7,12 +7,9 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. +\usepgflibrary{shapes.gates.logic} \pgfkeys{/pgf/.cd, - logic gate input sep/.initial=0.125cm, - logic gate inputs/.initial={normal,normal},% - logic gate inverted radius/.initial=2pt,% - logic gate anchors use bounding box/.is if=pgfgateanchorsuseboundingrectangle,% and gate IEC symbol/.initial=$\char`\&$, nand gate IEC symbol/.initial=$\char`\&$, or gate IEC symbol/.initial=$\geq1$, @@ -32,84 +29,6 @@ right/.code=\pgftransformxshift{\innerhalfwidth} } -% Internal macro for parsing inputs. -% -\expandafter\ifx\csname pgf@lib@sh@logicgate@parseinputs\endcsname\relax% -\def\pgf@lib@sh@logicgate@parseinputs#1{% - \edef\pgf@lib@sh@temp{\pgfkeysvalueof{/pgf/logic gate inputs}}% - \c@pgf@counta#1\relax% - \c@pgf@countb0\relax% - \expandafter\pgfutil@in@\expandafter,\expandafter{\pgf@lib@sh@temp}% - \ifpgfutil@in@% - \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@long% - \else% - \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@short% - \fi% - \pgf@lib@sh@next% -} -\def\pgf@lib@sh@itext{i} -\def\pgf@lib@sh@invertedtext{inverted} -% -% The `short' version for input specifcation is an extension of -% ideas due to Juergen Werber and Christoph Bartoschek. -% -\def\pgf@lib@sh@logicgate@parseinputs@short{% - \expandafter\pgf@lib@sh@logicgate@parseinputs@@short\pgf@lib@sh@temp\pgf@stop% -} -\def\pgf@lib@sh@logicgate@parseinputs@@short#1{% - \ifx#1\pgf@stop% - \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% - \let\pgf@lib@sh@next\relax% - \else% - \ifnum\c@pgf@countb=\c@pgf@counta% - \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% - \let\pgf@lib@sh@next\relax% - \else% - \advance\c@pgf@countb1\relax% - \expandafter\ifx\pgf@lib@sh@itext#1% - \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% - \expandafter\def\csname input-\the\c@pgf@countb\endcsname{i}}% - \else% - \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% - \expandafter\def\csname input-\the\c@pgf@countb\endcsname{n}}% - \fi% - \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@@short% - \fi% - \fi% - \pgf@lib@sh@next% -} -\def\pgf@lib@sh@logicgate@parseinputs@long{% - \expandafter\pgf@lib@sh@logicgate@parseinputs@@long\pgf@lib@sh@temp,\pgf@stop,% -} -\def\pgf@lib@sh@logicgate@parseinputs@@long#1,{% - \ifx#1\pgf@stop% - \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% - \let\pgf@lib@sh@next\relax% - \else% - \ifnum\c@pgf@countb=\c@pgf@counta% - \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% - \let\pgf@lib@sh@next\relax% - \else% - \advance\c@pgf@countb1\relax% - \def\pgf@lib@sh@temp{#1}% - \ifx\pgf@lib@sh@invertedtext\pgf@lib@sh@temp% - \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% - \expandafter\def\csname input-\the\c@pgf@countb\endcsname{i}}% - \else% - \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% - \expandafter\def\csname input-\the\c@pgf@countb\endcsname{n}}% - \fi% - \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@@@long% - \fi% - \fi% - \pgf@lib@sh@next% -} -\def\pgf@lib@sh@logicgate@parseinputs@@@long{% - \pgfutil@ifnextchar x{\pgf@lib@sh@logicgate@parseinputs@@long}% - {\pgf@lib@sh@logicgate@parseinputs@@long}% -} -\fi% - \def\pgf@lib@sh@logicgates@IEC@foregroundpath#1{% \dimensions% {% diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.gates.logic.US.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.logic.US.code.tex index 76d6916bcd5..ae857c6fd42 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.gates.logic.US.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.logic.US.code.tex @@ -7,17 +7,16 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. +\usepgflibrary{shapes.gates.logic} + \newif\ifpgfgateanchorsuseboundingrectangle% % Keys for US/CDH logic gates. % -\pgfkeys{/pgf/.cd,% - logic gate input sep/.initial=0.125cm, - logic gate inputs/.initial={normal,normal},% - logic gate inverted radius/.initial=2pt,% - logic gate anchors use bounding box/.is if=pgfgateanchorsuseboundingrectangle,% +\pgfkeys{ + /pgf/logic gate anchors use bounding box/.is if=pgfgateanchorsuseboundingrectangle,% } % An internal macro for calculating internal dimensions of @@ -175,84 +174,6 @@ }% -% Internal macro for parsing inputs. -% -\expandafter\ifx\csname pgf@lib@sh@logicgate@parseinputs\endcsname\relax% -\def\pgf@lib@sh@logicgate@parseinputs#1{% - \edef\pgf@lib@sh@temp{\pgfkeysvalueof{/pgf/logic gate inputs}}% - \c@pgf@counta#1\relax% - \c@pgf@countb0\relax% - \expandafter\pgfutil@in@\expandafter,\expandafter{\pgf@lib@sh@temp}% - \ifpgfutil@in@% - \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@long% - \else% - \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@short% - \fi% - \pgf@lib@sh@next% -} -\def\pgf@lib@sh@itext{i} -\def\pgf@lib@sh@invertedtext{inverted} -% -% The `short' version for input specifcation is an extension of -% ideas due to Juergen Werber and Christoph Bartoschek. -% -\def\pgf@lib@sh@logicgate@parseinputs@short{% - \expandafter\pgf@lib@sh@logicgate@parseinputs@@short\pgf@lib@sh@temp\pgf@stop% -} -\def\pgf@lib@sh@logicgate@parseinputs@@short#1{% - \ifx#1\pgf@stop% - \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% - \let\pgf@lib@sh@next\relax% - \else% - \ifnum\c@pgf@countb=\c@pgf@counta% - \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% - \let\pgf@lib@sh@next\relax% - \else% - \advance\c@pgf@countb1\relax% - \expandafter\ifx\pgf@lib@sh@itext#1% - \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% - \expandafter\def\csname input-\the\c@pgf@countb\endcsname{i}}% - \else% - \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% - \expandafter\def\csname input-\the\c@pgf@countb\endcsname{n}}% - \fi% - \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@@short% - \fi% - \fi% - \pgf@lib@sh@next% -} -\def\pgf@lib@sh@logicgate@parseinputs@long{% - \expandafter\pgf@lib@sh@logicgate@parseinputs@@long\pgf@lib@sh@temp,\pgf@stop,% -} -\def\pgf@lib@sh@logicgate@parseinputs@@long#1,{% - \ifx#1\pgf@stop% - \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% - \let\pgf@lib@sh@next\relax% - \else% - \ifnum\c@pgf@countb=\c@pgf@counta% - \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% - \let\pgf@lib@sh@next\relax% - \else% - \advance\c@pgf@countb1\relax% - \def\pgf@lib@sh@temp{#1}% - \ifx\pgf@lib@sh@invertedtext\pgf@lib@sh@temp% - \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% - \expandafter\def\csname input-\the\c@pgf@countb\endcsname{i}}% - \else% - \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% - \expandafter\def\csname input-\the\c@pgf@countb\endcsname{n}}% - \fi% - \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@@@long% - \fi% - \fi% - \pgf@lib@sh@next% -} -\def\pgf@lib@sh@logicgate@parseinputs@@@long{% - \pgfutil@ifnextchar x{\pgf@lib@sh@logicgate@parseinputs@@long}% - {\pgf@lib@sh@logicgate@parseinputs@@long}% -} -\fi% - % Internal macro for calculation input anchors. Used by % both and gates and nand gates, and also the not gate and buffer. % @@ -1733,287 +1654,302 @@ % Shape not gate US % \pgfdeclareshape{not gate US}{% - \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@not gate US\endcsname{% - \pgf@lib@sh@logicgate@parseinputs{1}% - \ifnum\pgf@lib@sh@logicgate@numinputs=0\relax% - \PackageError{PGF}{A not gate must have one input}{}% - \fi% - }% - \savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% - \saveddimen\invertedradius{% - \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% - }% - \saveddimen\halflinewidth{% - \pgf@x.5\pgflinewidth% - }% - \saveddimen\outerinvertedradius{% - \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% - \advance\pgf@x.5\pgflinewidth% - } - \savedmacro\dimensions{\pgf@lib@sh@logicgates@dimensions@orUS} - \savedanchor\centerpoint{% - \pgf@x.5\wd\pgfnodeparttextbox% - \pgf@y.5\ht\pgfnodeparttextbox% - \advance\pgf@y-.5\dp\pgfnodeparttextbox% - } - \savedanchor\midpoint{% - \pgf@x.5\wd\pgfnodeparttextbox% - \pgfmathsetlength\pgf@y{+0.5ex}% - } - \savedanchor\basepoint{% - \pgf@x.5\wd\pgfnodeparttextbox% - \pgf@y0pt% - } - \anchor{center}{\centerpoint}% - \anchor{mid}{\midpoint}% - \anchor{mid east}{% - \midpoint% - \pgfutil@tempdima\pgf@y% - \csname pgf@anchor@not gate US@east\endcsname% - \pgf@y\pgfutil@tempdima% - } - \anchor{mid west}{% - \dimensions% - \pgf@xc\halfside% - \pgf@xc-.833333\pgf@xc% - \advance\pgf@xc-\outerxsep% - \midpoint% - \advance\pgf@x\pgf@xc% - }% - \anchor{base}{\basepoint}% - \anchor{base east}{% - \basepoint% - \pgfutil@tempdima\pgf@y% - \csname pgf@anchor@not gate US@east\endcsname% - \pgf@y\pgfutil@tempdima% - } - \anchor{base west}{% - \dimensions% - \pgf@xc\halfside% - \pgf@xc-.833333\pgf@xc% - \advance\pgf@xc-\outerxsep% - \basepoint% - \advance\pgf@x\pgf@xc% - }% - \inheritanchor[from=and gate US]{base} - \anchor{output}{% - \dimensions% - \pgf@xc\halfside% - \centerpoint% - \advance\pgf@x-.166666\pgf@xc% - \pgf@xc2.0\pgf@xc% - \advance\pgf@x.866025\pgf@xc% - \advance\pgf@x\invertedradius% - \advance\pgf@x\outerinvertedradius% - \advance\pgf@x\outerxsep% - } - \anchor{east}{% - \dimensions% - \tipanchor% - \pgf@xa\pgf@x% - \centerpoint% - \advance\pgf@x\pgf@xa% - }% - \anchor{north}{% - \dimensions% - \ifpgfgateanchorsuseboundingrectangle% - \csname pgf@anchor@not gate US@north west\endcsname% - \pgf@ya\pgf@y% - \centerpoint% - \pgf@y\pgf@ya% - \else% - \pgfpointintersectionoflines{\centerpoint}{\centerpoint\advance\pgf@y1pt}% - {\csname pgf@anchor@not gate US@north west\endcsname}% - {% - \pgfpointadd{\centerpoint}{% - \tipanchor% - \pgf@xa\outerxsep% - \advance\pgf@x2.350943\pgf@xa% - }% - }% - \fi% - } - \anchor{south}{% - \dimensions% - \ifpgfgateanchorsuseboundingrectangle% - \csname pgf@anchor@not gate US@south west\endcsname% - \pgf@ya\pgf@y% - \centerpoint% - \pgf@y\pgf@ya% - \else% - \pgfpointintersectionoflines{\centerpoint}{\centerpoint\advance\pgf@y-1pt}% - {\csname pgf@anchor@not gate US@south west\endcsname}% - {% - \pgfpointadd{\centerpoint}{% - \tipanchor% - \pgf@xa\outerxsep% - \advance\pgf@x2.350943\pgf@xa% - }% - }% - \fi% - } - \anchor{south east}{% - \dimensions% - \ifpgfgateanchorsuseboundingrectangle% - \csname pgf@anchor@not gate US@south west\endcsname% - \pgf@ya\pgf@y% - \pgf@process{% - \dimensions% - \tipanchor% - \pgf@xa\pgf@x% - \centerpoint% - \advance\pgf@x\pgf@xa% - }% - \pgf@y\pgf@ya% - \else% - \pgfpointintersectionoflines{\centerpoint}{\centerpoint\advance\pgf@x1pt\advance\pgf@y-1pt}% - {\csname pgf@anchor@not gate US@south west\endcsname}% - {% - \pgfpointadd{\centerpoint}{% - \tipanchor% - \pgf@xa\outerxsep% - \advance\pgf@x2.350943\pgf@xa% - }% - }% - \fi% - } - \anchor{north east}{% - \dimensions% - \ifpgfgateanchorsuseboundingrectangle% - \csname pgf@anchor@not gate US@north west\endcsname% - \pgf@ya\pgf@y% - \pgf@process{% - \dimensions% - \tipanchor% - \pgf@xa\pgf@x% - \centerpoint% - \advance\pgf@x\pgf@xa% - }% - \pgf@y\pgf@ya% - \else% - \pgfpointintersectionoflines{\centerpoint}{\centerpoint\advance\pgf@x1pt\advance\pgf@y1pt}% - {\csname pgf@anchor@not gate US@north west\endcsname}% - {% - \pgfpointadd{\centerpoint}{% - \tipanchor% - \pgf@xa\outerxsep% - \advance\pgf@x2.350943\pgf@xa% - }% - }% - \fi% - } - \anchor{south west}{% - \dimensions% - \pgf@xa\halfside% - \centerpoint% - \advance\pgf@x-.833333\pgf@xa - \advance\pgf@x-\outerxsep% - \advance\pgf@y-1.166666\pgf@xa% - \pgf@ya\outerysep% - \advance\pgf@y-1.565\pgf@ya% Selected by trial and error. - }% - \anchor{north west}{% - \dimensions% - \pgf@xa\halfside% - \centerpoint% - \advance\pgf@x-.833333\pgf@xa - \advance\pgf@x-\outerxsep% - \advance\pgf@y1.166666\pgf@xa% - \pgf@ya\outerysep% - \advance\pgf@y1.565\pgf@ya% Selected by trial and error. - }% - \anchor{input}{% - \dimensions% - \pgf@lib@sh@logicgate@AND@inputanchor{1}% - \pgf@xc\halfside% - \advance\pgf@x.333333\pgf@xc% - }% - \anchor{west}{% - \dimensions% - \pgf@xc\halfside% - \pgf@xc-.833333\pgf@xc% - \advance\pgf@xc-\outerxsep% - \centerpoint% - \advance\pgf@x\pgf@xc% - } - \backgroundpath{% - \dimensions% - \pgf@xc\halfwidth% - \pgf@yc\halfheight% - \advance\pgf@xc-\outerxsep% - \advance\pgf@yc-\outerysep% - {% - \pgftransformshift{\centerpoint}% - \pgfpathmoveto{\tipanchor}% - \pgfpathlineto{\pgfqpoint{-.833333\pgf@xc}{1.166666\pgf@yc}}% - \pgfpathlineto{\pgfqpoint{-.833333\pgf@xc}{-1.166666\pgf@yc}}% - \pgfpathlineto{\tipanchor}% - % - % Draw the output inverter. - % - {% - \pgfpathcircle{% - \pgf@x-.166666\pgf@xc% - \pgf@yc2.0\pgf@yc% - \advance\pgf@x.866025\pgf@yc% - \advance\pgf@x\outerinvertedradius% - \pgf@y0pt% - }{+\invertedradius}% - }% - % - % Draw the input. - % - \expandafter\ifx\expandafter\pgf@lib@sh@itext\csname input-1\endcsname% - {% - \pgfpathcircle{% - \pgf@xa\halfside% - \pgf@x-.833333\pgf@xa% - \advance\pgf@x-.5\pgflinewidth% - \advance\pgf@x-\invertedradius% - \pgf@y0pt% - }{+\invertedradius}% - }% - \fi% - }% - }% - \anchorborder{% - \pgfextract@process\externalpoint{}% - \pgfextract@process\externalpoint{\pgfpointadd{\centerpoint}{\externalpoint}}% - \pgfmathanglebetweenpoints{\centerpoint}{\externalpoint}% - \let\externalangle\pgfmathresult% - \dimensions% - \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@not gate US@north west\endcsname}% - \ifdim\externalangle pt<\pgfmathresult pt% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% - {\csname pgf@anchor@not gate US@north west\endcsname}% - {% - \pgfpointadd{\centerpoint}{% - \tipanchor% - \pgf@xa\outerxsep% - \advance\pgf@x2.350943\pgf@xa% - }% - }% - \else% - \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@not gate US@south west\endcsname}% - \ifdim\externalangle pt<\pgfmathresult pt% - \pgfpointintersectionoflines{\externalpoint}{\centerpoint}% - {\csname pgf@anchor@not gate US@north west\endcsname}% - {\csname pgf@anchor@not gate US@south west\endcsname}% - \else% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% - {\csname pgf@anchor@not gate US@south west\endcsname}% - {% - \pgfpointadd{\centerpoint}{% - \tipanchor% - \pgf@xa\outerxsep% - \advance\pgf@x2.350943\pgf@xa% - }% - }% - \fi% - \fi% - }% + \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@not gate US\endcsname{% + \pgf@lib@sh@logicgate@parseinputs{1}% + \ifnum\pgf@lib@sh@logicgate@numinputs=0\relax% + \PackageError{PGF}{A not gate must have one input}{}% + \fi% + }% + \savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% + \saveddimen\invertedradius{% + \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% + }% + \saveddimen\halflinewidth{% + \pgf@x.5\pgflinewidth% + }% + \saveddimen\outerinvertedradius{% + \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% + \advance\pgf@x.5\pgflinewidth% + } + \savedmacro\dimensions{\pgf@lib@sh@logicgates@dimensions@orUS} + \savedanchor\centerpoint{% + \pgf@x.5\wd\pgfnodeparttextbox% + \pgf@y.5\ht\pgfnodeparttextbox% + \advance\pgf@y-.5\dp\pgfnodeparttextbox% + } + \savedanchor\midpoint{% + \pgf@x.5\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@y{+0.5ex}% + } + \savedanchor\basepoint{% + \pgf@x.5\wd\pgfnodeparttextbox% + \pgf@y0pt% + } + \anchor{center}{\centerpoint}% + \anchor{mid}{\midpoint}% + \anchor{mid east}{% + \midpoint% + \pgfutil@tempdima\pgf@y% + \csname pgf@anchor@not gate US@east\endcsname% + \pgf@y\pgfutil@tempdima% + } + \anchor{mid west}{% + \dimensions% + \pgf@xc\halfside% + \pgf@xc-.833333\pgf@xc% + \advance\pgf@xc-\outerxsep% + \midpoint% + \advance\pgf@x\pgf@xc% + }% + \anchor{base}{\basepoint}% + \anchor{base east}{% + \basepoint% + \pgfutil@tempdima\pgf@y% + \csname pgf@anchor@not gate US@east\endcsname% + \pgf@y\pgfutil@tempdima% + } + \anchor{base west}{% + \dimensions% + \pgf@xc\halfside% + \pgf@xc-.833333\pgf@xc% + \advance\pgf@xc-\outerxsep% + \basepoint% + \advance\pgf@x\pgf@xc% + }% + \inheritanchor[from=and gate US]{base} + \anchor{output}{% + \dimensions% + \pgf@xc\halfside% + \centerpoint% + \advance\pgf@x-.166666\pgf@xc% + \pgf@xc2.0\pgf@xc% + \advance\pgf@x.866025\pgf@xc% + \advance\pgf@x\invertedradius% + \advance\pgf@x\outerinvertedradius% + \advance\pgf@x\outerxsep% + } + \anchor{east}{% + \dimensions% + \tipanchor% + \pgf@xa\pgf@x% + \centerpoint% + \advance\pgf@x\pgf@xa% + }% + \anchor{north}{% + \dimensions% + \ifpgfgateanchorsuseboundingrectangle% + \csname pgf@anchor@not gate US@north west\endcsname% + \pgf@ya\pgf@y% + \centerpoint% + \pgf@y\pgf@ya% + \else% + \pgfpointintersectionoflines{\centerpoint}{\centerpoint\advance\pgf@y1pt}% + {\csname pgf@anchor@not gate US@north west\endcsname}% + {% + \pgfpointadd{\centerpoint}{% + \tipanchor% + \pgf@xa\outerxsep% + \advance\pgf@x2.350943\pgf@xa% + }% + }% + \fi% + } + \anchor{south}{% + \dimensions% + \ifpgfgateanchorsuseboundingrectangle% + \csname pgf@anchor@not gate US@south west\endcsname% + \pgf@ya\pgf@y% + \centerpoint% + \pgf@y\pgf@ya% + \else% + \pgfpointintersectionoflines{\centerpoint}{\centerpoint\advance\pgf@y-1pt}% + {\csname pgf@anchor@not gate US@south west\endcsname}% + {% + \pgfpointadd{\centerpoint}{% + \tipanchor% + \pgf@xa\outerxsep% + \advance\pgf@x2.350943\pgf@xa% + }% + }% + \fi% + } + \anchor{south east}{% + \dimensions% + \ifpgfgateanchorsuseboundingrectangle% + \csname pgf@anchor@not gate US@south west\endcsname% + \pgf@ya\pgf@y% + \pgf@process{% + \dimensions% + \tipanchor% + \pgf@xa\pgf@x% + \centerpoint% + \advance\pgf@x\pgf@xa% + }% + \pgf@y\pgf@ya% + \else% + \pgfpointintersectionoflines{\centerpoint}{\centerpoint\advance\pgf@x1pt\advance\pgf@y-1pt}% + {\csname pgf@anchor@not gate US@south west\endcsname}% + {% + \pgfpointadd{\centerpoint}{% + \tipanchor% + \pgf@xa\outerxsep% + \advance\pgf@x2.350943\pgf@xa% + }% + }% + \fi% + } + \anchor{north east}{% + \dimensions% + \ifpgfgateanchorsuseboundingrectangle% + \csname pgf@anchor@not gate US@north west\endcsname% + \pgf@ya\pgf@y% + \pgf@process{% + \dimensions% + \tipanchor% + \pgf@xa\pgf@x% + \centerpoint% + \advance\pgf@x\pgf@xa% + }% + \pgf@y\pgf@ya% + \else% + \pgfpointintersectionoflines{\centerpoint}{\centerpoint\advance\pgf@x1pt\advance\pgf@y1pt}% + {\csname pgf@anchor@not gate US@north west\endcsname}% + {% + \pgfpointadd{\centerpoint}{% + \tipanchor% + \pgf@xa\outerxsep% + \advance\pgf@x2.350943\pgf@xa% + }% + }% + \fi% + } + \anchor{south west}{% + \dimensions% + \pgf@xa\halfside% + \centerpoint% + \advance\pgf@x-.833333\pgf@xa + \advance\pgf@x-\outerxsep% + \advance\pgf@y-1.166666\pgf@xa% + \pgf@ya\outerysep% + \advance\pgf@y-1.565\pgf@ya% Selected by trial and error. + }% + \anchor{north west}{% + \dimensions% + \pgf@xa\halfside% + \centerpoint% + \advance\pgf@x-.833333\pgf@xa + \advance\pgf@x-\outerxsep% + \advance\pgf@y1.166666\pgf@xa% + \pgf@ya\outerysep% + \advance\pgf@y1.565\pgf@ya% Selected by trial and error. + }% + \anchor{input}{% + \dimensions% + \pgf@lib@sh@logicgate@AND@inputanchor{1}% + \pgf@xc\halfside% + \advance\pgf@x.333333\pgf@xc% + }% + \anchor{west}{% + \dimensions% + \pgf@xc\halfside% + \pgf@xc-.833333\pgf@xc% + \advance\pgf@xc-\outerxsep% + \centerpoint% + \advance\pgf@x\pgf@xc% + } + \backgroundpath{% + \dimensions% + \pgf@xc\halfwidth% + \pgf@yc\halfheight% + \advance\pgf@xc-\outerxsep% + \advance\pgf@yc-\outerysep% + {% + \pgftransformshift{\centerpoint}% + \pgfpathmoveto{\tipanchor}% + \pgfpathlineto{\pgfqpoint{-.833333\pgf@xc}{1.166666\pgf@yc}}% + \pgfpathlineto{\pgfqpoint{-.833333\pgf@xc}{-1.166666\pgf@yc}}% + \pgfpathlineto{\tipanchor}% + % + % Draw the output inverter. + % + {% + \pgfpathcircle{% + \pgf@x-.166666\pgf@xc% + \pgf@yc2.0\pgf@yc% + \advance\pgf@x.866025\pgf@yc% + \advance\pgf@x\outerinvertedradius% + \pgf@y0pt% + }{+\invertedradius}% + }% + % + % Draw the input. + % + \expandafter\ifx\expandafter\pgf@lib@sh@itext\csname input-1\endcsname% + {% + \pgfpathcircle{% + \pgf@xa\halfside% + \pgf@x-.833333\pgf@xa% + \advance\pgf@x-.5\pgflinewidth% + \advance\pgf@x-\invertedradius% + \pgf@y0pt% + }{+\invertedradius}% + }% + \fi% + }% + }% + \anchorborder{% + \pgf@lib@gates@not@buffer@border{not gate US} + } } +\def\pgf@lib@gates@not@buffer@border#1{ + \pgfextract@process\externalpoint{}% + \pgfextract@process\externalpoint{\pgfpointadd{\centerpoint}{\externalpoint}}% + \pgfmathanglebetweenpoints{\centerpoint}{\externalpoint}% + \ifx\pgfmathresult\pgf@lib@zero@text% + \csname pgf@anchor@#1@output\endcsname% + \else% + \ifx\pgfmathresult\pgf@lib@onehundredeighty@text% + \csname pgf@anchor@#1@input\endcsname% + \else% + \let\externalangle\pgfmathresult% + \dimensions% + \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@not gate US@north west\endcsname}% + \ifdim\externalangle pt<\pgfmathresult pt% + \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% + {\csname pgf@anchor@not gate US@north west\endcsname}% + {% + \pgfpointadd{\centerpoint}{% + \tipanchor% + \pgf@xa\outerxsep% + \advance\pgf@x2.350943\pgf@xa% + }% + }% + \else% + \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@not gate US@south west\endcsname}% + \ifdim\externalangle pt<\pgfmathresult pt% + \pgfpointintersectionoflines{\externalpoint}{\centerpoint}% + {\csname pgf@anchor@not gate US@north west\endcsname}% + {\csname pgf@anchor@not gate US@south west\endcsname}% + \else% + \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% + {\csname pgf@anchor@not gate US@south west\endcsname}% + {% + \pgfpointadd{\centerpoint}{% + \tipanchor% + \pgf@xa\outerxsep% + \advance\pgf@x2.350943\pgf@xa% + }% + }% + \fi% + \fi% + \fi% + \fi% +}% + + +\def\pgf@lib@zero@text{0.0} +\def\pgf@lib@onehundredeighty@text{180.0} @@ -2194,7 +2130,9 @@ \fi% }% }% - \inheritanchorborder[from=not gate US] + \anchorborder{% + \pgf@lib@gates@not@buffer@border{buffer gate US} + } } diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.logic.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.logic.code.tex new file mode 100644 index 00000000000..8b047f04ab1 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/circuits/pgflibraryshapes.gates.logic.code.tex @@ -0,0 +1,98 @@ +% Copyright 2008 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + + +% Common keys for all logic gates. +% +\pgfkeys{/pgf/.cd,% + logic gate input sep/.initial=0.125cm, + logic gate inputs/.initial={normal,normal},% + logic gate inverted radius/.initial=2pt +} + + +% Internal macro for parsing inputs. +% +\expandafter\ifx\csname pgf@lib@sh@logicgate@parseinputs\endcsname\relax% +\def\pgf@lib@sh@logicgate@parseinputs#1{% + \edef\pgf@lib@sh@temp{\pgfkeysvalueof{/pgf/logic gate inputs}}% + \c@pgf@counta#1\relax% + \c@pgf@countb0\relax% + \expandafter\pgfutil@in@\expandafter,\expandafter{\pgf@lib@sh@temp}% + \ifpgfutil@in@% + \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@long% + \else% + \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@short% + \fi% + \pgf@lib@sh@next% +} +\def\pgf@lib@sh@itext{i} +\def\pgf@lib@sh@invertedtext{inverted} +% +% The `short' version for input specifcation is an extension of +% ideas due to Juergen Werber and Christoph Bartoschek. +% +\def\pgf@lib@sh@logicgate@parseinputs@short{% + \expandafter\pgf@lib@sh@logicgate@parseinputs@@short\pgf@lib@sh@temp\pgf@stop% +} +\def\pgf@lib@sh@logicgate@parseinputs@@short#1{% + \ifx#1\pgf@stop% + \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% + \let\pgf@lib@sh@next\relax% + \else% + \ifnum\c@pgf@countb=\c@pgf@counta% + \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% + \let\pgf@lib@sh@next\relax% + \else% + \advance\c@pgf@countb1\relax% + \expandafter\ifx\pgf@lib@sh@itext#1% + \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% + \expandafter\def\csname input-\the\c@pgf@countb\endcsname{i}}% + \else% + \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% + \expandafter\def\csname input-\the\c@pgf@countb\endcsname{n}}% + \fi% + \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@@short% + \fi% + \fi% + \pgf@lib@sh@next% +} +\def\pgf@lib@sh@logicgate@parseinputs@long{% + \expandafter\pgf@lib@sh@logicgate@parseinputs@@long\pgf@lib@sh@temp,\pgf@stop,% +} +\def\pgf@lib@sh@logicgate@parseinputs@@long#1,{% + \ifx#1\pgf@stop% + \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% + \let\pgf@lib@sh@next\relax% + \else% + \ifnum\c@pgf@countb=\c@pgf@counta% + \edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% + \let\pgf@lib@sh@next\relax% + \else% + \advance\c@pgf@countb1\relax% + \def\pgf@lib@sh@temp{#1}% + \ifx\pgf@lib@sh@invertedtext\pgf@lib@sh@temp% + \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% + \expandafter\def\csname input-\the\c@pgf@countb\endcsname{i}}% + \else% + \expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% + \expandafter\def\csname input-\the\c@pgf@countb\endcsname{n}}% + \fi% + \let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@@@long% + \fi% + \fi% + \pgf@lib@sh@next% +} +\def\pgf@lib@sh@logicgate@parseinputs@@@long{% + \pgfutil@ifnextchar x{\pgf@lib@sh@logicgate@parseinputs@@long}% + {\pgf@lib@sh@logicgate@parseinputs@@long}% +} +\fi% + + diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.arrows.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.arrows.code.tex index a188ad2871e..39f90d6f2e6 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.arrows.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.arrows.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.arrows.code.tex,v 1.3 2007/11/10 09:16:33 vibrovski Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/shapes/pgflibraryshapes.arrows.code.tex,v 1.1 2008/06/26 16:55:55 tantau Exp $ % keys for shape single arrow diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.callouts.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.callouts.code.tex index 5a39a629e07..440681b7b87 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.callouts.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.callouts.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. - +\usepgflibrary{shapes.symbols} % Keys for callouts % diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.code.tex index 02d4956235c..fc0b1d20aa5 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.code.tex,v 1.14 2007/12/17 16:20:50 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/shapes/pgflibraryshapes.code.tex,v 1.1 2008/06/26 16:55:55 tantau Exp $ % Only the following are loaded by default and only for historical % reasons. diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.geometric.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.geometric.code.tex index 2f11e6a4fd2..ae7ec0f3c4e 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.geometric.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.geometric.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.geometric.code.tex,v 1.22 2008/02/01 17:09:04 vibrovski Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/shapes/pgflibraryshapes.geometric.code.tex,v 1.1 2008/06/26 16:55:55 tantau Exp $ \pgfdeclareshape{ellipse} % @@ -368,7 +368,7 @@ \def\pgf@lib@temp{#1}% \pgfkeyslet{/pgf/star point ratio}{\pgf@lib@temp}% \pgf@lib@shapes@starouterradiususesratiotrue% - }% + },% star rotate/.style={/pgf/shape border rotate=#1}% For compatability with 1.18 } @@ -3672,7 +3672,7 @@ \advance\pgf@xa\pgf@x% \pgf@xb\pgf@xa% \advance\pgf@xa\pgf@x% - \pgfmathveclen@{\the\pgf@xa}{\the\pgf@y}% + \pgfmathveclen@{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@y}}% \pgf@xa\pgfmathresult pt\relax% \fi% % diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.misc.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.misc.code.tex index 62e488dc79a..a57b0cd4511 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.misc.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.misc.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.misc.code.tex,v 1.10 2008/02/12 18:02:25 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/shapes/pgflibraryshapes.misc.code.tex,v 1.3 2008/10/07 18:23:25 vibrovski Exp $ \pgfdeclareshape{cross out} @@ -66,622 +66,412 @@ } } + +% Rounded rectangle + + \pgfkeys{/pgf/.cd, rounded rectangle west arc/.initial=convex, rounded rectangle east arc/.initial=convex, rounded rectangle left arc/.style={/pgf/rounded rectangle west arc=#1},% - rounded rectangle right arc/.code={/pgf/rounded rectangle east arc=#1},% + rounded rectangle right arc/.style={/pgf/rounded rectangle east arc=#1},% rounded rectangle arc length/.initial=180% }% -\def\pgf@lib@shapes@roundedrectangle@concave{concave}% -\def\pgf@lib@shapes@roundedrectangle@convex{convex}% +\def\pgf@lib@sh@misc@rr@text@concave{concave}% +\def\pgf@lib@sh@misc@rr@text@convex{convex}% -\pgfdeclareshape{rounded rectangle}{ - \savedmacro\leftarc{% - \edef\leftarc{\pgfkeysvalueof{/pgf/rounded rectangle west arc}}% +\pgfdeclareshape{rounded rectangle}{% + \savedmacro\westarc{% + \edef\westarc{\pgfkeysvalueof{/pgf/rounded rectangle west arc}}% } - \savedmacro\rightarc{% - \edef\rightarc{\pgfkeysvalueof{/pgf/rounded rectangle east arc}}% + \savedmacro\eastarc{% + \edef\eastarc{\pgfkeysvalueof{/pgf/rounded rectangle east arc}}% } \savedmacro\roundedrectanglepoints{% % - % Get half the arc angle. + % Get half the arc angle, a. % \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/rounded rectangle arc length}}% - \pgf@x.5\pgf@x% + \pgf@x=.5\pgf@x% \edef\halfarcangle{\pgfmath@tonumber{\pgf@x}}% - \addtosavedmacro\halfarcangle% + \addtosavedmacro\halfarcangle% % % Get the (half) node dimensions x & y. % \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}% - \advance\pgf@x.5\wd\pgfnodeparttextbox% + \edef\innerxsep{\the\pgf@x}% + \pgf@xa=0.5\wd\pgfnodeparttextbox% + \edef\halftextwidth{\the\pgf@xa}% + \addtosavedmacro\halftextwidth% + \advance\pgf@x by\pgf@xa% + % \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% - \advance\pgf@y.5\ht\pgfnodeparttextbox% - \advance\pgf@y.5\dp\pgfnodeparttextbox% - % - % Adjust for minimum height - % + \edef\innerysep{\the\pgf@y}% + \pgf@ya=.5\ht\pgfnodeparttextbox% + \advance\pgf@ya by.5\dp\pgfnodeparttextbox% + \edef\halftextheight{\the\pgf@ya}% + \addtosavedmacro\halftextheight% + \advance\pgf@y by\pgf@ya% + % + % Adjust for minimum height % \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% \ifdim\pgf@y<.5\pgf@yb% - \pgf@y.5\pgf@yb% + \pgf@y=.5\pgf@yb% \fi% + \edef\halfheight{\the\pgf@y}% + \addtosavedmacro\halfheight% + % + % Calculate the radius of the arc ends. % - % Calculate the radii xa & ya of the arc ends. + \pgfmathcosec@{\halfarcangle}% + \pgf@ya=\pgfmathresult\pgf@y% + \edef\radius{\the\pgf@ya}% + \addtosavedmacro\radius% % - \pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/rounded rectangle arc length}}% - \pgfutil@tempdima.5\pgfutil@tempdima% - \pgfmathcosec@{\pgfmath@tonumber{\pgfutil@tempdima}}% - \pgf@ya\pgfmathresult\pgf@y% - \pgf@xa\pgf@ya% + % Arc width = r - r*cos(a/2). % - % Calculate the width of the arc end. + \pgfmathcos@{\halfarcangle}% + \pgf@xa=\pgf@ya% + \advance\pgf@xa by-\pgfmathresult\pgf@ya% % - \pgfmathcos@{\pgfmath@tonumber{\pgfutil@tempdima}}% - \pgf@xb-\pgfmathresult\pgf@xa% - \advance\pgf@xb\pgf@xa\relax% - \edef\arcwidth{\the\pgf@xb}% - \addtosavedmacro{\arcwidth}% + % When the node contents are pushed inside a convex arc, + % the resulting chord has a height r - r*cos(asin(0.5*h/r)). % - % Adjust for minimum width + \pgfmathdivide{\halftextheight}{\radius}% + \pgfmathasin@{\pgfmathresult}% + \pgfmathcos@{\pgfmathresult}% + \pgf@xb=\pgf@ya% + \advance\pgf@xb by-\pgfmathresult\pgf@ya% % - \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% - \advance\pgf@x\arcwidth\relax% - \ifdim\pgf@x<.5\pgf@xb% - \pgf@x.5\pgf@xb% + % Adjust for minimum width. + % + \edef\westarc{\pgfkeysvalueof{/pgf/rounded rectangle west arc}}% + \edef\eastarc{\pgfkeysvalueof{/pgf/rounded rectangle east arc}}% + % + \pgfutil@tempdima=2.0\pgf@x% x still holds the half width. + \ifx\westarc\pgf@lib@sh@misc@rr@text@concave% + \advance\pgfutil@tempdima by\pgf@xa% + \else% + \ifx\westarc\pgf@lib@sh@misc@rr@text@convex% + \advance\pgfutil@tempdima by\pgf@xb% + \fi% \fi% - \advance\pgf@x-\arcwidth\relax% % - % Get the outer sep. + \ifx\eastarc\pgf@lib@sh@misc@rr@text@concave% + \advance\pgfutil@tempdima by\pgf@xa% + \else% + \ifx\eastarc\pgf@lib@sh@misc@rr@text@convex% + \advance\pgfutil@tempdima by\pgf@xb% + \fi% + \fi% % - \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/outer xsep}}% - \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/outer ysep}}% - \edef\outerxsep{\the\pgf@xb}% - \edef\outerysep{\the\pgf@yb}% - \addtosavedmacro\outerxsep% - \addtosavedmacro\outerysep% + \pgfmathsetlength\pgfutil@tempdimb{\pgfkeysvalueof{/pgf/minimum width}}% + \ifdim\pgfutil@tempdima<\pgfutil@tempdimb% + \advance\pgfutil@tempdimb by-\pgfutil@tempdima% + \divide\pgfutil@tempdimb by2\relax% + \edef\xoffset{\the\pgfutil@tempdimb}% + \else% + \let\xoffset=\innerxsep% + \fi% % - \edef\xpathradius{\the\pgf@xa}% - \edef\ypathradius{\the\pgf@ya}% - \addtosavedmacro\xpathradius% - \addtosavedmacro\ypathradius% + % The node is made wider if convex arcs overlap. % - \advance\pgf@xa\pgf@xb% - \advance\pgf@ya\pgf@yb% - \edef\xradius{\the\pgf@xa}% - \edef\yradius{\the\pgf@ya}% - \addtosavedmacro\xradius% - \addtosavedmacro\yradius% + \pgf@x=\halftextwidth\relax% + \advance\pgf@x by\xoffset\relax% + \pgf@xc=\pgf@ya% + \advance\pgf@xc by-\pgf@xb% + \ifdim\pgf@xc>\pgf@x\relax% + \advance\pgf@xc by-\pgf@x% + \advance\pgf@xc by\xoffset\relax% + \edef\xoffset{\the\pgf@xc}% + \fi% + \addtosavedmacro\xoffset% % - \advance\pgf@xa-2.0\pgf@xb% - \advance\pgf@ya-2.0\pgf@yb% - \edef\xinnerradius{\the\pgf@xa}% - \edef\yinnerradius{\the\pgf@ya}% - \addtosavedmacro\xinnerradius% - \addtosavedmacro\yinnerradius% + \pgf@x=\halftextwidth\relax% + \advance\pgf@x by\xoffset\relax% + \edef\halfwidth{\the\pgf@x}% + \addtosavedmacro\halfwidth% % - \pgfextract@process\pathcornernoarc{}% - \addtosavedmacro\pathcornernoarc% + \edef\arcwidth{\the\pgf@xa}% + \addtosavedmacro\arcwidth% % - \pgfextract@process\pathcornerconvexarc{% - \pathcornernoarc% - \pgf@xc\arcwidth\relax% - \advance\pgf@x-.707106\pgf@xc - }% - \addtosavedmacro\pathcornerconvexarc% + \edef\chordwidth{\the\pgf@xb}% + \addtosavedmacro\chordwidth% % - \pgfextract@process\pathcornerconcavearc{% - \pathcornernoarc% - \advance\pgf@x\arcwidth\relax% - }% - \addtosavedmacro\pathcornerconcavearc% + \pgfmathsetlengthmacro\outerxsep{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlengthmacro\outerysep{\pgfkeysvalueof{/pgf/outer ysep}}% + \addtosavedmacro\outerxsep% + \addtosavedmacro\outerysep% % - \pgfextract@process\anchorcornernoarc{% - \pathcornernoarc% - \advance\pgf@x\pgf@xb% - \advance\pgf@y\pgf@yb% - }% - \addtosavedmacro\anchorcornernoarc% + % calculate some horizontal adjustments made for the default miter + % drawn when an arc meets the north or south side of the node path. % - \pgfextract@process\anchorcornerconvexarc{% - \pathcornerconvexarc% - \ifdim\halfarcangle pt=90pt\relax% - \else% - \pgfmathsin@{\halfarcangle}% - \pgf@xa\xpathradius\relax% - \pgf@xa\pgfmathresult\pgf@xa% - \pgfmathcos@{\halfarcangle}% - \pgf@ya\ypathradius\relax% - \pgf@ya\pgfmathresult\pgf@ya% - % - \pgfmathdivide@{\pgfmath@tonumber{\pgf@ya}}{\pgfmath@tonumber{\pgf@xa}}% - \pgfmathatan@{\pgfmathresult}% - \let\angle\pgfmathresult% - \pgfmathadd@{90}{\angle}% - \pgfmathcosec@{\pgfmathresult}% - \pgf@xb\pgfmathresult\pgf@xb% - \pgfmathadd@{90}{\halfarcangle}% - \pgfmathdivide@{\pgfmathresult}{2}% - \pgfmathcos@{\pgfmathresult}% - \advance\pgf@x\pgfmathresult\pgf@xb% - \fi% - \advance\pgf@y\pgf@yb% - }% - \addtosavedmacro\anchorcornerconvexarc% + \ifdim\halfarcangle pt=90pt\relax% Avoid division by zero. + \def\concavexshift{0pt}% + \else% + % For a concave arc: outer xsep * cosec((90-a/2)/2)*cos((90-a/2)/2). + \pgfmathsubtract@{90}{\halfarcangle}% + \pgfmathdivide@{\pgfmathresult}{2}% + \let\angletemp=\pgfmathresult% + \pgf@x=\outerxsep\relax% + \pgfmathcosec@{\angletemp}% + \pgf@x=\pgfmathresult\pgf@x% + \pgfmathcos@{\angletemp}% + \pgf@x=\pgfmathresult\pgf@x% + \edef\concavexshift{\the\pgf@x}% + \fi% + \addtosavedmacro\concavexshift% % - \pgfextract@process\anchorcornerconcavearc{% - \pathcornerconcavearc% - \ifdim\halfarcangle pt=90pt\relax% - \else% - \pgfmathsin@{\halfarcangle}% - \pgf@xa\xpathradius\relax% - \pgf@xa\pgfmathresult\pgf@xa% - \pgfmathcos@{\halfarcangle}% - \pgf@ya\ypathradius\relax% - \pgf@ya\pgfmathresult\pgf@ya% - % - \pgfmathdivide@{\pgfmath@tonumber{\pgf@ya}}{\pgfmath@tonumber{\pgf@xa}}% - \pgfmathatan@{\pgfmathresult}% - \pgfmathdivide@{\pgfmathresult}{2}% - \let\angle\pgfmathresult% - \pgfmathcosec@{\pgfmathresult}% - \pgf@xb\pgfmathresult\pgf@xb% - \pgfmathcos@{\angle}% - \advance\pgf@x\pgfmathresult\pgf@xb% - \fi% - \advance\pgf@y\pgf@yb% - }% - \addtosavedmacro\anchorcornerconcavearc% - % + \ifdim\halfarcangle pt=90pt\relax% Avoid division by zero. + \def\convexxshift{0pt}% + \else% + % For a convex arc: outer xsep * cosec((90+a/2)/2)*cos((90+a/2)/2). + \pgfmathadd@{90}{\halfarcangle}% + \pgfmathdivide@{\pgfmathresult}{2}% + \let\angletemp=\pgfmathresult% + \pgf@x=\outerxsep\relax% + \pgfmathcosec@{\angletemp}% + \pgf@x=\pgfmathresult\pgf@x% + \pgfmathcos@{\angletemp}% + \pgf@x=\pgfmathresult\pgf@x% + \edef\convexxshift{\the\pgf@x}% + \fi% + \addtosavedmacro\convexxshift% }% \saveddimen\halflinewidth{\pgf@x.5\pgflinewidth}% \savedanchor\centerpoint{% - \pgf@x.5\wd\pgfnodeparttextbox% - \pgf@y.5\ht\pgfnodeparttextbox% - \advance\pgf@y-.5\dp\pgfnodeparttextbox% + \pgf@x=.5\wd\pgfnodeparttextbox% + \pgf@y=.5\ht\pgfnodeparttextbox% + \advance\pgf@y by-.5\dp\pgfnodeparttextbox% } \savedanchor\midpoint{% - \pgf@x.5\wd\pgfnodeparttextbox% + \pgf@x=.5\wd\pgfnodeparttextbox% \pgfmathsetlength\pgf@y{+0.5ex}% } \savedanchor\basepoint{% - \pgf@x.5\wd\pgfnodeparttextbox% - \pgf@y0pt\relax% + \pgf@x=.5\wd\pgfnodeparttextbox% + \pgf@y=0pt\relax% } \anchor{center}{\centerpoint}% \anchor{mid}{\midpoint}% - \anchor{mid east}{% - \roundedrectanglepoints% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \csname pgf@anchor@rounded rectangle@east\endcsname% - \else% - \csname pgf@anchor@rounded rectangle@south east\endcsname% - \fi% - \pgf@xa\pgf@x% + \anchor{mid west}{% + \csname pgf@anchor@rounded rectangle@west\endcsname% + \pgf@xc=\pgf@x% \midpoint% - \pgf@x\pgf@xa% + \pgf@x=\pgf@xc% }% - \anchor{mid west}{% - \roundedrectanglepoints% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \csname pgf@anchor@rounded rectangle@west\endcsname% - \else% - \csname pgf@anchor@rounded rectangle@south west\endcsname% - \fi% - \pgf@xa\pgf@x% + \anchor{mid east}{% + \csname pgf@anchor@rounded rectangle@east\endcsname% + \pgf@xc=\pgf@x% \midpoint% - \pgf@x\pgf@xa% + \pgf@x=\pgf@xc% }% \anchor{base}{\basepoint}% - \anchor{base east}{% - \roundedrectanglepoints% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \csname pgf@anchor@rounded rectangle@east\endcsname% - \else% - \csname pgf@anchor@rounded rectangle@south east\endcsname% - \fi% - \pgf@y0pt% - }% \anchor{base west}{% - \roundedrectanglepoints% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \csname pgf@anchor@rounded rectangle@west\endcsname% - \else% - \csname pgf@anchor@rounded rectangle@south west\endcsname% - \fi% - \pgf@y0pt% + \csname pgf@anchor@rounded rectangle@west\endcsname% + \pgf@xc=\pgf@x% + \basepoint% + \pgf@x=\pgf@xc% + }% + \anchor{base east}{% + \csname pgf@anchor@rounded rectangle@east\endcsname% + \pgf@xc=\pgf@x% + \basepoint% + \pgf@x=\pgf@xc% }% \anchor{north}{% - \pgfpointadd{\centerpoint}{% - \roundedrectanglepoints% - \anchorcornernoarc% - \pgf@x0pt% - }% + \roundedrectanglepoints% + \pgfpointadd{\centerpoint}{\pgfpoint{+0pt}{\halfheight+\outerysep}}% }% - \anchor{east}{% - \pgfpointadd{\centerpoint}{% - \roundedrectanglepoints% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \pathcornerconvexarc% - \advance\pgf@x\arcwidth\relax% - \advance\pgf@x\outerxsep\relax% - \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \pathcornerconcavearc% - \advance\pgf@x-\arcwidth\relax% - \advance\pgf@x\outerxsep\relax% - \else% - \anchorcornernoarc% - \fi% - \fi% - \pgf@y0pt\relax% - }% + \anchor{south}{% + \roundedrectanglepoints% + \pgfpointadd{\centerpoint}{\pgfpoint{+0pt}{-\halfheight-\outerysep}}% }% \anchor{west}{% + \roundedrectanglepoints% \pgfpointadd{\centerpoint}{% - \roundedrectanglepoints% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@convex% - \pathcornerconvexarc% - \advance\pgf@x\arcwidth\relax% - \advance\pgf@x\outerxsep\relax% + \ifx\westarc\pgf@lib@sh@misc@rr@text@concave% + \pgfpoint{-\halfwidth-\arcwidth-\concavexshift}{+0pt}% \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@concave% - \pathcornerconcavearc% - \advance\pgf@x-\arcwidth\relax% - \advance\pgf@x\outerxsep\relax% + \ifx\westarc\pgf@lib@sh@misc@rr@text@convex% + \pgfpoint{-\halfwidth-\chordwidth-\outerxsep}{+0pt}% \else% - \anchorcornernoarc% + \pgfpoint{-\halfwidth-\outerxsep}{+0pt}% \fi% - \fi% - \pgf@x-\pgf@x% - \pgf@y0pt\relax% + \fi% }% }% - \anchor{south}{% - \pgfpointadd{\centerpoint}{% - \roundedrectanglepoints% - \anchorcornernoarc% - \pgf@x0pt% - \pgf@y-\pgf@y - }% + \anchor{north west}{% + \roundedrectanglepoints% + \ifx\westarc\pgf@lib@sh@misc@rr@text@convex% + \pgfpointadd{\centerpoint}{\pgfpoint{-\halfwidth-\chordwidth+\arcwidth-\convexxshift}{+0pt}}% + \else% + \csname pgf@anchor@rounded rectangle@west\endcsname% + \fi% + \pgf@xc=\pgf@x% + \csname pgf@anchor@rounded rectangle@north\endcsname% + \pgf@x=\pgf@xc% }% - \anchor{north east}{% - \pgfpointadd{\centerpoint}{% - \roundedrectanglepoints% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \anchorcornerconvexarc% - \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \anchorcornerconcavearc% - \else% - \anchorcornernoarc% - \fi% - \fi% - }% + \anchor{south west}{% + \roundedrectanglepoints% + \ifx\westarc\pgf@lib@sh@misc@rr@text@convex% + \pgfpointadd{\centerpoint}{\pgfpoint{-\halfwidth-\chordwidth+\arcwidth-\convexxshift}{+0pt}}% + \else% + \csname pgf@anchor@rounded rectangle@west\endcsname% + \fi% + \pgf@xc=\pgf@x% + \csname pgf@anchor@rounded rectangle@south\endcsname% + \pgf@x=\pgf@xc% }% - \anchor{north west}{% + \anchor{east}{% + \roundedrectanglepoints% \pgfpointadd{\centerpoint}{% - \roundedrectanglepoints% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@convex% - \anchorcornerconvexarc% + \ifx\eastarc\pgf@lib@sh@misc@rr@text@concave% + \pgfpoint{\halfwidth+\arcwidth+\concavexshift}{+0pt}% \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@concave% - \anchorcornerconcavearc% + \ifx\eastarc\pgf@lib@sh@misc@rr@text@convex% + \pgfpoint{\halfwidth+\chordwidth+\outerxsep}{+0pt}% \else% - \anchorcornernoarc% + \pgfpoint{\halfwidth+\outerxsep}{+0pt}% \fi% \fi% - \pgf@x-\pgf@x% }% }% - \anchor{south west}{% - \pgfpointadd{\centerpoint}{% - \roundedrectanglepoints% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@convex% - \anchorcornerconvexarc% - \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@concave% - \anchorcornerconcavearc% - \else% - \anchorcornernoarc% - \fi% - \fi% - \pgf@x-\pgf@x% - \pgf@y-\pgf@y% - }% + \anchor{north east}{% + \roundedrectanglepoints% + \ifx\eastarc\pgf@lib@sh@misc@rr@text@convex% + \pgfpointadd{\centerpoint}{\pgfpoint{\halfwidth+\chordwidth-\arcwidth+\convexxshift}{+0pt}}% + \else% + \csname pgf@anchor@rounded rectangle@east\endcsname% + \fi% + \pgf@xc=\pgf@x% + \csname pgf@anchor@rounded rectangle@north\endcsname% + \pgf@x=\pgf@xc% }% \anchor{south east}{% - \pgfpointadd{\centerpoint}{% - \roundedrectanglepoints% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \anchorcornerconvexarc% - \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \anchorcornerconcavearc% - \else% - \anchorcornernoarc% - \fi% - \fi% - \pgf@y-\pgf@y% - }% - }% - \anchor{shape center}{% - \roundedrectanglepoints% - \pgfpointadd{\centerpoint}{% - \pgfpointadd{% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \pathcornerconvexarc% - \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \pathcornerconcavearc% - \else% - \pathcornernoarc% - \fi% - \fi}% - {% - \pgfpointadd{% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \pathcornerconvexarc% - \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \pathcornerconcavearc% - \else% - \pathcornernoarc% - \fi% - \fi - \pgf@x-\pgf@x}% - {% - \pgfpointadd{% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@convex% - \pathcornerconvexarc% - \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@concave% - \pathcornerconcavearc% - \else% - \pathcornernoarc% - \fi% - \fi - \pgf@x-\pgf@x% - \pgf@y-\pgf@y}% - {% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \pathcornerconvexarc% - \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \pathcornerconcavearc% - \else% - \pathcornernoarc% - \fi% - \fi - \pgf@y-\pgf@y% - }% - }% - }% - \divide\pgf@x4\relax% - \divide\pgf@y4\relax% - }% + \roundedrectanglepoints% + \ifx\eastarc\pgf@lib@sh@misc@rr@text@convex% + \pgfpointadd{\centerpoint}{\pgfpoint{\halfwidth+\chordwidth-\arcwidth+\convexxshift}{+0pt}}% + \else% + \csname pgf@anchor@rounded rectangle@east\endcsname% + \fi% + \pgf@xc=\pgf@x% + \csname pgf@anchor@rounded rectangle@south\endcsname% + \pgf@x=\pgf@xc% }% \backgroundpath{% {% - \pgftransformshift{\centerpoint}% \roundedrectanglepoints% - % - \pgf@x\xradius\relax% - \pgf@y\yradius\relax% - \advance\pgf@x-\outerxsep\relax% - \advance\pgf@y-\outerysep\relax% - \edef\xradius{\the\pgf@x}% - \edef\yradius{\the\pgf@y}% - % - \pgfpathmoveto{% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \pathcornerconvexarc% - \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \pathcornerconcavearc% - \else% - \pathcornernoarc% - \fi% - \fi% - }% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \pgfpatharc{\halfarcangle}{-\halfarcangle}{\xradius and \yradius}% + \pgftransformshift{\centerpoint}% + \pgfpathmoveto{\pgfpoint{0pt}{\halfheight}}% + \ifx\eastarc\pgf@lib@sh@misc@rr@text@concave% + \pgfpathlineto{\pgfpoint{\halfwidth+\arcwidth}{+\halfheight}}% + \pgfpatharc{180-\halfarcangle}{180+\halfarcangle}{+\radius}% \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \pgfpatharc{180-\halfarcangle}{180+\halfarcangle}{\xradius and \yradius}% + \ifx\eastarc\pgf@lib@sh@misc@rr@text@convex% + \pgfpathlineto{\pgfpoint{\halfwidth+\chordwidth-\arcwidth}{+\halfheight}}% + \pgfpatharc{+\halfarcangle}{+-\halfarcangle}{+\radius}% \else% - \pgfpathlineto{\pathcornernoarc\pgf@y-\pgf@y}% + \pgfpathlineto{\pgfqpoint{\halfwidth}{\halfheight}}% + \pgfpathlineto{\pgfqpoint{\halfwidth}{-\halfheight}}% \fi% \fi% - \pgfpathlineto{% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@convex% - \pathcornerconvexarc% - \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@concave% - \pathcornerconcavearc% - \else% - \pathcornernoarc% - \fi% - \fi% - \pgf@x-\pgf@x% - \pgf@y-\pgf@y% - }% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@convex% - \pgfpatharc{180+\halfarcangle}{180-\halfarcangle}{\xradius and \yradius}% + \ifx\westarc\pgf@lib@sh@misc@rr@text@concave% + \pgfpathlineto{\pgfpoint{-\halfwidth-\arcwidth}{+-\halfheight}}% + \pgfpatharc{+-\halfarcangle}{+\halfarcangle}{+\radius}% \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@concave% - \pgfpatharc{-\halfarcangle}{\halfarcangle}{\xradius and \yradius}% + \ifx\westarc\pgf@lib@sh@misc@rr@text@convex% + \pgfpathlineto{\pgfpoint{-\halfwidth-\chordwidth+\arcwidth}{+-\halfheight}}% + \pgfpatharc{180+\halfarcangle}{180-\halfarcangle}{+\radius}% \else% - \pgfpathlineto{\pathcornernoarc\pgf@x-\pgf@x}% + \pgfpathlineto{\pgfqpoint{-\halfwidth}{-\halfheight}}% + \pgfpathlineto{\pgfqpoint{-\halfwidth}{\halfheight}}% \fi% \fi% \pgfpathclose% }% } \anchorborder{% - \pgfextract@process\externalpoint{% - \pgfextract@process\externalpoint{}% + \pgfextract@process\externalpoint{% + \pgfextract@process\externalpoint{}% \pgfpointadd{\centerpoint}{\externalpoint}% }% \roundedrectanglepoints% % \pgfmathanglebetweenpoints{\centerpoint}{\externalpoint}% - \let\externalangle\pgfmathresult% - % - \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@west\endcsname}% + \let\externalangle=\pgfmathresult% + \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@north west\endcsname}% \ifdim\externalangle pt<\pgfmathresult pt\relax% - \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@north\endcsname}% + \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@north east\endcsname}% \ifdim\externalangle pt<\pgfmathresult pt\relax% - \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@north east\endcsname}% - \ifdim\externalangle pt<\pgfmathresult pt\relax% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}% - {% - \csname pgf@anchor@rounded rectangle@east\endcsname% - \advance\pgf@x-\xradius\relax% - }% - {0}{\halfarcangle}{\xradius and \yradius}% - \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \pgfmathpointintersectionoflineandarc{\centerpoint}{\externalpoint}% - {% - \centerpoint% - \pgf@xa\pgf@x% - \pgf@ya\pgf@y% - \pathcornernoarc% - \advance\pgf@x\pgf@xa% - \pgf@y\pgf@ya% - \advance\pgf@x\xpathradius\relax% - }% - {180-\halfarcangle}{180}{\xinnerradius and \yinnerradius}% - \else% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% - {\csname pgf@anchor@rounded rectangle@north east\endcsname}% - {\csname pgf@anchor@rounded rectangle@south east\endcsname}% - \fi% - \fi% + % Between north east and east. + \ifx\eastarc\pgf@lib@sh@misc@rr@text@convex% + \pgfextract@process\arccenter{% + \pgfpointadd{\centerpoint}{\pgfpoint{\halfwidth+\chordwidth-\radius}{+0pt}}% + }% + \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}% + {\arccenter}{0}{\halfarcangle}{\radius+\outerxsep and \radius+\outerysep}% \else% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% + \pgfpointintersectionoflines% {\csname pgf@anchor@rounded rectangle@north east\endcsname}% - {\csname pgf@anchor@rounded rectangle@north west\endcsname}% + {\csname pgf@anchor@rounded rectangle@south east\endcsname}% + {\externalpoint}{\centerpoint}% \fi% \else% - \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@north west\endcsname}% - \ifdim\externalangle pt<\pgfmathresult pt\relax% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% - {\csname pgf@anchor@rounded rectangle@north east\endcsname}% - {\csname pgf@anchor@rounded rectangle@north west\endcsname}% - \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@convex% - \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}% - {% - \csname pgf@anchor@rounded rectangle@west\endcsname% - \advance\pgf@x\xradius\relax% - }% - {180-\halfarcangle}{180}{\xradius and \yradius}% - \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@concave% - \pgfmathpointintersectionoflineandarc{\centerpoint}{\externalpoint}% - {% - \centerpoint% - \pgf@xa\pgf@x% - \pgf@ya\pgf@y% - \pathcornernoarc% - \pgf@x-\pgf@x% - \advance\pgf@x\pgf@xa% - \pgf@y\pgf@ya% - \advance\pgf@x-\xpathradius\relax% - }% - {0}{\halfarcangle}{\xinnerradius and \yinnerradius}% - \else% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% - {\csname pgf@anchor@rounded rectangle@north west\endcsname}% - {\csname pgf@anchor@rounded rectangle@south west\endcsname}% - \fi% - \fi% - \fi% + % Between north west and north east. + \pgfpointintersectionoflines% + {\csname pgf@anchor@rounded rectangle@north east\endcsname}% + {\csname pgf@anchor@rounded rectangle@north west\endcsname}% + {\externalpoint}{\centerpoint}% \fi% \else% - \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@south\endcsname}% + \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@south west\endcsname}% \ifdim\externalangle pt<\pgfmathresult pt\relax% - \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@south west\endcsname}% - \ifdim\externalangle pt<\pgfmathresult pt\relax% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@convex% - \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}% - {% - \csname pgf@anchor@rounded rectangle@west\endcsname% - \advance\pgf@x\xradius\relax% - }% - {180}{180+\halfarcangle}{\xradius and \yradius}% - \else% - \ifx\leftarc\pgf@lib@shapes@roundedrectangle@concave% - \pgfmathpointintersectionoflineandarc{\centerpoint}{\externalpoint}% - {% - \centerpoint% - \pgf@xa\pgf@x% - \pgf@ya\pgf@y% - \pathcornernoarc% - \pgf@x-\pgf@x% - \advance\pgf@x\pgf@xa% - \pgf@y\pgf@ya% - \advance\pgf@x-\xpathradius\relax% - }% - {360-\halfarcangle}{360}{\xinnerradius and \yinnerradius}% - \else% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% - {\csname pgf@anchor@rounded rectangle@north west\endcsname}% - {\csname pgf@anchor@rounded rectangle@south west\endcsname}% - \fi% - \fi% + % Between south west and north west. + \ifx\westarc\pgf@lib@sh@misc@rr@text@convex% + \pgfextract@process\arccenter{% + \pgfpointadd{\centerpoint}{\pgfpoint{-\halfwidth-\chordwidth+\radius}{+0pt}}% + }% + \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}% + {\arccenter}{180-\halfarcangle}{180+\halfarcangle}{\radius+\outerxsep and \radius+\outerysep}% \else% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% + \pgfpointintersectionoflines% + {\csname pgf@anchor@rounded rectangle@north west\endcsname}% {\csname pgf@anchor@rounded rectangle@south west\endcsname}% - {\csname pgf@anchor@rounded rectangle@south east\endcsname}% + {\externalpoint}{\centerpoint}% \fi% \else% \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@rounded rectangle@south east\endcsname}% \ifdim\externalangle pt<\pgfmathresult pt\relax% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% - {\csname pgf@anchor@rounded rectangle@south west\endcsname}% + % Between south east and south west. + \pgfpointintersectionoflines% {\csname pgf@anchor@rounded rectangle@south east\endcsname}% + {\csname pgf@anchor@rounded rectangle@south west\endcsname}% + {\externalpoint}{\centerpoint}% \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@convex% - \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}% - {% - \csname pgf@anchor@rounded rectangle@east\endcsname% - \advance\pgf@x-\xradius\relax% + % Between east and south east. + \ifx\eastarc\pgf@lib@sh@misc@rr@text@convex% + \pgfextract@process\arccenter{% + \pgfpointadd{\centerpoint}{\pgfpoint{\halfwidth+\chordwidth-\radius}{+0pt}}% }% - {360-\halfarcangle}{360}{\xradius and \yradius}% + \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}% + {\arccenter}{360-\halfarcangle}{360}{\radius+\outerxsep and \radius+\outerysep}% \else% - \ifx\rightarc\pgf@lib@shapes@roundedrectangle@concave% - \pgfmathpointintersectionoflineandarc{\centerpoint}{\externalpoint}% - {% - \centerpoint% - \pgf@xa\pgf@x% - \pgf@ya\pgf@y% - \pathcornernoarc% - \advance\pgf@x\pgf@xa% - \pgf@y\pgf@ya% - \advance\pgf@x\xpathradius\relax% - }% - {180}{180+\halfarcangle}{\xinnerradius and \yinnerradius}% - \else% - \pgfpointintersectionoflines{\centerpoint}{\externalpoint}% - {\csname pgf@anchor@rounded rectangle@south east\endcsname}% - {\csname pgf@anchor@rounded rectangle@north east\endcsname}% - \fi% + \pgfpointintersectionoflines% + {\csname pgf@anchor@rounded rectangle@north east\endcsname}% + {\csname pgf@anchor@rounded rectangle@south east\endcsname}% + {\externalpoint}{\centerpoint}% \fi% \fi% \fi% \fi% - }% + } } - % Keys for chamfered rectangle % % /pgf/chamfered rectangle corners : specify the corners to chamfer. @@ -689,33 +479,33 @@ % /pgf/chamfered rectangle xsep : set the extent of the x chamferling. % /pgf/chamfered rectangle ysep : set the extent of the y chamferling. -\pgfkeys{/pgf/chamfered rectangle corners/.store in=\pgf@chamferedrectangle@corners} -\pgfkeys{/tikz/chamfered rectangle corners/.store in=\pgf@chamferedrectangle@corners} +\pgfkeys{/pgf/chamfered rectangle corners/.store in=\pgf@lib@sh@misc@cr@corners} +\pgfkeys{/tikz/chamfered rectangle corners/.store in=\pgf@lib@sh@misc@cr@corners} -\def\pgf@chamferedrectangle@chamferall{chamfer all}% -\def\pgf@chamferedrectangle@chamfer{chamfer} -\let\pgf@chamferedrectangle@corners\pgf@chamferedrectangle@chamferall +\def\pgf@lib@sh@misc@cr@chamferall{chamfer all}% +\def\pgf@lib@sh@misc@cr@chamfer{chamfer} +\let\pgf@lib@sh@misc@cr@corners\pgf@lib@sh@misc@cr@chamferall -\def\pgf@chamferedrectangle@getcorners{% +\def\pgf@lib@sh@misc@cr@getcorners{% \let\northeastcorner\pgfutil@empty% \let\southeastcorner\pgfutil@empty% \let\southwestcorner\pgfutil@empty% \let\northwestcorner\pgfutil@empty% - \expandafter\pgfutil@in@\expandafter{\pgf@chamferedrectangle@corners}{chamfer all}% + \expandafter\pgfutil@in@\expandafter{\pgf@lib@sh@misc@cr@corners}{chamfer all}% \ifpgfutil@in@% - \let\northeastcorner\pgf@chamferedrectangle@round% - \let\southeastcorner\pgf@chamferedrectangle@round% - \let\southwestcorner\pgf@chamferedrectangle@round% - \let\northwestcorner\pgf@chamferedrectangle@round% + \let\northeastcorner\pgf@lib@sh@misc@cr@round% + \let\southeastcorner\pgf@lib@sh@misc@cr@round% + \let\southwestcorner\pgf@lib@sh@misc@cr@round% + \let\northwestcorner\pgf@lib@sh@misc@cr@round% \let\pgf@next\relax% \else% - \let\pgf@next\pgf@chamferedrectangle@parsecorners% + \let\pgf@next\pgf@lib@sh@misc@cr@parsecorners% \fi% \pgf@next} -\def\pgf@chamferedrectangle@parsecorners{% - \expandafter\pgf@@chamferedrectangle@parsecorners\pgf@chamferedrectangle@corners,\pgf@stop,% +\def\pgf@lib@sh@misc@cr@parsecorners{% + \expandafter\pgf@@chamferedrectangle@parsecorners\pgf@lib@sh@misc@cr@corners,\pgf@stop,% } \def\pgf@@chamferedrectangle@parsecorners#1,{% @@ -724,19 +514,19 @@ \else% \pgfutil@in@{@#1@}{@north east@@top left@}% \ifpgfutil@in@% - \let\northeastcorner\pgf@chamferedrectangle@chamfer% + \let\northeastcorner\pgf@lib@sh@misc@cr@chamfer% \else% \pgfutil@in@{@#1@}{@south east@@bottom right@}% \ifpgfutil@in@% - \let\southeastcorner\pgf@chamferedrectangle@chamfer% + \let\southeastcorner\pgf@lib@sh@misc@cr@chamfer% \else% \pgfutil@in@{@#1@}{@south west@@bottom left@}% \ifpgfutil@in@% - \let\southwestcorner\pgf@chamferedrectangle@chamfer% + \let\southwestcorner\pgf@lib@sh@misc@cr@chamfer% \else% \pgfutil@in@{@#1@}{@north west@@top right@}% \ifpgfutil@in@% - \let\southeastcorner\pgf@chamferedrectangle@round% + \let\northwestcorner\pgf@lib@sh@misc@cr@round% \fi% \fi% \fi% @@ -766,7 +556,7 @@ % \pgfdeclareshape{chamfered rectangle}{% \savedmacro\getchamferedrectanglepoints{% - \pgf@chamferedrectangle@getcorners% + \pgf@lib@sh@misc@cr@getcorners% % % Get the node dimensions. % diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.multipart.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.multipart.code.tex new file mode 100644 index 00000000000..15d7baf090c --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.multipart.code.tex @@ -0,0 +1,1354 @@ +% Copyright 2007 by Till Tantau and Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/shapes/pgflibraryshapes.multipart.code.tex,v 1.2 2010/01/07 01:12:23 vibrovski Exp $ + +\newbox\pgfnodepartlowerbox + +% +% A circle that is split in the middle into an upper and a lower part. +% +% This node consists of two parts: The upper (main) part is shown in +% the upper half of the circle. The second part is the (optional) +% lower part. +% +% Parts: text, lower + +\pgfdeclareshape{circle split} +{ + % + % Node parts + % + \nodeparts{text,lower} + + % + % Anchors + % + \savedanchor\centerpoint{% + \pgf@x=.5\wd\pgfnodeparttextbox% + \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/inner ysep}}% + \pgf@y=-\pgf@y% + \advance\pgf@y by-\dp\pgfnodeparttextbox% + \advance\pgf@y by-.5\pgflinewidth% + }% + \savedanchor\loweranchor{% + \pgf@x=-.5\wd\pgfnodepartlowerbox% + \advance\pgf@x by.5\wd\pgfnodeparttextbox% + \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/inner ysep}}% + \pgf@y=-2\pgf@y% + \advance\pgf@y by-\ht\pgfnodepartlowerbox% + \advance\pgf@y by-.5\pgflinewidth% + \advance\pgf@y by-\dp\pgfnodeparttextbox% + \advance\pgf@y by-.5\pgflinewidth% + } + + \saveddimen\radius{% + % + % Caculate ``height radius'' + % + %\pgf@ya=.5\ht\pgfnodeparttextbox% +% \advance\pgf@ya by.5\dp\pgfnodeparttextbox% +% \advance\pgf@ya by.5\ht\pgfnodepartlowerbox% +% \advance\pgf@ya by.5\dp\pgfnodepartlowerbox% +% \advance\pgf@ya by.5\pgflinewidth% + % + % MW: Suggested correction for above calculation: Use the tallest box * 2. + % + \pgf@ya=.5\ht\pgfnodeparttextbox% + \advance\pgf@ya by.5\dp\pgfnodeparttextbox% + \pgf@yb=.5\ht\pgfnodepartlowerbox% + \advance\pgf@yb by.5\dp\pgfnodepartlowerbox% + \ifdim\pgf@ya>\pgf@yb\relax% + \pgf@ya2.0\pgf@ya\relax% + \else% + \pgf@ya2.0\pgf@yb\relax% + \fi% + \advance\pgf@ya by.5\pgflinewidth% + \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@ya by2\pgf@yb% + % + % Caculate ``width radius'' + % + \pgf@xa=.5\wd\pgfnodeparttextbox% + \ifdim\pgf@xa<.5\wd\pgfnodepartlowerbox% + \pgf@xa=.5\wd\pgfnodepartlowerbox% + \fi% + \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@xa by\pgf@xb% + % + % Calculate length of radius vector: + % + \pgf@process{\pgfpointnormalised{\pgfqpoint{\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: + % + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/minimum width}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/minimum height}}% + \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. + % + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb% + \advance\pgf@x by\pgf@yb% + \else% + \advance\pgf@x by\pgf@xb% + \fi% + } + + % + % Anchors + % + \inheritanchorborder[from=circle] + \inheritanchor[from=circle]{north} + \inheritanchor[from=circle]{north west} + \inheritanchor[from=circle]{north east} + \inheritanchor[from=circle]{center} + \inheritanchor[from=circle]{west} + \inheritanchor[from=circle]{east} + \inheritanchor[from=circle]{mid} + \inheritanchor[from=circle]{mid west} + \inheritanchor[from=circle]{mid east} + \inheritanchor[from=circle]{base} + \inheritanchor[from=circle]{base west} + \inheritanchor[from=circle]{base east} + \inheritanchor[from=circle]{south} + \inheritanchor[from=circle]{south west} + \inheritanchor[from=circle]{south east} + \anchor{lower}{\loweranchor} + + % + % Background path + % + \inheritbackgroundpath[from=circle] + \beforebackgroundpath{ + \pgfutil@tempdima=\radius% + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb% + \advance\pgfutil@tempdima by-\pgf@yb% + \else% + \advance\pgfutil@tempdima by-\pgf@xb% + \fi% + \advance\pgfutil@tempdima by-.5\pgflinewidth% + \pgfsetshortenstart{0pt}% + \pgfsetshortenend{0pt}% + \pgfsetarrows{-}% + \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfqpoint{-1\pgfutil@tempdima}{0pt}}}% + \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpoint{\pgfutil@tempdima}{0pt}}}% + \pgfusepath{stroke}% + } +} + + +% +% A circle that is split diagonally into an upper and a lower part. +% +% Parts: text, lower + +\pgfdeclareshape{circle solidus}{% + % Node parts + \nodeparts{text,lower}% + % Anchors + % solidus slants at 45 degrees + % text placement minimizes the required radius, + % this is achieved placing the "outer" corner + % of each box in the line orthogonal to the + % solidus which passes through circle center + \savedanchor\centerpoint{% + \pgf@x=0.5\wd\pgfnodeparttextbox% + \advance\pgf@x by0.5\dp\pgfnodeparttextbox% + \advance\pgf@x by0.5\ht\pgfnodeparttextbox% + \pgf@y=-\pgf@x% + \advance\pgf@y by\ht\pgfnodeparttextbox% + \advance\pgf@x by0.3536\pgflinewidth% + \advance\pgf@y by-0.3536\pgflinewidth% + \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@x by\pgf@xa% + \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@y by-\pgf@ya% + }% + \savedanchor\loweranchor{% + \pgf@x=0.5\wd\pgfnodeparttextbox% + \advance\pgf@x by0.5\dp\pgfnodeparttextbox% + \advance\pgf@x by0.5\ht\pgfnodeparttextbox% + \pgf@y=-\pgf@x% + \advance\pgf@y by\ht\pgfnodeparttextbox% + \advance\pgf@x by0.5\ht\pgfnodepartlowerbox% + \advance\pgf@x by0.5\dp\pgfnodepartlowerbox% + \advance\pgf@x by-0.5\wd\pgfnodepartlowerbox% + \advance\pgf@y by-0.5\ht\pgfnodepartlowerbox% + \advance\pgf@y by0.5\dp\pgfnodepartlowerbox% + \advance\pgf@y by-0.5\wd\pgfnodepartlowerbox% + \advance\pgf@x by0.7071\pgflinewidth% + \advance\pgf@y by-0.7071\pgflinewidth% + \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/inner xsep}}% + \advance\pgf@x by2\pgf@xa% + \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@y by-2\pgf@ya% + }% + \saveddimen\radius{% + % "top" radius + \pgf@x=\ht\pgfnodeparttextbox% + \advance\pgf@x by\dp\pgfnodeparttextbox% + \advance\pgf@x by\wd\pgfnodeparttextbox% + % "bottom" radius + \pgf@y=\ht\pgfnodepartlowerbox% + \advance\pgf@y by\dp\pgfnodepartlowerbox% + \advance\pgf@y by\wd\pgfnodepartlowerbox% + % use the larger + \ifdim\pgf@x<\pgf@y% + \pgf@x=\pgf@y% + \fi% + \pgf@x=0.7071\pgf@x% + % add spacings + \advance\pgf@x by0.5\pgflinewidth% + \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/inner xsep}}% + \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/inner ysep}}% + \pgfmathaddtolength{\pgf@x}{veclen(2\pgf@xa,2\pgf@ya)}% + % If necessary, adjust radius so that the size requirements are + % met: + \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/minimum width}}% + \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/minimum height}}% + \ifdim\pgf@x<.5\pgf@xa% + \pgf@x=.5\pgf@xa% + \fi% + \ifdim\pgf@x<.5\pgf@ya% + \pgf@x=.5\pgf@ya% + \fi% + % Now, add larger of outer separations. + \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xa<\pgf@ya% + \advance\pgf@x by\pgf@ya% + \else% + \advance\pgf@x by\pgf@xa% + \fi% + }% + % Anchors + \inheritanchorborder[from=circle]% + \inheritanchor[from=circle]{north}% + \inheritanchor[from=circle]{north west}% + \inheritanchor[from=circle]{north east}% + \inheritanchor[from=circle]{center}% + \inheritanchor[from=circle]{west}% + \inheritanchor[from=circle]{east}% + \inheritanchor[from=circle]{mid}% + \inheritanchor[from=circle]{mid west}% + \inheritanchor[from=circle]{mid east}% + \inheritanchor[from=circle]{base}% + \inheritanchor[from=circle]{base west}% + \inheritanchor[from=circle]{base east}% + \inheritanchor[from=circle]{south}% + \inheritanchor[from=circle]{south west}% + \inheritanchor[from=circle]{south east}% + \anchor{lower}{\loweranchor}% + % Background path + \inheritbackgroundpath[from=circle]% + \beforebackgroundpath{% + \pgfutil@tempdima=\radius% + \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xa<\pgf@ya% + \advance\pgfutil@tempdima by-\pgf@ya% + \else% + \advance\pgfutil@tempdima by-\pgf@xa% + \fi% + \advance\pgfutil@tempdima by-.5\pgflinewidth% + \pgfsetshortenstart{0pt}% + \pgfsetshortenend{0pt}% + \pgfsetarrows{-}% + % solidus slants at 45 degrees and its length is + % the golden section of the diameter + \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfqpoint{-0.437\pgfutil@tempdima}{-0.437\pgfutil@tempdima}}}% + \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpoint{0.437\pgfutil@tempdima}{0.437\pgfutil@tempdima}}}% + \pgfusepath{stroke}% + }% +} + + +\def\pgf@lib@sh@newbox{\csname newbox\endcsname}% Get round outer. + +\def\pgf@lib@sh@toalpha#1{% + \ifcase#1\relax% + \or one\or two\or three\or four\or five\or six\or seven\or eight\or nine\or ten% + \or eleven\or twelve\or thirteen\or fourteen\or fifteen% + \or sixteen\or seventeen\or eighteen\or nineteen\or twenty% + \else% + twenty% + \fi% +} + + +\def\pgf@lib@sh@getalpha#1#2{\expandafter\edef\expandafter#1\expandafter{\pgf@lib@sh@toalpha{#2}}} + +\newbox\pgfnodeparttwobox +\newbox\pgfnodepartthreebox +\newbox\pgfnodepartfourbox + +\let\pgfnodepartonebox=\pgfnodeparttextbox +\let\pgfnodepartsecondbox=\pgfnodeparttwobox +\let\pgfnodepartthirdbox=\pgfnodepartthreebox +\let\pgfnodepartfourthbox=\pgfnodepartfourbox + +\def\pgf@lib@sh@allocateboxes#1{% + \c@pgf@counta=#1\relax% + \pgfmathloop% + \ifnum\c@pgf@counta>4\relax% + \pgfutil@ifundefined{pgfnodepart\pgf@lib@sh@toalpha{\c@pgf@counta}box}% + {% + \expandafter\pgf@lib@sh@newbox\csname pgfnodepart\pgf@lib@sh@toalpha{\c@pgf@counta}box\endcsname% + }% + {}% + \advance\c@pgf@counta by-1\relax% + \repeatpgfmathloop% +} + +\def\pgf@lib@sh@rs@lefttext{left} +\def\pgf@lib@sh@rs@righttext{right} +\def\pgf@lib@sh@rs@centertext{center} +\def\pgf@lib@sh@rs@bottomtext{bottom} +\def\pgf@lib@sh@rs@toptext{top} +\def\pgf@lib@sh@rs@basetext{base} +\def\pgf@lib@sh@rs@nonetext{none} + + +\newif\ifpgfrectanglesplithorizontal +\newif\ifpgfrectanglesplitdrawsplits\pgfrectanglesplitdrawsplitstrue +\newif\ifpgfrectanglesplitignoreemptyparts +\newif\ifpgfrectanglesplitusecustomfill + +\let\pgf@lib@sh@rs@every@emptypart=\pgfutil@empty +\let\pgf@lib@sh@rs@every@part=\pgfutil@empty +\def\pgf@lib@sh@rs@list@fill{none} + +\pgfkeys{/pgf/.cd, + rectangle split parts/.initial=4, + rectangle split part align/.initial=center, + rectangle split horizontal/.is if=pgfrectanglesplithorizontal, + rectangle split ignore empty parts/.is if=pgfrectanglesplitignoreemptyparts, + rectangle split empty part width/.code={% + \pgfmathsetlength\pgf@x{#1} + \edef\pgf@lib@sh@rs@temp{\noexpand\vrule width\the\pgf@x height0ptdepth0pt\relax}% + \def\pgf@lib@sh@rs@@temp{\def\pgf@lib@sh@rs@every@emptypart}% + \expandafter\expandafter\expandafter\pgf@lib@sh@rs@@temp\expandafter\expandafter\expandafter{% + \expandafter\pgf@lib@sh@rs@every@emptypart\pgf@lib@sh@rs@temp}% + },% + rectangle split empty part width=1ex, + rectangle split empty part height/.code={% + \pgfmathsetlength\pgf@x{#1} + \edef\pgf@lib@sh@rs@temp{\noexpand\vrule width0ptheight\the\pgf@x depth0pt\relax}% + \def\pgf@lib@sh@rs@@temp{\def\pgf@lib@sh@rs@every@emptypart}% + \expandafter\expandafter\expandafter\pgf@lib@sh@rs@@temp\expandafter\expandafter\expandafter{% + \expandafter\pgf@lib@sh@rs@every@emptypart\pgf@lib@sh@rs@temp}% + },% + rectangle split empty part height=1ex, + rectangle split empty part depth/.code={% + \pgfmathsetlength\pgf@x{#1} + \edef\pgf@lib@sh@rs@temp{\noexpand\vrule width0ptheight0ptdepth\the\pgf@x\relax}% + \def\pgf@lib@sh@rs@@temp{\def\pgf@lib@sh@rs@every@emptypart}% + \expandafter\expandafter\expandafter\pgf@lib@sh@rs@@temp\expandafter\expandafter\expandafter{% + \expandafter\pgf@lib@sh@rs@every@emptypart\pgf@lib@sh@rs@temp}% + },% + rectangle split empty part depth=0ex, + rectangle split every empty part/.store in=\pgf@lib@sh@rs@every@emptypart, + rectangle split part fill/.code=\def\pgf@lib@sh@rs@list@fill{#1}\pgfrectanglesplitusecustomfilltrue, + rectangle split uses custom fill/.is if=pgfrectanglesplitusecustomfill, + rectangle split draw splits/.is if=pgfrectanglesplitdrawsplits, + rectangle split allocate boxes/.code=\pgf@lib@sh@allocateboxes{#1} +} + + +\def\pgf@lib@sh@rs@process@list#1#2{% + \c@pgf@counta=1\relax% + \c@pgf@countb=#2\relax% + \edef\pgf@lib@sh@rs@temp{#1}% + \expandafter\pgf@lib@sh@rs@@process@list\pgf@lib@sh@rs@temp,\pgf@stop,} + +\def\pgf@lib@sh@rs@@process@list{% + \pgfutil@ifnextchar x{\pgf@lib@sh@rs@@@process@list}% + {\pgf@lib@sh@rs@@@process@list}} + +\def\pgf@lib@sh@rs@@@process@list#1,{% + \ifx#1\pgf@stop% + \let\pgf@next\pgf@lib@sh@rs@@@@process@list% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\c@pgf@counta}% + \def\pgf@lib@sh@rs@lastalign{#1}% + \pgfutil@namedef{pgf@lib@sh@rs@\pgf@lib@sh@toalpha{\c@pgf@counta}@item}{#1}% + \let\pgf@next\pgf@lib@sh@rs@@process@list% + \advance\c@pgf@counta by1\relax% + \fi% + \pgf@next} + +\def\pgf@lib@sh@rs@@@@process@list{% + \pgfmathloop% + \ifnum\c@pgf@counta>\c@pgf@countb% + \else% + \expandafter\edef\csname pgf@lib@sh@rs@\pgf@lib@sh@toalpha{\c@pgf@counta}@item\endcsname% + {\pgf@lib@sh@rs@lastalign}% + \advance\c@pgf@counta by1\relax% + \repeatpgfmathloop% +} + +\pgf@lib@sh@allocateboxes{20} + +\pgfdeclareshape{rectangle split}{% + \savedmacro\rectanglesplitparameters{% + \pgfmathsetcount\c@pgf@counta{\pgfkeysvalueof{/pgf/rectangle split parts}}% + \edef\parts{\the\c@pgf@counta}% + \addtosavedmacro\parts% + % + \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}% + \edef\innerxsep{\the\pgf@x}% + \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% + \edef\innerysep{\the\pgf@y}% + % + \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% + \edef\outerxsep{\the\pgf@x}% + \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}% + \edef\outerysep{\the\pgf@y}% + \addtosavedmacro\outerxsep% + \addtosavedmacro\outerysep% + % + \pgf@x=0pt\relax% Widest box. + \pgf@y=0pt\relax% Tallest box. + % + \pgfutil@tempdima=0pt\relax% Maximum box height. + \pgfutil@tempdimb=0pt\relax% Maximum box depth. + % + % Get the dimensions of the boxes... + % + \pgfmathloop% + \ifnum\pgfmathcounter>\parts% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + % + \expandafter\let\expandafter\pgf@lib@sh@box\expandafter=% + \csname pgfnodepart\pgf@lib@sh@rs@number box\endcsname% + \pgf@xa=\wd\pgf@lib@sh@box% + \pgf@ya=\ht\pgf@lib@sh@box% + \pgf@yb=\dp\pgf@lib@sh@box% + % + % Test to see if the box is empty... + % + \expandafter\def\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname{\relax}% + \ifdim\pgf@xa=0pt\relax% + \ifdim\pgf@ya=0pt\relax% + \ifdim\pgf@yb=0pt\relax% + % + % ...It is. So... + % + \ifpgfrectanglesplitignoreemptyparts% + % + % ...flag this if we are ignoring parts... + % + \expandafter\let\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname=\pgfutil@empty% + \else% + % + % ...otherwise insert the code for every empty part. + % + \setbox\pgf@lib@sh@box=\hbox{{\pgf@lib@sh@rs@every@emptypart}}% + \pgf@xa=\wd\pgf@lib@sh@box% + \pgf@ya=\ht\pgf@lib@sh@box% + \pgf@yb=\dp\pgf@lib@sh@box% + \fi% + \fi% + \fi% + \fi% + \expandafter\edef\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@number\endcsname{\the\pgf@xa}% + \expandafter\edef\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname{\the\pgf@ya}% + \expandafter\edef\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname{\the\pgf@yb}% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname% + % + % ...saving the widest box... + % + \ifdim\pgf@xa>\pgf@x% + \pgf@x=\pgf@xa% + \fi% + % + % ...the maximum height and depth... + % + \ifdim\pgf@ya>\pgfutil@tempdima% + \pgfutil@tempdima=\pgf@ya% + \fi% + \ifdim\pgf@yb>\pgfutil@tempdimb% + \pgfutil@tempdimb=\pgf@yb% + \fi% + % + % ...and the tallest box. + % + \pgf@yc=\pgfutil@tempdima% + \advance\pgf@yc by\pgfutil@tempdimb% + \ifdim\pgf@yc>\pgf@y% + \pgf@y=\pgf@yc% + \fi% + \repeatpgfmathloop% + % + \edef\pgf@lib@sh@rs@max@width{\the\pgf@x}% + \edef\pgf@lib@sh@rs@max@totalheight{\the\pgf@y}% + % + \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/minimum width}}% + \advance\pgf@x by-\innerxsep\relax% + \advance\pgf@x by-\innerxsep\relax% + \pgf@xa=\pgf@x% + \advance\pgf@xa by-\pgf@lib@sh@rs@max@width\relax% + \ifdim\pgf@xa>0pt\relax% + \edef\pgf@lib@sh@rs@max@width{\the\pgf@x}% + \fi% + % + \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/minimum height}}% + \advance\pgf@y by-\innerysep\relax% + \advance\pgf@y by-\innerysep\relax% + \pgf@ya=\pgf@y% + \advance\pgf@ya by-\pgf@lib@sh@rs@max@totalheight\relax% + \ifdim\pgf@ya>0pt\relax% + \edef\pgf@lib@sh@rs@max@totalheight{\the\pgf@y}% + \fi% + % + % Get the alignment of each node part box. + % + \pgf@lib@sh@rs@process@list{\pgfkeysvalueof{/pgf/rectangle split part align}}{\parts}% + % + % Are we splitting horizontally or vertically? + % + \ifpgfrectanglesplithorizontal% + % + % Calculate the origins of each node part box. + % + \pgf@x=0pt\relax% + \pgfmathloop% + \ifnum\pgfmathcounter>\parts% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + % + \expandafter\let\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname=\pgfutil@empty% + \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \ifpgfrectanglesplitignoreemptyparts% + \expandafter\let\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname=% + \pgf@lib@sh@rs@lastanchor% + \fi% + \fi% + % + % Adjust for alignment. + % + \expandafter\ifx\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname% + \pgf@lib@sh@rs@bottomtext% + \pgf@y=\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname\relax% + \else% + \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname% + \pgf@lib@sh@rs@toptext% + \pgf@y=-\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname\relax% + \advance\pgf@y by\pgf@lib@sh@rs@max@totalheight\relax% + \else% + \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname% + \pgf@lib@sh@rs@basetext% + \pgf@y=\pgf@lib@sh@rs@max@totalheight\relax% + \advance\pgf@y by-\pgfutil@tempdima% + \advance\pgf@y by\pgfutil@tempdimb% + \divide\pgf@y by2\relax% + \else% + \pgf@y=\pgf@lib@sh@rs@max@totalheight\relax% + \advance\pgf@y by-\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname\relax% + \advance\pgf@y by\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname\relax% + \divide\pgf@y by2\relax% + \fi% + \fi% + \fi% + % + % Re-adjust as the first box is at the origin. + % + \ifnum\pgfmathcounter=1\relax% + \edef\pgf@lib@sh@rs@yoffset{\the\pgf@y}% + \pgf@y=0pt\relax% + \pgfextract@process\pgf@lib@sh@rs@anchor@one{}% + \addtosavedmacro\pgf@lib@sh@rs@anchor@one% + \let\pgf@lib@sh@rs@lastanchor=\pgf@lib@sh@rs@anchor@one% + \let\pgf@lib@sh@rs@lastnumber=\pgf@lib@sh@rs@number% + \else + \advance\pgf@y by-\pgf@lib@sh@rs@yoffset\relax% + \advance\pgf@x by\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@lastnumber\endcsname\relax% + \advance\pgf@x by\innerxsep\relax% + \advance\pgf@x by\pgflinewidth% + \advance\pgf@x by\innerxsep\relax% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname{}% + \expandafter\let\expandafter\pgf@lib@sh@rs@lastanchor\expandafter=% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname% + \let\pgf@lib@sh@rs@lastnumber=\pgf@lib@sh@rs@number% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname% + \fi% + \fi% + \repeatpgfmathloop% + % + % Calculate some anchors. + % + \pgfextract@process\northeast{% + \pgf@lib@sh@rs@lastanchor% + \advance\pgf@x by\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@lastnumber\endcsname\relax% + \advance\pgf@x by\innerxsep\relax% + \advance\pgf@x by\outerxsep\relax% + \pgf@y=\pgf@lib@sh@rs@max@totalheight\relax% + \advance\pgf@y by-\pgf@lib@sh@rs@yoffset\relax% + \advance\pgf@y by\innerysep\relax% + \advance\pgf@y by\outerysep\relax% + }% + \addtosavedmacro\northeast% + \pgfextract@process\southwest{% + \pgf@lib@sh@rs@anchor@one% + \advance\pgf@x by-\innerxsep\relax% + \advance\pgf@x by-\outerxsep\relax% + \pgf@y=-\pgf@lib@sh@rs@yoffset\relax% + \advance\pgf@y by-\innerysep\relax% + \advance\pgf@y by-\outerysep\relax% + }% + \addtosavedmacro\southwest% + % + \pgfextract@process\centerpoint{% + \pgfpointadd{\southwest}{\northeast}% + \divide\pgf@x by2\relax% + \divide\pgf@y by2\relax% + }% + \addtosavedmacro\centerpoint% + % + \pgfmathloop% + \ifnum\pgfmathcounter>\parts% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + % + \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \else% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname% + \pgf@xa=\pgf@x% + \pgf@xb=\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@number\endcsname\relax% + \advance\pgf@xa by0.5\pgf@xb% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @south\endcsname{% + \southwest% + \pgf@x=\pgf@xa% + }% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @north\endcsname{% + \northeast% + \pgf@x=\pgf@xa% + }% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @north\endcsname% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @south\endcsname% + \ifnum\pgfmathcounter=\parts% + \else% + \advance\pgf@xa by0.5\pgf@xb% + \advance\pgf@xa by\innerxsep\relax% + \advance\pgf@xa by.5\pgflinewidth% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@south\endcsname{% + \southwest% + \pgf@x=\pgf@xa% + }% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@north\endcsname{% + \northeast% + \pgf@x=\pgf@xa% + }% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split\endcsname{% + \centerpoint% + \pgf@x=\pgf@xa% + }% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@north\endcsname% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@south\endcsname% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split\endcsname% + \fi% + \fi% + \repeatpgfmathloop% + \else% + % + % Calculate the origins of each node part box. + % + \pgf@y=0pt\relax% + \pgfmathloop% + \ifnum\pgfmathcounter>\parts% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + % + \expandafter\let\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname=\pgfutil@empty% + \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \ifpgfrectanglesplitignoreemptyparts% + \expandafter\let\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname=% + \pgf@lib@sh@rs@lastanchor% + \fi% + \fi% + % + % Adjust for alignment. + % + \expandafter\ifx\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname% + \pgf@lib@sh@rs@lefttext% + \pgf@x=0pt\relax% + \else% + \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname% + \pgf@lib@sh@rs@righttext% + \pgf@x=-\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@number\endcsname\relax% + \advance\pgf@x by\pgf@lib@sh@rs@max@width\relax% + \else% + \pgf@x=-\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@number\endcsname\relax% + \advance\pgf@x by\pgf@lib@sh@rs@max@width\relax% + \divide\pgf@x by2\relax% + \fi% + \fi% + % + % Re-adjust as the first box is at the origin. + % + \ifnum\pgfmathcounter=1\relax% + \edef\pgf@lib@sh@rs@xoffset{\the\pgf@x}% + \pgf@x=0pt\relax% + \pgfextract@process\pgf@lib@sh@rs@anchor@one{}% + \addtosavedmacro\pgf@lib@sh@rs@anchor@one% + \let\pgf@lib@sh@rs@lastanchor=\pgf@lib@sh@rs@anchor@one% + \let\pgf@lib@sh@rs@lastnumber=\pgf@lib@sh@rs@number% + \else + \advance\pgf@x by-\pgf@lib@sh@rs@xoffset\relax% + \advance\pgf@y by-\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@lastnumber\endcsname\relax% + \advance\pgf@y by-\innerysep\relax% + \advance\pgf@y by-\pgflinewidth% + \advance\pgf@y by-\innerysep\relax% + \advance\pgf@y by-\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname\relax% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname{}% + \expandafter\let\expandafter\pgf@lib@sh@rs@lastanchor\expandafter=% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname% + \let\pgf@lib@sh@rs@lastnumber=\pgf@lib@sh@rs@number% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname% + \fi% + \fi% + \repeatpgfmathloop% + % + % Calculate some anchors. + % + \pgfextract@process\northeast{% + \pgf@x=\pgf@lib@sh@rs@max@width\relax% + \advance\pgf@x by-\pgf@lib@sh@rs@xoffset\relax% + \advance\pgf@x by\innerxsep\relax% + \advance\pgf@x by\outerxsep\relax% + \pgf@y=\pgf@lib@sh@rs@height@one\relax% + \advance\pgf@y by\innerysep\relax% + \advance\pgf@y by\outerysep\relax% + \advance\pgf@y by.5\pgflinewidth% + }% + \addtosavedmacro\northeast% + \pgfextract@process\southwest{% + \pgf@lib@sh@rs@lastanchor% + \pgf@x=-\pgf@lib@sh@rs@xoffset\relax% + \advance\pgf@x by-\innerxsep\relax% + \advance\pgf@x by-\outerxsep\relax% + \advance\pgf@y by-\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@lastnumber\endcsname\relax% + \advance\pgf@y by-\innerysep\relax% + \advance\pgf@y by-\outerysep\relax% + \advance\pgf@y by-.5\pgflinewidth% + }% + \addtosavedmacro\southwest% + % + \pgfextract@process\centerpoint{% + \pgfpointadd{\southwest}{\northeast}% + \divide\pgf@x by2\relax% + \divide\pgf@y by2\relax% + }% + \addtosavedmacro\centerpoint% + % + \pgfmathloop% + \ifnum\pgfmathcounter>\parts% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + % + \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \else% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname% + \pgf@ya=\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname\relax% + \advance\pgf@y by0.5\pgf@ya% + \pgf@ya=\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname\relax% + \advance\pgf@y by-0.5\pgf@ya% + \pgf@ya=\pgf@y% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @west\endcsname{% + \southwest% + \pgf@y=\pgf@ya% + }% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @east\endcsname{% + \northeast% + \pgf@y=\pgf@ya% + }% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @east\endcsname% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @west\endcsname% + \ifnum\pgfmathcounter=\parts% + \else% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname% + \pgf@ya=\pgf@y% + \advance\pgf@ya by-\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname\relax% + \advance\pgf@ya by-\innerysep\relax% + \advance\pgf@ya by-.5\pgflinewidth% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@west\endcsname{% + \southwest% + \pgf@y=\pgf@ya% + }% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@east\endcsname{% + \northeast% + \pgf@y=\pgf@ya% + }% + \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split\endcsname{% + \centerpoint% + \pgf@y=\pgf@ya% + }% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@east\endcsname% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@west\endcsname% + \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split\endcsname% + \fi% + \fi% + \repeatpgfmathloop% + \fi% + }% + \savedanchor\basepoint{% + \pgf@x=0.5\wd\pgfnodeparttextbox% + \pgf@y=0pt\relax% + } + \savedanchor\midpoint{% + \pgf@x=0.5\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@y{+0.5ex}% + } + \anchor{center}{% + \rectanglesplitparameters% + \centerpoint% + }% + \anchor{base}{\basepoint} + \anchor{base east}{% + \rectanglesplitparameters% + \northeast% + \pgf@y=0pt\relax% + }% + \anchor{base west}{% + \rectanglesplitparameters% + \southwest% + \pgf@y=0pt\relax% + }% + \anchor{mid}{\midpoint}% + \anchor{mid east}{% + \rectanglesplitparameters% + \northeast% + \pgf@xa=\pgf@x% + \midpoint% + \pgf@x=\pgf@xa% + }% + \anchor{mid west}{% + \rectanglesplitparameters% + \southwest% + \pgf@xa=\pgf@x% + \midpoint% + \pgf@x=\pgf@xa% + }% + \anchor{north}{% + \rectanglesplitparameters% + \centerpoint% + \pgf@xa=\pgf@x% + \northeast% + \pgf@x=\pgf@xa% + } + \anchor{south}{% + \rectanglesplitparameters% + \centerpoint% + \pgf@xa=\pgf@x% + \southwest% + \pgf@x=\pgf@xa% + } + \anchor{east}{% + \rectanglesplitparameters% + \centerpoint% + \pgf@ya=\pgf@y% + \northeast% + \pgf@y=\pgf@ya% + } + \anchor{west}{% + \rectanglesplitparameters% + \centerpoint% + \pgf@ya=\pgf@y% + \southwest% + \pgf@y=\pgf@ya% + } + \anchor{north east}{% + \rectanglesplitparameters% + \northeast% + } + \anchor{north west}{% + \rectanglesplitparameters% + \northeast% + \pgf@ya=\pgf@y% + \southwest% + \pgf@y=\pgf@ya% + } + \anchor{south west}{% + \rectanglesplitparameters% + \southwest% + } + \anchor{south east}{% + \rectanglesplitparameters% + \southwest% + \pgf@ya=\pgf@y% + \northeast% + \pgf@y=\pgf@ya% + } + \behindbackgroundpath{% + \ifpgfrectanglesplitusecustomfill% + \pgf@lib@sh@rs@process@list{\pgf@lib@sh@rs@list@fill}{\parts}% + {% + \ifpgfrectanglesplithorizontal% + \expandafter\let\expandafter\pgf@lib@sh@rs@fill@bottomleft\expandafter=% + \csname pgf@anchor@rectangle split@south west\endcsname% + \pgfmathloop% + \ifnum\pgfmathcounter>\parts% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + \ifnum\pgfmathcounter=\parts% + \expandafter\let\expandafter\pgf@lib@sh@rs@fill@topright\expandafter=% + \csname pgf@anchor@rectangle split@north east\endcsname% + \else% + \expandafter\let\expandafter\pgf@lib@sh@rs@fill@topright\expandafter=% + \csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@number\space split north\endcsname% + \fi% + \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \else% + \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname\pgf@lib@sh@rs@nonetext% + \else% + \pgfextract@process\pgf@lib@sh@rs@fill@bottomleft{% + \pgf@lib@sh@rs@fill@bottomleft% + \advance\pgf@y by\outerysep\relax% + \ifnum\pgfmathcounter=1\relax% + \advance\pgf@x by\outerxsep\relax% + \fi% + }% + \pgfextract@process\pgf@lib@sh@rs@fill@topright{% + \pgf@lib@sh@rs@fill@topright% + \advance\pgf@y by-\outerysep\relax% + \ifnum\pgfmathcounter=\parts\relax% + \advance\pgf@x by-\outerxsep\relax% + \fi% + }% + \ifnum\pgfmathcounter>1\relax% + \begingroup\pgfsetcornersarced{\pgfpointorigin}% + \fi% + \pgfpathmoveto{% + \pgf@lib@sh@rs@fill@topright% + \pgf@xa=\pgf@x% + \pgf@lib@sh@rs@fill@bottomleft% + \pgf@x=\pgf@xa% + }% + \pgfpathlineto{\pgf@lib@sh@rs@fill@bottomleft}% + \pgfpathlineto{% + \pgf@lib@sh@rs@fill@bottomleft% + \pgf@xa=\pgf@x% + \pgf@lib@sh@rs@fill@topright% + \pgf@x=\pgf@xa% + }% + \ifnum\pgfmathcounter>1\relax% + \endgroup% + \fi% + \ifnum\pgfmathcounter<\parts% + \begingroup\pgfsetcornersarced{\pgfpointorigin}% + \fi% + \pgfpathlineto{\pgf@lib@sh@rs@fill@topright}% + \pgfpathclose% + \ifnum\pgfmathcounter<\parts% + \endgroup% + \fi% + \pgfsetfillcolor{\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname}% + \pgfusepath{fill}% + \fi% + \fi% + \pgfextract@process\pgf@lib@sh@rs@fill@bottomleft{% + \pgf@lib@sh@rs@fill@bottomleft% + \pgf@ya=\pgf@y% + \pgf@lib@sh@rs@fill@topright% + \pgf@y=\pgf@ya% + \advance\pgf@y by-\outerysep% + }% + \repeatpgfmathloop% + \else% + \expandafter\let\expandafter\pgf@lib@sh@rs@fill@topright\expandafter=% + \csname pgf@anchor@rectangle split@north east\endcsname% + \pgfmathloop% + \ifnum\pgfmathcounter>\parts% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + \ifnum\pgfmathcounter=\parts% + \expandafter\let\expandafter\pgf@lib@sh@rs@fill@bottomleft\expandafter=% + \csname pgf@anchor@rectangle split@south west\endcsname% + \else% + \expandafter\let\expandafter\pgf@lib@sh@rs@fill@bottomleft\expandafter=% + \csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@number\space split west\endcsname% + \fi% + \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \else% + \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname\pgf@lib@sh@rs@nonetext% + \else% + \pgfextract@process\pgf@lib@sh@rs@fill@bottomleft{% + \pgf@lib@sh@rs@fill@bottomleft% + \advance\pgf@x by\outerxsep\relax% + \ifnum\parts=1\relax% + \advance\pgf@y by\outerysep\relax% + \else% + \ifnum\pgfmathcounter=\parts + \advance\pgf@y by\outerysep\relax% + \fi% + \fi% + }% + \pgfextract@process\pgf@lib@sh@rs@fill@topright{% + \pgf@lib@sh@rs@fill@topright% + \advance\pgf@x by-\outerxsep\relax% + \ifnum\parts=1\relax% + \advance\pgf@y by-\outerysep\relax% + \else% + \ifnum\pgfmathcounter=1\relax% + \advance\pgf@y by-\outerysep\relax% + \fi% + \fi% + }% + \pgfpathmoveto{\pgf@lib@sh@rs@fill@bottomleft}% + \ifnum\pgfmathcounter>1\relax% + \begingroup\pgfsetcornersarced{\pgfpointorigin}% + \fi% + \pgfpathlineto{% + \pgf@lib@sh@rs@fill@bottomleft% + \pgf@xa=\pgf@x% + \pgf@lib@sh@rs@fill@topright% + \pgf@x=\pgf@xa% + }% + \pgfpathlineto{\pgf@lib@sh@rs@fill@topright}% + \ifnum\pgfmathcounter>1\relax% + \endgroup%% + \fi% + \ifnum\pgfmathcounter<\parts% + \begingroup\pgfsetcornersarced{\pgfpointorigin}% + \fi% + \pgfpathlineto{% + \pgf@lib@sh@rs@fill@topright% + \pgf@xa=\pgf@x% + \pgf@lib@sh@rs@fill@bottomleft% + \pgf@x=\pgf@xa% + }% + \pgfpathclose% + \ifnum\pgfmathcounter<\parts% + \endgroup% + \fi% + \pgfsetfillcolor{\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname}% + \pgfusepath{fill}% + \fi% + \fi% + \pgfextract@process\pgf@lib@sh@rs@fill@topright{% + \pgf@lib@sh@rs@fill@topright% + \pgf@xa=\pgf@x% + \pgf@lib@sh@rs@fill@bottomleft% + \pgf@x=\pgf@xa% + \advance\pgf@x by\outerxsep\relax% + }% + \repeatpgfmathloop% + \fi% + }% + \fi% + }% + \backgroundpath{% + \begingroup% + \pgfextract@process\southwest{% + \southwest% + \advance\pgf@x by\outerxsep\relax% + \advance\pgf@y by\outerysep\relax% + }% + \pgfextract@process\northeast{% + \northeast% + \advance\pgf@x by-\outerxsep\relax% + \advance\pgf@y by-\outerysep\relax% + }% + \pgfpathrectangle{\southwest}{\pgfpointdiff{\southwest}{\northeast}}% + \endgroup% + \ifpgfrectanglesplitdrawsplits% + \pgfmathloop% + \ifnum\pgfmathcounter=\parts% + \else% + \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}% + % + \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty% + \else% + \pgfpathmoveto{% + \ifpgfrectanglesplithorizontal% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@north\endcsname% + \advance\pgf@y by-\outerysep\relax% + \else% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@east\endcsname% + \advance\pgf@x by-\outerxsep\relax% + \fi% + }% + \pgfpathlineto{% + \ifpgfrectanglesplithorizontal% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@south\endcsname% + \advance\pgf@y by\outerysep\relax% + \else% + \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@west\endcsname% + \advance\pgf@x by\outerxsep\relax% + \fi% + }% + \fi% + \repeatpgfmathloop% + \fi% + }% + \anchorborder{% + \pgfutil@tempdima\pgf@x% + \pgfutil@tempdimb\pgf@y% + \rectanglesplitparameters% + \pgfpointdiff{\southwest}{\northeast}% + \pgf@x.5\pgf@x% + \pgf@y.5\pgf@y% + \edef\pgf@marshall{% + \noexpand\pgfpointborderrectangle{% + \noexpand\pgfqpoint{\the\pgfutil@tempdima}{\the\pgfutil@tempdimb}% + }% + {% + \noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}% + }% + }% + \pgf@marshall% + \pgf@xa\pgf@x% + \pgf@ya\pgf@y% + \centerpoint% + \advance\pgf@x\pgf@xa% + \advance\pgf@y\pgf@ya% + }% + % + % Hackery to install the correct number of node parts. + % + \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@rectangle split\endcsname{% + \let\pgf@lib@sh@rs@temp=\pgfutil@empty% + \pgfmathloop% + \ifnum\pgfmathcounter=\parts% + \expandafter\edef\csname pgf@sh@boxes@rectangle split\endcsname% + {\pgf@lib@sh@rs@temp\pgf@lib@sh@toalpha{\pgfmathcounter}}% + \else% + \edef\pgf@lib@sh@rs@temp{\pgf@lib@sh@rs@temp\pgf@lib@sh@toalpha{\pgfmathcounter},}% + \repeatpgfmathloop% + }% +} + +\pgfutil@for\pgf@lib@sh@rs@temp:={one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen,twenty}\do{% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp}{\noexpand\pgf@lib@sh@rs@anchor@one}% + {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split}% + {\noexpand\centerpoint}% + {\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split north\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@north}% + {\noexpand\csname pgf@anchor@rectangle split@north\noexpand\endcsname}% + {\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@north\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split south\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@south}% + {\noexpand\csname pgf@anchor@rectangle split@south\noexpand\endcsname}% + {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@south\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space north\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @north}% + {\noexpand\csname pgf@anchor@rectangle split@north\noexpand\endcsname}% + {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @north\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space south\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @south}% + {\noexpand\csname pgf@anchor@rectangle split@south\noexpand\endcsname}% + {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @south\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split east\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@east}% + {\noexpand\csname pgf@anchor@rectangle split@east\noexpand\endcsname}% + {\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@east\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split west\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@west}% + {\noexpand\csname pgf@anchor@rectangle split@west\noexpand\endcsname}% + {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@west\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space east\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @east}% + {\noexpand\csname pgf@anchor@rectangle split@east\noexpand\endcsname}% + {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @east\noexpand\endcsname}% + }% + \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space west\endcsname{% + \noexpand\rectanglesplitparameters% + \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @west}% + {\noexpand\csname pgf@anchor@rectangle split@west\noexpand\endcsname}% + {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @west\noexpand\endcsname}% + }% +}% + + +\pgfutil@namelet{pgf@anchor@rectangle split@text east}{pgf@anchor@rectangle split@one east} +\pgfutil@namelet{pgf@anchor@rectangle split@text west}{pgf@anchor@rectangle split@one west} +\pgfutil@namelet{pgf@anchor@rectangle split@text split}{pgf@anchor@rectangle split@one split} +\pgfutil@namelet{pgf@anchor@rectangle split@text split east}{pgf@anchor@rectangle split@one split east} +\pgfutil@namelet{pgf@anchor@rectangle split@text split west}{pgf@anchor@rectangle split@one split west} + +\pgfutil@namelet{pgf@anchor@rectangle split@second}{pgf@anchor@rectangle split@two} +\pgfutil@namelet{pgf@anchor@rectangle split@second east}{pgf@anchor@rectangle split@two east} +\pgfutil@namelet{pgf@anchor@rectangle split@second west}{pgf@anchor@rectangle split@two west} +\pgfutil@namelet{pgf@anchor@rectangle split@second split}{pgf@anchor@rectangle split@two split} +\pgfutil@namelet{pgf@anchor@rectangle split@second split east}{pgf@anchor@rectangle split@two split east} +\pgfutil@namelet{pgf@anchor@rectangle split@second split west}{pgf@anchor@rectangle split@two split west} + +\pgfutil@namelet{pgf@anchor@rectangle split@third}{pgf@anchor@rectangle split@three} +\pgfutil@namelet{pgf@anchor@rectangle split@third east}{pgf@anchor@rectangle split@three east} +\pgfutil@namelet{pgf@anchor@rectangle split@third west}{pgf@anchor@rectangle split@three west} +\pgfutil@namelet{pgf@anchor@rectangle split@third split}{pgf@anchor@rectangle split@three split} +\pgfutil@namelet{pgf@anchor@rectangle split@third split east}{pgf@anchor@rectangle split@three split east} +\pgfutil@namelet{pgf@anchor@rectangle split@third split west}{pgf@anchor@rectangle split@three split west} + +\pgfutil@namelet{pgf@anchor@rectangle split@fourth}{pgf@anchor@rectangle split@four} +\pgfutil@namelet{pgf@anchor@rectangle split@fourth east}{pgf@anchor@rectangle split@four east} +\pgfutil@namelet{pgf@anchor@rectangle split@fourth west}{pgf@anchor@rectangle split@four west} +\pgfutil@namelet{pgf@anchor@rectangle split@fourth split}{pgf@anchor@rectangle split@four split} +\pgfutil@namelet{pgf@anchor@rectangle split@fourth split east}{pgf@anchor@rectangle split@four split east} +\pgfutil@namelet{pgf@anchor@rectangle split@fourth split west}{pgf@anchor@rectangle split@four split west} + + + + +% Shape: ellipse split. +% +\pgfdeclareshape{ellipse split}{% + \nodeparts{text,lower} + \savedanchor\radii{% + \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}% + \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% + \pgf@y2.0\pgf@y% + \advance\pgf@y.5\pgflinewidth% + \pgf@xa.5\wd\pgfnodeparttextbox% + \pgf@xb.5\wd\pgfnodepartlowerbox% + \advance\pgf@xa\pgf@x% + \advance\pgf@xb\pgf@x% + \pgf@ya\ht\pgfnodeparttextbox% + \advance\pgf@ya\dp\pgfnodeparttextbox% + \pgf@yb\ht\pgfnodepartlowerbox% + \advance\pgf@yb\dp\pgfnodepartlowerbox% + \advance\pgf@ya\pgf@y% + \advance\pgf@yb\pgf@y% + \ifdim\pgf@xa>\pgf@xb% + \pgf@x1.414213\pgf@xa% + \else% + \pgf@x1.414213\pgf@xb% + \fi% + \ifdim\pgf@ya>\pgf@yb% + \pgf@y1.414213\pgf@ya% + \else% + \pgf@y1.414213\pgf@yb% + \fi% + \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}% + \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}% + \ifdim\pgf@x<.5\pgf@xa% + \pgf@x.5\pgf@xa% + \fi% + \ifdim\pgf@y<.5\pgf@ya% + \pgf@y.5\pgf@ya% + \fi% + \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}% + } + \savedanchor\lower{% + \pgf@x-.5\wd\pgfnodepartlowerbox% + \advance\pgf@x.5\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% + \pgf@y-2.0\pgf@y% + \advance\pgf@y-\pgflinewidth% + \advance\pgf@y-\dp\pgfnodeparttextbox% + \advance\pgf@y-\ht\pgfnodepartlowerbox% + } + \savedanchor\centerpoint{% + \pgf@x.5\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@y{-\pgfkeysvalueof{/pgf/inner ysep}}% + \advance\pgf@y-\dp\pgfnodeparttextbox% + \advance\pgf@y-.5\pgflinewidth% + }% + \savedanchor\basepoint{% + \pgf@x.5\wd\pgfnodeparttextbox% + \pgf@y0pt\relax% + }% + \savedanchor\midpoint{% + \pgf@x.5\wd\pgfnodeparttextbox% + \pgfmathsetlength\pgf@y{.5ex}% + }% + \anchor{center}{\centerpoint} + \anchor{lower}{\lower} + \anchor{mid}{\midpoint} + \anchor{mid east}{\radii\pgf@xa\pgf@x\midpoint\advance\pgf@x\pgf@xa} + \anchor{mid west}{\radii\pgf@xa\pgf@x\midpoint\advance\pgf@x-\pgf@xa} + \anchor{base}{\basepoint} + \anchor{base east}{\radii\pgf@xa\pgf@x\basepoint\advance\pgf@x\pgf@xa} + \anchor{base west}{\radii\pgf@xa\pgf@x\basepoint\advance\pgf@x-\pgf@xa} + \anchor{north}{\pgfpointadd{\centerpoint}{\radii\pgf@x0pt}}% + \anchor{south}{\pgfpointadd{\centerpoint}{\radii\pgf@x0pt\pgf@y-\pgf@y}}% + \anchor{east}{\pgfpointadd{\centerpoint}{\radii\pgf@y0pt}}% + \anchor{west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-\pgf@x\pgf@y0pt}}% + \anchor{north west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-0.707106\pgf@x\pgf@y0.707106\pgf@y}}% + \anchor{south west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-0.707106\pgf@x\pgf@y-0.707106\pgf@y}}% + \anchor{north east}{\pgfpointadd{\centerpoint}{\radii\pgf@x0.707106\pgf@x\pgf@y0.707106\pgf@y}}% + \anchor{south east}{\pgfpointadd{\centerpoint}{\radii\pgf@x0.707106\pgf@x\pgf@y-0.707106\pgf@y}}% + \backgroundpath{% + \radii% + \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}% + \pgfutil@tempdima\pgf@x% + \pgfutil@tempdimb\pgf@y% + \pgfpathellipse{\centerpoint}{\pgfqpoint{\the\pgfutil@tempdima}{0pt}}{\pgfqpoint{0pt}{\the\pgfutil@tempdimb}}% + \pgfpathmoveto{\centerpoint\advance\pgf@x-\pgfutil@tempdima}% + \pgfpathlineto{\centerpoint\advance\pgf@x\pgfutil@tempdima}% + } + \anchorborder{% + \pgfextract@process\externalpoint{}% + \radii% + \edef\pgf@marshal{% + \noexpand\pgfpointadd{\noexpand\pgfpointborderellipse{\noexpand\externalpoint}% + {\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}}{\noexpand\centerpoint}% + }% + \pgf@marshal% + }% +} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.symbols.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.symbols.code.tex index 152ee00c4fb..b419a8cb624 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.symbols.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.symbols.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.symbols.code.tex,v 1.13 2008/01/30 07:56:38 vibrovski Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/shapes/pgflibraryshapes.symbols.code.tex,v 1.3 2009/10/27 23:03:12 tantau Exp $ \pgfdeclareshape{forbidden sign} { @@ -1377,72 +1377,56 @@ % Internal macros for signal shape. % -\def\pgf@lib@shapes@signal@nowhere{nowhere}% -\def\pgf@lib@shapes@signal@from{from}% -\def\pgf@lib@shapes@signal@to{to}% +\def\pgf@lib@sh@signal@nowhere{nowhere}% +\def\pgf@lib@sh@signal@from{from}% +\def\pgf@lib@sh@signal@to{to}% -\let\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@nowhere% -\let\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@nowhere% -\let\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@nowhere% -\let\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@nowhere% +\def\pgf@lib@sh@signal@parsedirection#1#2{% + % + \let\pgf@lib@sh@signal@direction=#2% + \edef\pgf@lib@sh@temp{#1}% + \expandafter\pgf@lib@sh@signal@@parsedirection\pgf@lib@sh@temp\pgf@stop} -\def\pgf@lib@shapes@signal@parsedirection#1#2{% - \let\pgf@lib@shapes@signal@direction#2% +\def\pgf@lib@sh@signal@@parsedirection#1\pgf@stop{% \pgfutil@in@{and}{#1}% \ifpgfutil@in@% - \pgf@lib@shapes@signal@@parsedirection#1\pgf@lib% + \pgf@lib@sh@signal@@@parsedirection#1\pgf@lib% \else% - \pgf@lib@shapes@signal@@parsedirection#1 and #1\pgf@lib% + \pgf@lib@sh@signal@@@parsedirection#1 and #1\pgf@lib% \fi } -\def\pgf@lib@shapes@signal@@parsedirection#1 and #2\pgf@lib{% +\def\pgf@lib@sh@signal@@@parsedirection#1 and #2\pgf@lib{% \pgfutil@in@{nowhere}{#1}% \ifpgfutil@in@ - \pgf@lib@shapes@signal@@donowhere% \else% - \pgf@lib@shapes@signal@@@parsedirection{#1}% - \pgf@lib@shapes@signal@@@parsedirection{#2}% + \pgf@lib@sh@signal@@@@parsedirection{#1}% + \pgf@lib@sh@signal@@@@parsedirection{#2}% \fi% } -\def\pgf@lib@shapes@signal@@@parsedirection#1{% +\def\pgf@lib@sh@signal@@@@parsedirection#1{% \pgfutil@in@{ #1 }{ east right }% \ifpgfutil@in@% - \let\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@direction% - \let\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@nowhere% - \let\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@nowhere% + \let\pgf@lib@sh@signal@east=\pgf@lib@sh@signal@direction% + \let\pgf@lib@sh@signal@north=\pgf@lib@sh@signal@nowhere% + \let\pgf@lib@sh@signal@south=\pgf@lib@sh@signal@nowhere% \fi% \pgfutil@in@{ #1 }{ left west }% \ifpgfutil@in@% - \let\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@direction% - \let\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@nowhere% - \let\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@nowhere% + \let\pgf@lib@sh@signal@west=\pgf@lib@sh@signal@direction% + \let\pgf@lib@sh@signal@north=\pgf@lib@sh@signal@nowhere% + \let\pgf@lib@sh@signal@south=\pgf@lib@sh@signal@nowhere% \fi% \pgfutil@in@{ #1 }{ above up north }% \ifpgfutil@in@% - \let\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@direction% - \let\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@nowhere% - \let\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@nowhere% + \let\pgf@lib@sh@signal@north=\pgf@lib@sh@signal@direction% + \let\pgf@lib@sh@signal@east=\pgf@lib@sh@signal@nowhere% + \let\pgf@lib@sh@signal@west=\pgf@lib@sh@signal@nowhere% \fi% \pgfutil@in@{ #1 }{ below down south }% \ifpgfutil@in@% - \let\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@direction% - \let\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@nowhere% - \let\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@nowhere% - \fi% -} - -\def\pgf@lib@shapes@signal@@donowhere{% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@direction% - \pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@nowhere% - \fi% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@direction% - \pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@nowhere% - \fi% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@direction% - \pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@nowhere% - \fi% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@direction% - \pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@nowhere% + \let\pgf@lib@sh@signal@south=\pgf@lib@sh@signal@direction% + \let\pgf@lib@sh@signal@east=\pgf@lib@sh@signal@nowhere% + \let\pgf@lib@sh@signal@west=\pgf@lib@sh@signal@nowhere% \fi% } @@ -1451,23 +1435,21 @@ % \pgfkeys{/pgf/.cd, signal pointer angle/.initial=90, - signal from/.code={\pgf@lib@shapes@signal@parsedirection{#1}{\pgf@lib@shapes@signal@from}}, - signal to/.code={\pgf@lib@shapes@signal@parsedirection{#1}{\pgf@lib@shapes@signal@to}} -} - - -\pgfkeys{/pgf/.cd, - signal to=east, - signal from=nowhere + signal to/.initial=east, + signal from/.initial=nowhere } - -% Shape signal -% -% \pgfdeclareshape{signal}{% \savedmacro\installsignalparameters{% % + \let\pgf@lib@sh@signal@north=\pgf@lib@sh@signal@nowhere% + \let\pgf@lib@sh@signal@south=\pgf@lib@sh@signal@nowhere% + \let\pgf@lib@sh@signal@east=\pgf@lib@sh@signal@nowhere% + \let\pgf@lib@sh@signal@west=\pgf@lib@sh@signal@nowhere% + % + \pgf@lib@sh@signal@parsedirection{\pgfkeysvalueof{/pgf/signal from}}{\pgf@lib@sh@signal@from}% + \pgf@lib@sh@signal@parsedirection{\pgfkeysvalueof{/pgf/signal to}}{\pgf@lib@sh@signal@to}% + % % Define a centerpoint. % \pgfextract@process\centerpoint{% @@ -1479,16 +1461,22 @@ % Get some useful trig. stuff % \pgfmathsetmacro\pointerangle{\pgfkeysvalueof{/pgf/signal pointer angle}}% + % \pgfmathdivide@{\pointerangle}{2}% - \let\halfpointerangle\pgfmathresult% + \let\halfpointerangle=\pgfmathresult% + % \pgfmathcosec@{\halfpointerangle}% - \let\cosechalfpointerangle\pgfmathresult% + \let\cosechalfpointerangle=\pgfmathresult% + % \pgfmathdivide@{\halfpointerangle}{2}% - \let\quarterpointerangle\pgfmathresult% + \let\quarterpointerangle=\pgfmathresult% + % \pgfmathcosec@{\quarterpointerangle}% - \let\cosecquarterpointerangle\pgfmathresult% + \let\cosecquarterpointerangle=\pgfmathresult% + % \pgfmathsec@{\quarterpointerangle}% - \let\secquarterpointerangle\pgfmathresult% + \let\secquarterpointerangle=\pgfmathresult% + % \pgfmathsubtract@{90}{\quarterpointerangle}% \let\complementquarterpointerangle\pgfmathresult% % @@ -1499,21 +1487,21 @@ \ifdim\pgf@x>\pgf@y% \pgf@y\pgf@x% \fi% - \pgf@yc\pgf@y% + \pgf@yc=\pgf@y% % % Calculate the miter due to the line width, at the pointer apex... % - \pgf@x\cosechalfpointerangle\pgf@y% + \pgf@x=\cosechalfpointerangle\pgf@y% \edef\pointerapexmiter{\the\pgf@x}% % % ...at a corner by a `to' pointer (i.e. sticks out)... % - \pgf@x\secquarterpointerangle\pgf@y% + \pgf@x=\secquarterpointerangle\pgf@y% \edef\tocornermiter{\the\pgf@x}% % % ...at a corner by a `from' pointer (i.e. sticks in). % - \pgf@x\cosecquarterpointerangle\pgf@y + \pgf@x=\cosecquarterpointerangle\pgf@y \edef\fromcornermiter{\the\pgf@x}% % % Get the (half) dimensions of the node. @@ -1528,52 +1516,67 @@ % \pgfmathsubtract@{90}{\halfpointerangle}% \pgfmathtan@{\pgfmathresult}% - \pgf@xb\pgfmathresult\pgf@ya% + \pgf@xb=\pgfmathresult\pgf@ya% % % ...and up. % - \pgf@yb\pgfmathresult\pgf@xa% + \pgf@yb=\pgfmathresult\pgf@xa% % % Adjust for minimum height. % - \pgfutil@tempdima2.0\pgf@ya% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@nowhere% + \pgfutil@tempdima=2.0\pgf@ya% + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@nowhere% \else% - \advance\pgfutil@tempdima\pgf@yb% + \advance\pgfutil@tempdima by\pgf@yb% \fi% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@nowhere% \else% - \advance\pgfutil@tempdima\pgf@yb% + \advance\pgfutil@tempdima by\pgf@yb% \fi% \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/minimum height}}% \ifdim\pgfutil@tempdima<\pgf@y% - \pgfmathreciprocal@{\pgfmath@tonumber{\pgfutil@tempdima}}% - \pgfutil@tempdima\pgfmathresult\pgf@y% - \pgf@xa\pgfmath@tonumber{\pgfutil@tempdima}\pgf@xa% - \pgf@ya\pgfmath@tonumber{\pgfutil@tempdima}\pgf@ya% - \pgf@xb\pgfmath@tonumber{\pgfutil@tempdima}\pgf@xb% - \pgf@yb\pgfmath@tonumber{\pgfutil@tempdima}\pgf@yb% + \pgfutil@tempdima=\pgf@y% + % + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@nowhere% + \else% + \advance\pgfutil@tempdima by-\pgf@yb% + \fi% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@nowhere% + \else% + \advance\pgfutil@tempdima by-\pgf@yb% + \fi% + \pgf@ya=0.5\pgfutil@tempdima% + \pgfmathsubtract@{90}{\halfpointerangle}% + \pgfmathtan@{\pgfmathresult}% + \pgf@xb=\pgfmathresult\pgf@ya% \fi% % % Adjust for minimum width. % - \pgfutil@tempdima2.0\pgf@xa% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@nowhere% + \pgfutil@tempdima=2.0\pgf@xa% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere% \else% - \advance\pgfutil@tempdima\pgf@xb% + \advance\pgfutil@tempdima by\pgf@xb% \fi% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere% \else% - \advance\pgfutil@tempdima\pgf@xb% + \advance\pgfutil@tempdima by\pgf@xb% \fi% \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/minimum width}}% \ifdim\pgfutil@tempdima<\pgf@x% - \pgfmathreciprocal@{\pgfmath@tonumber{\pgfutil@tempdima}}% - \pgfutil@tempdima\pgfmathresult\pgf@x% - \pgf@xa\pgfmath@tonumber{\pgfutil@tempdima}\pgf@xa% - \pgf@ya\pgfmath@tonumber{\pgfutil@tempdima}\pgf@ya% - \pgf@xb\pgfmath@tonumber{\pgfutil@tempdima}\pgf@xb% - \pgf@yb\pgfmath@tonumber{\pgfutil@tempdima}\pgf@yb% + \pgfutil@tempdima=\pgf@x% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere% + \else% + \advance\pgfutil@tempdima by-\pgf@xb% + \fi% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere% + \else% + \advance\pgfutil@tempdima by-\pgf@xb% + \fi% + \pgf@xa=0.5\pgfutil@tempdima% + \pgfmathsubtract@{90}{\halfpointerangle}% + \pgfmathtan@{\pgfmathresult}% + \pgf@yb=\pgfmathresult\pgf@xa% \fi% % % So, define the points for the background path. @@ -1581,28 +1584,28 @@ \pgfextract@process\north{% \centerpoint% \advance\pgf@y\pgf@ya% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@to% \advance\pgf@y\pgf@yb% \fi% }% \pgfextract@process\south{% \centerpoint% \advance\pgf@y-\pgf@ya% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@to% \advance\pgf@y-\pgf@yb% \fi% }% \pgfextract@process\east{% \centerpoint% \advance\pgf@x\pgf@xa% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@to% \advance\pgf@x\pgf@xb% \fi% }% \pgfextract@process\west{% \centerpoint% \advance\pgf@x-\pgf@xa% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@to% \advance\pgf@x-\pgf@xb% \fi% }% @@ -1610,10 +1613,10 @@ \centerpoint% \advance\pgf@y\pgf@ya% \advance\pgf@x\pgf@xa% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@from% \advance\pgf@y\pgf@yb% \fi% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@from% \advance\pgf@x\pgf@xb% \fi% }% @@ -1621,10 +1624,10 @@ \centerpoint% \advance\pgf@y-\pgf@ya% \advance\pgf@x\pgf@xa% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@from% \advance\pgf@y-\pgf@yb% \fi% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@from% \advance\pgf@x\pgf@xb% \fi% }% @@ -1632,10 +1635,10 @@ \centerpoint% \advance\pgf@y-\pgf@ya% \advance\pgf@x-\pgf@xa% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@from% \advance\pgf@y-\pgf@yb% \fi% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@from% \advance\pgf@x-\pgf@xb% \fi% }% @@ -1643,10 +1646,10 @@ \centerpoint% \advance\pgf@y\pgf@ya% \advance\pgf@x-\pgf@xa% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@from% \advance\pgf@y\pgf@yb% \fi% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@from% \advance\pgf@x-\pgf@xb% \fi% }% @@ -1663,7 +1666,7 @@ % \pgfextract@process\northmiter{% \pgf@x0pt% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@nowhere% \pgf@y\pgf@yc% \else% \pgf@y\pointerapexmiter\relax% @@ -1671,7 +1674,7 @@ }% \pgfextract@process\southmiter{% \pgf@x0pt% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@nowhere% \pgf@y-\pgf@yc% \else% \pgf@y-\pointerapexmiter\relax% @@ -1679,7 +1682,7 @@ }% \pgfextract@process\eastmiter{% \pgf@y0pt% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere% \pgf@x\pgf@yc% \else% \pgf@x\pointerapexmiter\relax% @@ -1687,99 +1690,99 @@ }% \pgfextract@process\westmiter{% \pgf@y0pt% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere% \pgf@x-\pgf@yc% \else% \pgf@x-\pointerapexmiter\relax% \fi% }% \pgfextract@process\northeastmiter{% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere% \pgf@x\pgf@yc \pgf@y\pgf@yc% \else - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@from% \pgfqpointpolar{\quarterpointerangle}{\fromcornermiter} \else% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@to% \pgfqpointpolar{\complementquarterpointerangle}{\tocornermiter}% \fi% \fi% \fi% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@from% \pgfqpointpolar{\complementquarterpointerangle}{\fromcornermiter}% \else% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@to% \pgfqpointpolar{\quarterpointerangle}{\tocornermiter}% \fi% \fi% }% \pgfextract@process\southeastmiter{% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere% \pgf@x\pgf@yc% \pgf@y\pgf@yc% \else - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@from% \pgfqpointpolar{-\quarterpointerangle}{\fromcornermiter} \else% - \ifx\pgf@lib@shapes@signal@east\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@to% \pgfqpointpolar{-\complementquarterpointerangle}{\tocornermiter}% \fi% \fi% \fi% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@from% \pgfqpointpolar{-\complementquarterpointerangle}{\fromcornermiter} \else% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@to% \pgfqpointpolar{-\quarterpointerangle}{\tocornermiter}% \fi% \fi% }% \pgfextract@process\southwestmiter{% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere% \pgf@x-\pgf@yc \pgf@y-\pgf@yc% \else - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@from% \pgfmathadd@{\quarterpointerangle}{180}% \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\fromcornermiter} \else% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@to% \pgfmathadd@{\complementquarterpointerangle}{180}% \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\tocornermiter}% \fi% \fi% \fi% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@from% \pgfmathadd@{\complementquarterpointerangle}{180}% \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\fromcornermiter}% \else% - \ifx\pgf@lib@shapes@signal@south\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@to% \pgfmathadd@{\quarterpointerangle}{180}% \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\tocornermiter}% \fi% \fi% }% \pgfextract@process\northwestmiter{% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@nowhere% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere% \pgf@x-\pgf@yc% \pgf@y\pgf@yc% \else - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@from% \pgfmathsubtract@{180}{\quarterpointerangle}% \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\fromcornermiter} \else% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@to% \pgfmathsubtract@{180}{\complementquarterpointerangle}% \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\tocornermiter}% \fi% \fi% \fi% - \ifx\pgf@lib@shapes@signal@north\pgf@lib@shapes@signal@from% + \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@from% \pgfmathsubtract@{180}{\complementquarterpointerangle}% \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\fromcornermiter}% \else% - \ifx\pgf@lib@shapes@signal@west\pgf@lib@shapes@signal@to% + \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@to% \pgfmathsubtract@{180}{\quarterpointerangle}% \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\tocornermiter}% \fi% @@ -2051,7 +2054,6 @@ - % Keys for shape tape % % /pgf/tape bend top : Type of bend for north side. @@ -2510,4 +2512,60 @@ \fi% \fi% }% -}
\ No newline at end of file +} + + + + +% Keys for magnifying glass shape +% +% /pgf/magnifying glass handle angle : The angle of handle +% /pgf/magnifying glass handle aspect : The length of the handle as a multiple +% of the radius of the circle +% + +\pgfkeys{/pgf/.cd, + magnifying glass handle angle/.initial=-45, + magnifying glass handle aspect/.initial=1.5 +} + +\pgfdeclareshape{magnifying glass} +{ + \inheritsavedanchors[from=circle] % this is nearly a circle + \inheritanchorborder[from=circle] + \inheritanchor[from=circle]{north} + \inheritanchor[from=circle]{north west} + \inheritanchor[from=circle]{north east} + \inheritanchor[from=circle]{center} + \inheritanchor[from=circle]{west} + \inheritanchor[from=circle]{east} + \inheritanchor[from=circle]{mid} + \inheritanchor[from=circle]{mid west} + \inheritanchor[from=circle]{mid east} + \inheritanchor[from=circle]{base} + \inheritanchor[from=circle]{base west} + \inheritanchor[from=circle]{base east} + \inheritanchor[from=circle]{south} + \inheritanchor[from=circle]{south west} + \inheritanchor[from=circle]{south east} + \inheritbackgroundpath[from=circle] + \foregroundpath{ + \centerpoint% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgfutil@tempdima=\radius% + \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}% + \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}% + \ifdim\pgf@xb<\pgf@yb% + \advance\pgfutil@tempdima by-\pgf@yb% + \else% + \advance\pgfutil@tempdima by-\pgf@xb% + \fi% + \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}} + {\pgfpointpolar{\pgfkeysvalueof{/pgf/magnifying glass handle angle}}{\pgfutil@tempdima}}} + \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}} + {\pgfpointpolar{\pgfkeysvalueof{/pgf/magnifying glass handle angle}}{\pgfutil@tempdima+\pgfutil@tempdima*(\pgfkeysvalueof{/pgf/magnifying glass handle aspect})}}} + } +} + + |