summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex177
1 files changed, 156 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex
index 6446027318f..8f60ef1e6b9 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex
@@ -86,8 +86,10 @@
\immediate\write16{Package pgfplots: loading complementary 'name path' implementation for your pgf version...}
\let\tikz@key@name@path=\tikz@key@name@path@new
\fi
+
% ------------------------------------------------------------
+\newif\iftikzfillbetween@optimize@name@intersections
\pgfkeys{%
/tikz/fill between/of/.code=\tikzlibraryfillbetween@parse#1\pgf@stop,
@@ -96,6 +98,12 @@
/tikz/fill between/every segment/.style={},
/tikz/fill between/every odd segment/.style={},
/tikz/fill between/every even segment/.style={},
+ /tikz/fill between/every last segment/.style={},
+ %
+ % Allows to add path instructions *after* the segment.
+ % If you want to add some *before* the segment, you can rely on
+ % 'every segment no 0/.style={ ... suitable tikz options ... }'
+ /tikz/fill between/path after segment/.initial={},
%
% soft clip={(axis cs:0,0) rectangle (axis cs:1,1)}
/tikz/fill between/soft clip/.style={
@@ -109,6 +117,10 @@
/tikz/fill between/@draw style/.style={
/pgf/fill between/result stream/begin/.code={%
\gdef\tikzsegmentindex{0}%
+ \xdef\tikzsegmentindices{##1}%
+ \c@pgf@countc=##1 %
+ \advance\c@pgf@countc by-1 %
+ \xdef\tikzsegmentlastindex{\the\c@pgf@countc}%
},%
/pgf/fill between/result stream/next ready/.code={%
\let\pgflibraryfill@path=\pgfretval
@@ -127,13 +139,30 @@
}%
\fi
%
+ \ifnum\tikzsegmentindex=\tikzsegmentlastindex\relax
+ \expandafter\def\expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@loc@TMPa
+ /tikz/fill between/every last segment,
+ }%
+ \fi
+ %
\expandafter\fill\expandafter[\pgfplots@loc@TMPa]
- \pgfextra \pgfsetpathandBB{\pgflibraryfill@path}\endpgfextra;%
+ \pgfextra
+ \pgfsetpathandBB{\pgflibraryfill@path}%
+ \pgfkeysgetvalue{/tikz/fill between/path after segment}\tikz@fillbetween@post@segment
+ \expandafter
+ \endpgfextra
+ \tikz@fillbetween@post@segment
+ ;%
\pgfplotsutil@advancestringcounter@global\tikzsegmentindex
},%
/pgf/fill between/result stream/end/.code=,%
},
/tikz/fill between/.search also={/pgf/fill between,/pgfplots},
+ /tikz/fill between/optimize name intersections/.is if=tikzfillbetween@optimize@name@intersections,
+ %
+ % FIXME : this optimization needs much more work... I believe it
+ % would be stable enough, but it covers too few cases.
+ %/tikz/fill between/optimize name intersections=true,
%
%
%
@@ -252,6 +281,12 @@
\expandafter\let\expandafter\tikz@fillbetween@b@path
\csname tikz@intersect@path@name@\tikz@fillbetween@b\endcsname
%
+ \iftikzfillbetween@optimize@name@intersections
+ \ifpgfpathfillbetween@split
+ \tikzfillbetween@optimize@name@intersections\tikz@fillbetween@a\tikz@fillbetween@b
+ \fi
+ \fi
+ %
\pgfpathfillbetween{\tikz@fillbetween@a@path}{\tikz@fillbetween@b@path}%
}%
@@ -330,18 +365,27 @@
% compute intersections using the PGF intersection lib...
\pgfintersectionofpaths{\pgfsetpath\tikz@path@segments@A}{\pgfsetpath\tikz@path@segments@B}%
%
- % ... and compute the intersection *segments* for both input
- % paths...
- \pgfcomputeintersectionsegments1%
- \pgfcomputeintersectionsegments2%
+ \ifnum\pgfintersectionsolutions=0 %
+ \pgferror{The argument of 'sequence' requests an intersection segment -- but the two input paths do not intersect. Please use A* or B* to select the whole path}%
+ \def\b@tikz@select@all{1}%
+ \else
+ %
+ % ... and compute the intersection *segments* for both input
+ % paths...
+ \pgfcomputeintersectionsegments1%
+ \pgfcomputeintersectionsegments2%
+ \fi
\let\tikz@ensurehascomputedintersection=\relax
}%
%
\pgfkeysgetvalue{/tikz/segments/sequence}\tikz@sequence
%
\def\b@tikz@isect@nextismoveto{1}%
+ \let\pgfpointlastofsetpath=\pgfutil@empty
\expandafter\tikzpathintersectionsegments@parse@loop\tikz@sequence\pgf@stop
+ \pgfmath@smuggleone\pgfpointlastofsetpath
\endgroup
+ \tikz@make@last@position{\pgfpointlastofsetpath}%
}%
\def\tikzpathintersectionsegments@parse@loop{%
@@ -354,10 +398,18 @@
\pgfutil@ifnextchar B{%
\tikz@isect@p@next
}{%
- \pgfutil@ifnextchar\pgf@stop{%
- \tikz@isect@finish
+ \pgfutil@ifnextchar L{%
+ \tikz@isect@p@next
}{%
- \tikz@isect@p@error
+ \pgfutil@ifnextchar R{%
+ \tikz@isect@p@next
+ }{%
+ \pgfutil@ifnextchar\pgf@stop{%
+ \tikz@isect@finish
+ }{%
+ \tikz@isect@p@error
+ }%
+ }%
}%
}%
}%
@@ -376,12 +428,25 @@
}
\def\tikz@isect@p@next#1#2{%
+ \def\tikz@temp{#2}%
+ \def\tikz@@temp{-}%
+ \ifx\tikz@@temp\tikz@temp
+ % also accept minus signs without curly braces, i.e.
+ % L-2 instead of L{-2}
+ \def\tikz@next{\tikz@isect@p@next@{#1}{#2}}%
+ \else
+ \def\tikz@next{\tikz@isect@p@next@{#1}{#2}{}}%
+ \fi
+ \tikz@next
+}%
+\def\tikz@isect@p@next@#1#2#3{%
\pgfutil@ifnextchar[{%
- \tikz@isect@p@next@opt{#1}{#2}%
+ \tikz@isect@p@next@opt{#1}{#2#3}%
}{%
- \tikz@isect@p@next@opt{#1}{#2}[]%
+ \tikz@isect@p@next@opt{#1}{#2#3}[]%
}%
}%
+
\def\tikz@isect@p@next@opt#1#2[#3]{%
\begingroup
%
@@ -392,8 +457,38 @@
\pgfqkeys{/tikz/segments}{#3}%
\fi
%
+ \def\tikz@indexshift{}%
+ \if A#1%
+ % FIRST function (0-based index)
+ \def\tikz@path{1}%
+ \def\tikz@path@ab{A}%
+ \else
+ \if B#1%
+ % SECOND function (0-based index)
+ \def\tikz@path{2}%
+ \def\tikz@path@ab{B}%
+ \else
+ \if L#1%
+ % FIRST function (1-based index)
+ \def\tikz@path{1}%
+ \def\tikz@indexshift{-1}%
+ \def\tikz@path@ab{A}%
+ \else
+ \if R#1%
+ % SECOND function (1-based index)
+ \def\tikz@path{2}%
+ \def\tikz@indexshift{-1}%
+ \def\tikz@path@ab{B}%
+ \else
+ \def\tikz@path{}%
+ \pgferror{The argument of 'sequence' has an unexpected format near '#1#2': expected L#2 or R#2}%
+ \fi
+ \fi
+ \fi
+ \fi
+ %
% parse arguments:
- \edef\pgfmathresult{#2}%
+ \def\pgfmathresult{#2}%
\def\tikz@temp{*}%
\ifx\pgfmathresult\tikz@temp
\def\b@tikz@select@all{1}%
@@ -402,27 +497,29 @@
\tikz@ensurehascomputedintersection
\pgfmathparse{round(#2)}%
\let\tikz@index=\pgfmathresult
- \fi
- %
- \if A#1%
- \def\tikz@path{1}%
- \else
- \if B#1%
- \def\tikz@path{2}%
+ \ifx\tikz@indexshift\pgfutil@empty
\else
- \def\tikz@path{}%
- \pgferror{The argument of 'sequence' has an unexpected format near '#1#2': expected A#2 or B#2}%
+ \afterassignment\pgfutil@gobble@until@relax
+ \c@pgf@countc=\tikz@index\relax
+ \ifnum\c@pgf@countc<0 \else
+ % the index shift is ONLY for positive numbers: we
+ % want to start indexing at 1, not at 0 -- and the
+ % negative ones start at -1 anyway.
+ \advance\c@pgf@countc by\tikz@indexshift\relax
+ \edef\tikz@index{\the\c@pgf@countc}%
+ \fi
\fi
\fi
%
%
% PROCESS IT:
\ifx\tikz@path\pgfutil@empty
+ \let\pgfpointlastofsetpath=\pgfutil@empty
\else
\if1\b@tikz@select@all%
% ok... select the *entire* path.
% #1 = A|B :
- \expandafter\let\expandafter\pgfretval\csname tikz@path@segments@#1\endcsname
+ \expandafter\let\expandafter\pgfretval\csname tikz@path@segments@\tikz@path@ab\endcsname
\else
\pgfgetintersectionsegmentpath{\tikz@path}{\tikz@index}%
\fi
@@ -434,9 +531,47 @@
\fi
\pgfaddpathandBB\pgfretval
\fi
+ \pgfmath@smuggleone\pgfpointlastofsetpath
\endgroup
\def\b@tikz@isect@nextismoveto{1}%
\tikzpathintersectionsegments@parse@loop
}%
+\def\tikzfillbetween@optimize@name@intersections#1#2{%
+ \edef\tikzfillbetween@precached@intersectionofpaths@A{#1}%
+ \edef\tikzfillbetween@precached@intersectionofpaths@B{#2}%
+ \pgfkeys{%
+ /tikz/name intersections/.add code={%
+ \let\pgfintersectionofpaths=\tikzfillbetween@precached@intersectionofpaths
+ }{%
+ \let\pgfintersectionofpaths=\pgfintersectionofpaths@orig
+ }
+ }%
+}%
+
+\let\pgfintersectionofpaths@orig=\pgfintersectionofpaths
+
+\def\tikzfillbetween@precached@intersectionofpaths@log{%
+ \immediate\write-1{fill between: outcome of 'name intersections={of=\tikz@intersect@path@a\space and \tikz@intersect@path@b}' has been computed from available information of fill between}%
+}
+\def\tikzfillbetween@precached@intersectionofpaths#1#2{%
+ \def\pgf@loc@TMPa{0}%
+ \ifx\tikz@intersect@path@a\tikzfillbetween@precached@intersectionofpaths@A
+ \ifx\tikz@intersect@path@b\tikzfillbetween@precached@intersectionofpaths@B
+ \def\pgf@loc@TMPa{1}%
+ \fi
+ \fi
+ \ifx\tikz@intersect@path@b\tikzfillbetween@precached@intersectionofpaths@A
+ \ifx\tikz@intersect@path@a\tikzfillbetween@precached@intersectionofpaths@B
+ \def\pgf@loc@TMPa{1}%
+ \fi
+ \fi
+ %
+ \if1\pgf@loc@TMPa
+ \tikzfillbetween@precached@intersectionofpaths@log
+ \relax
+ \else
+ \pgfintersectionofpaths@orig{#1}{#2}%
+ \fi
+}%
\endinput