| 1 |
% Copyright 2013 by Christian Feuersaenger |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Free Documentation License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
|
| 11 |
\usepgflibrary{intersections} |
| 12 |
|
| 13 |
\pgfutil@IfUndefined{pgf@intersections@version}{% |
| 14 |
\input pgfplotsoldpgfsupp_pgflibraryintersections.code.tex |
| 15 |
}{% |
| 16 |
}% |
| 17 |
|
| 18 |
% FIXME : ARCHITECTURE VIOLATION: REQUIRES |
| 19 |
% \usetikzlibrary{decorations.softclip} |
| 20 |
% |
| 21 |
%\usepgfmodule{decorations} |
| 22 |
|
| 23 |
\newif\ifpgfpathfillbetween@split |
| 24 |
|
| 25 |
\pgfkeys{% |
| 26 |
/pgf/fill between/reverse/.is choice, |
| 27 |
/pgf/fill between/reverse/.default=true, |
| 28 |
/pgf/fill between/reverse/false/.code=\def\pgfpathfillbetween@reverse@mode{0},% |
| 29 |
/pgf/fill between/reverse/true/.code=\def\pgfpathfillbetween@reverse@mode{1},% |
| 30 |
% |
| 31 |
% checks the coordinates of the first two path instructions as heuristics: |
| 32 |
/pgf/fill between/reverse/auto/.code=\def\pgfpathfillbetween@reverse@mode{2},% |
| 33 |
/pgf/fill between/reverse/auto, |
| 34 |
/pgf/fill between/inner moveto/.is choice, |
| 35 |
/pgf/fill between/inner moveto/connect/.code=\def\pgfpathfillbetween@inner@moveto{1}, |
| 36 |
/pgf/fill between/inner moveto/keep/.code=\def\pgfpathfillbetween@inner@moveto{2}, |
| 37 |
/pgf/fill between/inner moveto/connect, |
| 38 |
% |
| 39 |
% split=true allows to generate individual result paths for every |
| 40 |
% region induced by the intersection points. Example: |
| 41 |
% "color positive region in red and negative region in green". |
| 42 |
% The case split=false results in just one output path |
| 43 |
% (simpler+faster, but of course less powerful). |
| 44 |
/pgf/fill between/split/.is if=pgfpathfillbetween@split, |
| 45 |
/pgf/fill between/split/.default=true, |
| 46 |
% |
| 47 |
% Used to report results. This is mainly useful in conjunction |
| 48 |
% with split=true: each result segment will be streamed. |
| 49 |
% |
| 50 |
% Results are reported in the sequence |
| 51 |
% begin |
| 52 |
% next ready |
| 53 |
% next ready |
| 54 |
% ... |
| 55 |
% end |
| 56 |
% |
| 57 |
% 'begin' has one arguments: the number of following single |
| 58 |
% streams. |
| 59 |
/pgf/fill between/result stream/begin/.code=,% |
| 60 |
% |
| 61 |
% 'next ready' has macro arguments, but the macro \pgfretval |
| 62 |
% contains the lowlevel path as result (i.e. you can write |
| 63 |
% \pgfsetpath\pgfretval to activate it). |
| 64 |
/pgf/fill between/result stream/next ready/.code={ |
| 65 |
\pgfaddpathandBB{\pgfretval}% |
| 66 |
},% |
| 67 |
% |
| 68 |
% 'end' has no arguments. |
| 69 |
/pgf/fill between/result stream/end/.code=,% |
| 70 |
% |
| 71 |
/pgf/fill between/omit empty segments/.is choice, |
| 72 |
/pgf/fill between/omit empty segments/.default=true, |
| 73 |
/pgf/fill between/omit empty segments/false/.code=\def\pgfpathfillbetween@omit@empty@segments{0},% |
| 74 |
/pgf/fill between/omit empty segments/true/.code=\def\pgfpathfillbetween@omit@empty@segments{1},% |
| 75 |
/pgf/fill between/omit empty segments/true, |
| 76 |
}% |
| 77 |
|
| 78 |
% \pgfpathfillbetween[<options>]{<first path>}{<second path>} |
| 79 |
% |
| 80 |
% Generates a new path consisting of the "fill between" of the two arguments. |
| 81 |
% #1: optional arguments with /pgf/fill between prefix |
| 82 |
% #2: a macro containing the first path. More precisely, it is supposed to be a return value of \pgfgetpath. |
| 83 |
% #3: a macro containing the second path (in a format understood by \pgfsetpath). It is supposed to be a return value of \pgfgetpath. |
| 84 |
\def\pgfpathfillbetween{\pgfutil@ifnextchar[{\pgfpathfillbetween@opt}{\pgfpathfillbetween@opt[]}}% |
| 85 |
\def\pgfpathfillbetween@opt[#1]#2#3{% |
| 86 |
\begingroup |
| 87 |
\pgfqkeys{/pgf/fill between}{#1}% |
| 88 |
% |
| 89 |
% remove any special round-corner-tokens: |
| 90 |
\pgfprocessround{#2}{#2}% |
| 91 |
\pgfprocessround{#3}{#3}% |
| 92 |
% |
| 93 |
\if1\pgfpathfillbetween@inner@moveto |
| 94 |
% inner moveto=connect: |
| 95 |
\pgfpathfillbetween@connect@inner@movetos#2% |
| 96 |
\pgfpathfillbetween@connect@inner@movetos#3% |
| 97 |
\fi |
| 98 |
% |
| 99 |
\if2\pgfpathfillbetween@reverse@mode |
| 100 |
% reverse=auto |
| 101 |
\expandafter\pgfpathfillbetween@heuristics@get@direction#2\pgf@stop |
| 102 |
\let\pgfpath@filled@dir@first=\pgfretval |
| 103 |
\expandafter\pgfpathfillbetween@heuristics@get@direction#3\pgf@stop |
| 104 |
\let\pgfpath@filled@dir@second=\pgfretval |
| 105 |
% |
| 106 |
\ifx\pgfpath@filled@dir@first\pgfpath@filled@dir@second |
| 107 |
% Ok, they (seem to) have the same direction. Reverse one of them: |
| 108 |
\def\pgfpathfillbetween@reverse@mode{1}% |
| 109 |
\else |
| 110 |
\def\pgfpathfillbetween@reverse@mode{0}% |
| 111 |
\fi |
| 112 |
\fi |
| 113 |
% |
| 114 |
% softclip, if configured (no-op otherwise): |
| 115 |
\pgfpathcomputesoftclippath{#2}{\pgfpathfillbetween@softclip@A}\let#2=\pgfretval% |
| 116 |
\pgfpathcomputesoftclippath{#3}{\pgfpathfillbetween@softclip@B}\let#3=\pgfretval% |
| 117 |
% |
| 118 |
\ifx#2\pgfutil@empty |
| 119 |
\ifx\pgfpathfillbetween@softclip@A\pgfutil@empty |
| 120 |
\pgfpathfillbetween@warning{first}% |
| 121 |
\else |
| 122 |
\pgfpathfillbetween@warning{soft-clipped first}% |
| 123 |
\fi |
| 124 |
\else |
| 125 |
\ifx#3\pgfutil@empty |
| 126 |
\ifx\pgfpathfillbetween@softclip@B\pgfutil@empty |
| 127 |
\pgfpathfillbetween@warning{second}% |
| 128 |
\else |
| 129 |
\pgfpathfillbetween@warning{soft-clipped second}% |
| 130 |
\fi |
| 131 |
\else |
| 132 |
% |
| 133 |
\ifpgfpathfillbetween@split |
| 134 |
\pgfpathfillbetween@compute@splitted{#2}{#3}% |
| 135 |
\else |
| 136 |
\pgfkeys{/pgf/fill between/result stream/begin=1}% |
| 137 |
\pgfpathfillbetween@compute{#2}{#3}% |
| 138 |
\pgfpathfillbetween@invoke{result stream/next ready}% |
| 139 |
\pgfpathfillbetween@invoke{result stream/end}% |
| 140 |
\fi |
| 141 |
\fi |
| 142 |
\fi |
| 143 |
% |
| 144 |
% |
| 145 |
\endgroup |
| 146 |
}% |
| 147 |
|
| 148 |
\def\pgfpathfillbetween@warning#1{% |
| 149 |
\pgfwarning{fill between skipped: the #1 input path is empty.}% |
| 150 |
}% |
| 151 |
|
| 152 |
% Replaces all 'moveto' operations inside of the soft path '#1' by |
| 153 |
% 'lineto'. This excludes the first moveto. |
| 154 |
% |
| 155 |
% The motivation is that fillbetween should ignore inner movetos. |
| 156 |
% |
| 157 |
% UPDATE: it turned out that replacing inner movetos is necessary, but |
| 158 |
% not sufficient. Now, this macro does more: |
| 159 |
% - it replaces isolated inner movetos by lineto |
| 160 |
% - if two successive inner movetos occur, it throws away the first |
| 161 |
% one replaces the second by lineto |
| 162 |
% - if one or more trailing movetos occur in a path, these will be |
| 163 |
% thrown away. |
| 164 |
\def\pgfpathfillbetween@connect@inner@movetos#1{% |
| 165 |
\expandafter\pgfpathfillbetween@connect@inner@movetos@#1\pgf@stop% |
| 166 |
\let#1=\pgfretval |
| 167 |
} |
| 168 |
\def\pgfpathfillbetween@connect@inner@movetos@#1#2\pgf@stop{% |
| 169 |
\ifx#1\pgfsyssoftpath@movetotoken |
| 170 |
\pgfpathfillbetween@connect@inner@movetos@@{#2}% |
| 171 |
\expandafter\def\expandafter\pgfretval\expandafter{\expandafter\pgfsyssoftpath@movetotoken\pgfretval}% |
| 172 |
\else |
| 173 |
\pgfpathfillbetween@connect@inner@movetos@@{#1#2}% |
| 174 |
\fi |
| 175 |
}% |
| 176 |
|
| 177 |
% Substitute all movetotokens by linetotokens. |
| 178 |
% |
| 179 |
% In addition, it should *deduplicate* movetos, i.e. |
| 180 |
% "moveto{<x>}{<y}moveto{<x2>}{<y2>}" |
| 181 |
% -> "moveto{<x2>}{<y2>}" |
| 182 |
% |
| 183 |
% and: trailing movetos should be discarded. |
| 184 |
\def\pgfpathfillbetween@connect@inner@movetos@@#1{% |
| 185 |
% this implementation is derived from \pgfutilstrreplace - it does |
| 186 |
% almost the same as |
| 187 |
% s/\pgfsyssoftpath@movetotoken/pgfsyssoftpath@linetotoken/g |
| 188 |
% -> but with the extra additions of deduplication and trailing |
| 189 |
% moveto removal. |
| 190 |
\def\pgfretval{}% |
| 191 |
\pgfpathfillbetween@search@and@replace@loop{#1}% |
| 192 |
} |
| 193 |
\def\pgfpathfillbetween@connect@inner@moveto@foundit@#1\pgfsyssoftpath@movetotoken#2#3#4{% |
| 194 |
\ifx#4\pgf@EOI |
| 195 |
% ah - a trailing moveto. |
| 196 |
% In this case, we remember all until the moveto, but we omit |
| 197 |
% the trailing moveto and its arguments. |
| 198 |
\expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #1}% |
| 199 |
% |
| 200 |
% ... and stop searching. |
| 201 |
\let\pgf@loc@TMPa\relax |
| 202 |
\else |
| 203 |
\ifx#4\pgfsyssoftpath@movetotoken |
| 204 |
% DEDUPLICATE: we have at least two successive movetos. |
| 205 |
% silently skip the first moveto and its arguments and go on |
| 206 |
% with the second moveto. |
| 207 |
\def\pgf@loc@TMPa{\pgfpathfillbetween@connect@inner@moveto@foundit@#1\pgfsyssoftpath@movetotoken}% |
| 208 |
\else |
| 209 |
% substitute it by a lineto. |
| 210 |
\expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #1\pgfsyssoftpath@linetotoken{#2}{#3}}% |
| 211 |
% |
| 212 |
% ... continue the standard loop which skips over paths |
| 213 |
% until the next moveto. Remember to re-insert '#4': |
| 214 |
\def\pgf@loc@TMPa{\pgfpathfillbetween@connect@inner@moveto@foundit@@ #4}% |
| 215 |
\fi |
| 216 |
\fi |
| 217 |
\pgf@loc@TMPa |
| 218 |
}% |
| 219 |
\def\pgfpathfillbetween@connect@inner@moveto@foundit@@#1\pgf@EOI{% |
| 220 |
\pgfpathfillbetween@search@and@replace@loop{#1}% |
| 221 |
}% |
| 222 |
|
| 223 |
\def\pgfpathfillbetween@search@and@replace@loop#1{% |
| 224 |
\pgfutil@in@{\pgfsyssoftpath@movetotoken}{#1}% |
| 225 |
\ifpgfutil@in@ |
| 226 |
\def\pgf@loc@TMPa{\pgfpathfillbetween@connect@inner@moveto@foundit@ #1\pgf@EOI}% |
| 227 |
\else |
| 228 |
\expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #1}% |
| 229 |
\let\pgf@loc@TMPa=\relax |
| 230 |
\fi |
| 231 |
\pgf@loc@TMPa |
| 232 |
}% |
| 233 |
|
| 234 |
\def\pgfpathfillbetween@invoke#1{\pgfkeysvalueof{/pgf/fill between/#1/.@cmd}\pgfeov} |
| 235 |
|
| 236 |
\def\pgfpathfillbetween@replace@first@moveto#1#2\pgf@stop{% |
| 237 |
\ifx#1\pgfsyssoftpath@movetotoken |
| 238 |
\def\pgfretval{\pgfsyssoftpath@linetotoken #2}% |
| 239 |
\else |
| 240 |
\def\pgfretval{#1#2}% |
| 241 |
\fi |
| 242 |
}% |
| 243 |
|
| 244 |
\def\pgfpathfillbetween@compute@splitted#1#2{% |
| 245 |
% 0. normalize path sequences. |
| 246 |
% ATTENTION : there are implicit assumptions on the INTERNAL ORDER of the two paths! |
| 247 |
% This implementation needs to loop over them synchronously, i.e. it processes |
| 248 |
% the 0.th segment of a and the 0th of b, |
| 249 |
% the 1.th segment of a and the 1th of b, |
| 250 |
% and so on. Here, "i th segment" implies a sort order in ascending x direction. |
| 251 |
% This is, however, a weakness of \pgfintersectionofpaths - it does not really support this kind of sorting. |
| 252 |
% |
| 253 |
% I work around this by restricting the implementation to the "common use-cases", i.e. to two plots of functions which do not intersect themselves (i.e. to "functions" in the original sense). This will probably (almost surely) fail for parametric functions or circles. |
| 254 |
% |
| 255 |
\if0\pgfpathfillbetween@reverse@mode |
| 256 |
% reverse=false |
| 257 |
% |
| 258 |
% This means one plot is in direction '+' and one in '-', i.e. |
| 259 |
% a: x ---> x ---> x |
| 260 |
% b: x <--- x <--- x |
| 261 |
% |
| 262 |
% However, we have the implicit assumption that both paths can be processed synchronously, i.e. that they have the SAME direction. |
| 263 |
% To this end, we have to reverse one of them here (since \pgfintersectionofpaths does not automatically sort results in a suitable way): |
| 264 |
% |
| 265 |
\pgf@reverse@path{#2}% |
| 266 |
\let#2=\pgfretval |
| 267 |
% |
| 268 |
% However, we need to re-reverse the individual segments later-on... |
| 269 |
% So: set 'reverse=true'. Will be respected when assembling the splitted segments... |
| 270 |
\def\pgfpathfillbetween@reverse@mode{1}% |
| 271 |
\fi |
| 272 |
% |
| 273 |
% 1. compute intersection points: |
| 274 |
\pgf@intersect@sort@by@second@pathfalse |
| 275 |
% |
| 276 |
% FIXME : do we want to sort by time!? That might be needed for curvetos ... ? |
| 277 |
\pgf@intersect@sortfalse |
| 278 |
\pgfintersectionofpaths% |
| 279 |
{% |
| 280 |
\pgfsetpath#1% |
| 281 |
}% |
| 282 |
{% |
| 283 |
\pgfsetpath#2% |
| 284 |
}% |
| 285 |
% |
| 286 |
% FIXME : computing the intersections is fine... but it would be |
| 287 |
% even finer to report the resulting points back to tikz! |
| 288 |
% -> call the *tikz* intersection lib through some sort of callback!? |
| 289 |
% |
| 290 |
% 2. split the first involved path into the |
| 291 |
% segments induced by the intersection points: |
| 292 |
\pgfcomputeintersectionsegments{1}% |
| 293 |
\let\pgfpathfilled@a@segments=\pgfretval |
| 294 |
% |
| 295 |
% 2. split the second involved path into the |
| 296 |
% segments induced by the intersection points: |
| 297 |
\pgfcomputeintersectionsegments{2}% |
| 298 |
\let\pgfpathfilled@b@segments=\pgfretval |
| 299 |
% |
| 300 |
\ifnum\pgfpathfilled@a@segments=\pgfpathfilled@b@segments\relax |
| 301 |
\else |
| 302 |
\pgferror{Illegal internal state encountered: the number segments induced by the intersection points of the two paths DIFFER between the first and the second path: first path has \pgfpathfilled@a@segments\space whereas the second has \pgfpathfilled@b@segments.}% |
| 303 |
\fi |
| 304 |
% |
| 305 |
% STEP 1: find out if there are empty segments. Numerical |
| 306 |
% inaccuracies occasionally result in such segments; we silently |
| 307 |
% skip them. |
| 308 |
\def\c@pgfpathfilled@nonemptysegments{0}% |
| 309 |
\def\c@pgfpathfilled@counter{0}% |
| 310 |
\pgfmathloop |
| 311 |
\ifnum\c@pgfpathfilled@counter<\pgfpathfilled@a@segments\relax |
| 312 |
\expandafter\let\expandafter\pgf@loc@path@a\csname pgf@intersect@path@split@a@\c@pgfpathfilled@counter\endcsname |
| 313 |
\expandafter\let\expandafter\pgf@loc@path@b\csname pgf@intersect@path@split@b@\c@pgfpathfilled@counter\endcsname |
| 314 |
% |
| 315 |
\if1\pgfpathfillbetween@omit@empty@segments |
| 316 |
\pgfpathfillbetween@compute@checkempty{\pgf@loc@path@a}% |
| 317 |
% A segment is empty if BOTH of its input segments are empty: |
| 318 |
\if1\pgfretval |
| 319 |
\pgfpathfillbetween@compute@checkempty{\pgf@loc@path@b}% |
| 320 |
\if1\pgfretval |
| 321 |
\pgfutil@IfUndefined{pgfplots@log}{}{% |
| 322 |
\pgfplots@log4{fillbetween: skipping empty intersection segment no \c@pgfpathfilled@counter}% |
| 323 |
}% |
| 324 |
\expandafter\def\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname{1}% |
| 325 |
\else |
| 326 |
\expandafter\def\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname{0}% |
| 327 |
\pgfutil@advancestringcounter\c@pgfpathfilled@nonemptysegments |
| 328 |
\fi |
| 329 |
\else |
| 330 |
\expandafter\def\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname{0}% |
| 331 |
\pgfutil@advancestringcounter\c@pgfpathfilled@nonemptysegments |
| 332 |
\fi |
| 333 |
\else |
| 334 |
\expandafter\def\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname{0}% |
| 335 |
\pgfutil@advancestringcounter\c@pgfpathfilled@nonemptysegments |
| 336 |
\fi |
| 337 |
% |
| 338 |
\pgfutil@advancestringcounter\c@pgfpathfilled@counter |
| 339 |
\repeatpgfmathloop |
| 340 |
% |
| 341 |
\ifnum\c@pgfpathfilled@nonemptysegments=0 |
| 342 |
\else |
| 343 |
\pgfkeys{/pgf/fill between/result stream/begin=\c@pgfpathfilled@nonemptysegments}% |
| 344 |
% Recombine the pairs of segments (a_i, b_i), i = 0,..., N-1 in a |
| 345 |
% filled way: |
| 346 |
\def\c@pgfpathfilled@counter{0}% |
| 347 |
\pgfmathloop |
| 348 |
\ifnum\c@pgfpathfilled@counter<\pgfpathfilled@a@segments\relax |
| 349 |
\if0\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname |
| 350 |
\expandafter\let\expandafter\pgf@loc@path@a\csname pgf@intersect@path@split@a@\c@pgfpathfilled@counter\endcsname |
| 351 |
\expandafter\let\expandafter\pgf@loc@path@b\csname pgf@intersect@path@split@b@\c@pgfpathfilled@counter\endcsname |
| 352 |
% |
| 353 |
\pgfpathfillbetween@compute{\pgf@loc@path@a}{\pgf@loc@path@b}% |
| 354 |
% report to the result stream. It knows how to deal with it: |
| 355 |
\pgfpathfillbetween@invoke{result stream/next ready}% |
| 356 |
% |
| 357 |
\fi |
| 358 |
\pgfutil@advancestringcounter\c@pgfpathfilled@counter |
| 359 |
\repeatpgfmathloop |
| 360 |
\pgfpathfillbetween@invoke{result stream/end}% |
| 361 |
\fi |
| 362 |
} |
| 363 |
|
| 364 |
\def\pgflibraryfillbetweenemptysegmenttolerance{1pt} |
| 365 |
|
| 366 |
\def\pgfpathfillbetween@compute@checkempty#1{% |
| 367 |
\def\pgfretval{0}% |
| 368 |
\pgf@compute@BB{#1}% |
| 369 |
\advance\pgf@xb by-\pgf@xa |
| 370 |
\advance\pgf@yb by-\pgf@ya |
| 371 |
% if one of the dimensions is empty, the segment is empty: |
| 372 |
\ifdim\pgf@xb<\pgflibraryfillbetweenemptysegmenttolerance\relax |
| 373 |
\def\pgfretval{1}% |
| 374 |
\fi |
| 375 |
\ifdim\pgf@yb<\pgflibraryfillbetweenemptysegmenttolerance\relax |
| 376 |
\def\pgfretval{1}% |
| 377 |
\fi |
| 378 |
} |
| 379 |
|
| 380 |
\def\pgfpathfillbetween@compute#1#2{% |
| 381 |
%\message{Combination of ^^J \meaning#1\space and ^^J \meaning#2...^^J}% |
| 382 |
% |
| 383 |
\if1\pgfpathfillbetween@reverse@mode |
| 384 |
% reverse=true |
| 385 |
% |
| 386 |
% Ok, then reverse one of the paths. We choose the second one as that is easier to debug. |
| 387 |
% FIXME : might make sense to determine which one is shorter... |
| 388 |
\pgf@reverse@path{#2}% |
| 389 |
\let#2=\pgfretval |
| 390 |
\fi |
| 391 |
% |
| 392 |
% FIXME: what should I do if I have closed paths!? What is the |
| 393 |
% expected behavior!? I know that the combination of two closed |
| 394 |
% paths should probably be used as is, perhaps with even-odd-rule. |
| 395 |
% This here should do the job. |
| 396 |
% |
| 397 |
% NOTE: I believe the 'split' fails to work with closed paths. |
| 398 |
\pgfpathfillbetween@contains@closepathtoken{#1}% |
| 399 |
\let\b@pgfpathfillbetween@contains@close@a=\pgfretval |
| 400 |
\pgfpathfillbetween@contains@closepathtoken{#2}% |
| 401 |
\let\b@pgfpathfillbetween@contains@close@b=\pgfretval |
| 402 |
% |
| 403 |
\def\b@pgfpathfillbetween@contains@close{0}% |
| 404 |
\if1\b@pgfpathfillbetween@contains@close@b |
| 405 |
\def\b@pgfpathfillbetween@contains@close{1}% |
| 406 |
\fi |
| 407 |
\if1\b@pgfpathfillbetween@contains@close@a |
| 408 |
\def\b@pgfpathfillbetween@contains@close{1}% |
| 409 |
\fi |
| 410 |
% |
| 411 |
\if0\b@pgfpathfillbetween@contains@close@b |
| 412 |
\expandafter\pgfpathfillbetween@replace@first@moveto#2\pgf@stop |
| 413 |
\let#2=\pgfretval |
| 414 |
\fi |
| 415 |
% |
| 416 |
\t@pgf@toka=\expandafter{#1}% |
| 417 |
\t@pgf@tokb=\expandafter{#2}% |
| 418 |
% |
| 419 |
\if0\b@pgfpathfillbetween@contains@close |
| 420 |
% we need to close the resulting combined path, otherwise decorations will look strange: |
| 421 |
\expandafter\pgfpathfillbetween@get@first@coord#1\pgf@stop |
| 422 |
\t@pgf@tokc=\expandafter{\expandafter\pgfsyssoftpath@closepathtoken\pgfretval}% |
| 423 |
\else |
| 424 |
\t@pgf@tokc={}% |
| 425 |
\fi |
| 426 |
% |
| 427 |
\edef\pgfretval{\the\t@pgf@toka\the\t@pgf@tokb\the\t@pgf@tokc}% |
| 428 |
% |
| 429 |
%\message{^^J = \meaning\pgfretval^^J}% |
| 430 |
% that's it. |
| 431 |
} |
| 432 |
|
| 433 |
% #1 a macro containing a softpath |
| 434 |
% OUTPUT: |
| 435 |
% \pgfretval = 1 if the path contains \pgfsyssoftpath@closepathtoken |
| 436 |
% and 0 otherwise. |
| 437 |
\def\pgfpathfillbetween@contains@closepathtoken#1{% |
| 438 |
\expandafter\pgfutil@in@\expandafter\pgfsyssoftpath@closepathtoken\expandafter{#1}% |
| 439 |
\ifpgfutil@in@ |
| 440 |
\def\pgfretval{1}% |
| 441 |
\else |
| 442 |
\def\pgfretval{0}% |
| 443 |
\fi |
| 444 |
} |
| 445 |
|
| 446 |
\def\pgfpathfillbetween@get@first@coord#1#2#3#4\pgf@stop{% |
| 447 |
\def\pgfretval{{#2}{#3}}% |
| 448 |
}% |
| 449 |
|
| 450 |
% assigns the bounding box of path #1 to |
| 451 |
% (pgf@xa , pgf@ya) = (minx,miny) |
| 452 |
% (pgf@xb , pgf@yb) = (maxx,maxy) |
| 453 |
\def\pgf@compute@BB#1{% |
| 454 |
\begingroup |
| 455 |
\dimendef\pgf@pathmaxx=0 % |
| 456 |
\dimendef\pgf@pathminx=1 % |
| 457 |
\dimendef\pgf@pathmaxy=2 % |
| 458 |
\dimendef\pgf@pathminy=3 % |
| 459 |
\pgf@pathmaxx=-16000pt\relax% |
| 460 |
\pgf@pathminx=16000pt\relax% |
| 461 |
\pgf@pathmaxy=-16000pt\relax% |
| 462 |
\pgf@pathminy=16000pt\relax% |
| 463 |
\let\pgf@protocolsizes=\pgf@compute@BB@protocol@sizes |
| 464 |
\expandafter\pgfsetpath@loop#1\pgf@stop |
| 465 |
\xdef\pgf@marshal{% |
| 466 |
\pgf@xa=\the\pgf@pathminx\relax |
| 467 |
\pgf@ya=\the\pgf@pathminy\relax |
| 468 |
\pgf@xb=\the\pgf@pathmaxx\relax |
| 469 |
\pgf@yb=\the\pgf@pathmaxy\relax |
| 470 |
}% |
| 471 |
\endgroup |
| 472 |
\pgf@marshal |
| 473 |
}% |
| 474 |
\def\pgf@compute@BB@protocol@sizes#1#2{% |
| 475 |
\ifdim#1<\pgf@pathminx\pgf@pathminx#1\fi% |
| 476 |
\ifdim#1>\pgf@pathmaxx\pgf@pathmaxx#1\fi% |
| 477 |
\ifdim#2<\pgf@pathminy\pgf@pathminy#2\fi% |
| 478 |
\ifdim#2>\pgf@pathmaxy\pgf@pathmaxy#2\fi% |
| 479 |
} |
| 480 |
|
| 481 |
% A utility function like \pgfsetpath which calls \pgfsetpath *and* protocols |
| 482 |
% the size of each path segment (i.e. compute the bounding box). |
| 483 |
% |
| 484 |
% #1 a macro containing a softpath (i.e. something returned by |
| 485 |
% \pgfgetpath) |
| 486 |
% |
| 487 |
% SIDE--EFFECT: defines \pgfpointlastofsetpath to be the last point of path #1 |
| 488 |
\def\pgfsetpathandBB#1{% |
| 489 |
\let\pgfpointlastofsetpath=\pgfutil@empty |
| 490 |
\expandafter\pgfsetpath@loop#1\pgf@stop |
| 491 |
% |
| 492 |
\pgfsetpath{#1}% |
| 493 |
}% |
| 494 |
|
| 495 |
% Like \pgfsetpathandBB, but this here *appends* to the existing |
| 496 |
% softpath. |
| 497 |
% |
| 498 |
% #1 a macro containing a softpath (i.e. something returned by |
| 499 |
% \pgfgetpath) |
| 500 |
% SIDE--EFFECT: defines \pgfpointlastofsetpath to be the last point of path #1 |
| 501 |
\def\pgfaddpathandBB#1{% |
| 502 |
\let\pgfpointlastofsetpath=\pgfutil@empty |
| 503 |
\expandafter\pgfsetpath@loop#1\pgf@stop |
| 504 |
\pgfaddpath#1% |
| 505 |
} |
| 506 |
|
| 507 |
% Like \pgfsetpath, but this here *appends* to the existing |
| 508 |
% softpath. |
| 509 |
% |
| 510 |
% #1 a macro containing a softpath (i.e. something returned by |
| 511 |
% \pgfgetpath) |
| 512 |
\def\pgfaddpath#1{% |
| 513 |
% append to any previous path elements: |
| 514 |
\pgfgetpath\pgf@temp |
| 515 |
\t@pgf@tokc=\expandafter{\pgf@temp}% |
| 516 |
\t@pgf@toka=\expandafter{#1}% |
| 517 |
\edef\pgfretval{\the\t@pgf@tokc\the\t@pgf@toka}% |
| 518 |
\pgfsetpath{\pgfretval}% |
| 519 |
} |
| 520 |
|
| 521 |
% Takes a softpath on input, replaces its first moveto by a lineto, |
| 522 |
% and returns it as softpath. |
| 523 |
% #1: a macro containing a softpath (i.e. the result of \pgfgetpath) |
| 524 |
% |
| 525 |
% On output, \pgfretval contains a modified path. |
| 526 |
\def\pgfpathreplacefirstmoveto#1{% |
| 527 |
\ifx#1\pgfutil@empty |
| 528 |
\let\pgfretval=#1% |
| 529 |
\else |
| 530 |
\expandafter\pgfpathfillbetween@replace@first@moveto#1\pgf@stop |
| 531 |
\fi |
| 532 |
} |
| 533 |
|
| 534 |
% Defines \pgfretval to be '+' if the path's direction is "ascending" |
| 535 |
% and "-" otherwise. |
| 536 |
% |
| 537 |
% Here, "ascending" means that its first two coordinates have |
| 538 |
% ascending X coordinates. If the X coordinates are equal, the Y |
| 539 |
% coordinates are used instead. |
| 540 |
\def\pgfpathfillbetween@heuristics@get@direction#1#2#3{% |
| 541 |
\pgfutil@ifnextchar\pgf@stop{% |
| 542 |
% wow. it has just one path element... we can do nothing. |
| 543 |
\def\pgfretval{+}% |
| 544 |
\pgfutil@gobble |
| 545 |
}{% |
| 546 |
\pgfpathfillbetween@heuristics@get@direction@{#1}{#2}{#3}% |
| 547 |
}% |
| 548 |
}% |
| 549 |
|
| 550 |
% example: \pgfsyssoftpath@movetotoken{#2}{#3}\pgfsyssoftpath@linetotoken{#5}{#6}#7\pgf@stop |
| 551 |
% example: |
| 552 |
% \pgfsyssoftpath@movetotoken{#2}{#3} |
| 553 |
% \pgfsyssoftpath@curvetosupportatoken{<x>}{<y>} |
| 554 |
% \pgfsyssoftpath@curvetosupportbtoken{<x>}{<y>} |
| 555 |
% \pgfsyssoftpath@curvetotoken{<x>}{<y>}\pgf@stop |
| 556 |
\def\pgfpathfillbetween@heuristics@get@direction@#1#2#3#4#5#6#7\pgf@stop{% |
| 557 |
\def\pgf@temp{#4}% |
| 558 |
\def\pgf@tempb{\pgfsyssoftpath@curvetosupportatoken}% |
| 559 |
\ifx\pgf@temp\pgf@tempb |
| 560 |
% Ah - a curveto! Use the end-point for the heuristics. |
| 561 |
\pgfpathfillbetween@heuristics@get@direction@curveto #1{#2}{#3}#4{#5}{#6}#7\pgf@stop |
| 562 |
\else |
| 563 |
% Ok, assume it is line to (or its variants): |
| 564 |
\pgfpathfillbetween@heuristics@get@direction@@{#2}{#3}{#5}{#6}% |
| 565 |
\fi |
| 566 |
}% |
| 567 |
|
| 568 |
\def\pgfpathfillbetween@heuristics@get@direction@curveto#1#2#3\pgfsyssoftpath@curvetosupportatoken#4\pgfsyssoftpath@curvetotoken#5#6#7\pgf@stop{% |
| 569 |
\pgfpathfillbetween@heuristics@get@direction@@{#2}{#3}{#5}{#6}% |
| 570 |
}% |
| 571 |
|
| 572 |
% #1: x1 |
| 573 |
% #2: y1 |
| 574 |
% #3: x2 |
| 575 |
% #4: y2 |
| 576 |
\def\pgfpathfillbetween@heuristics@get@direction@@#1#2#3#4{% |
| 577 |
\edef\pgfretval{% |
| 578 |
\ifdim #1<#3\space |
| 579 |
+% |
| 580 |
\else |
| 581 |
\ifdim #1=#3\space |
| 582 |
\ifdim #2<#4\space |
| 583 |
+% |
| 584 |
\else |
| 585 |
-% |
| 586 |
\fi |
| 587 |
\else |
| 588 |
-% |
| 589 |
\fi |
| 590 |
\fi |
| 591 |
}% |
| 592 |
} |
| 593 |
|
| 594 |
% Accumulates the path's bounding box, the last moveto, and the last |
| 595 |
% coord. |
| 596 |
\def\pgfsetpath@loop#1{% |
| 597 |
\ifx#1\pgf@stop% |
| 598 |
\let\pgfsetpathBB@protocolsizesnext=\relax% |
| 599 |
\else% |
| 600 |
\ifx#1\pgfsyssoftpath@movetotoken% |
| 601 |
\let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@moveto% |
| 602 |
\else% |
| 603 |
\ifx#1\pgfsyssoftpath@linetotoken% |
| 604 |
\let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@simple% |
| 605 |
\else% |
| 606 |
\ifx#1\pgfsyssoftpath@closepathtoken% |
| 607 |
\let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@simple% |
| 608 |
\else% |
| 609 |
\ifx#1\pgfsyssoftpath@curvetosupportatoken% |
| 610 |
\let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@curveto% |
| 611 |
\else% |
| 612 |
\ifx#1\pgfsyssoftpath@rectcornertoken% |
| 613 |
\let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@rect% |
| 614 |
\fi% |
| 615 |
\fi% |
| 616 |
\fi% |
| 617 |
\fi% |
| 618 |
\fi% |
| 619 |
\fi% |
| 620 |
\pgfsetpathBB@protocolsizesnext} |
| 621 |
|
| 622 |
\def\pgfsetpathBB@protocol@lastmoveto#1#2{% |
| 623 |
\gdef\pgfsyssoftpath@lastmoveto{{#1}{#2}}% |
| 624 |
} |
| 625 |
|
| 626 |
\def\pgfsetpathBB@protocolsizestoken@moveto#1#2{% |
| 627 |
% required for --cycle, among others: |
| 628 |
\pgfsetpathBB@protocol@lastmoveto{#1}{#2}% |
| 629 |
\pgfsetpathBB@protocolsizestoken@simple{#1}{#2}% |
| 630 |
} |
| 631 |
\def\pgfsetpathBB@protocolsizestoken@simple#1#2{% |
| 632 |
\def\pgfpointlastofsetpath{\pgfqpoint{#1}{#2}}% |
| 633 |
\pgf@protocolsizes{#1}{#2}% |
| 634 |
\pgfsetpath@loop% |
| 635 |
} |
| 636 |
|
| 637 |
\def\pgfsetpathBB@protocolsizestoken@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{% |
| 638 |
\def\pgfpointlastofsetpath{\pgfqpoint{#5}{#6}}% |
| 639 |
\pgf@protocolsizes{#1}{#2}% |
| 640 |
\pgf@protocolsizes{#3}{#4}% |
| 641 |
\pgf@protocolsizes{#5}{#6}% |
| 642 |
\pgfsetpath@loop |
| 643 |
} |
| 644 |
|
| 645 |
\def\pgfsetpathBB@protocolsizestoken@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{% |
| 646 |
\pgf@protocolsizes{#1}{#2}% |
| 647 |
\pgf@xa=#1\relax% |
| 648 |
\advance\pgf@xa by#3\relax% |
| 649 |
\pgf@ya=#2\relax% |
| 650 |
\advance\pgf@ya by#4\relax% |
| 651 |
\pgf@protocolsizes{\pgf@xa}{\pgf@ya}% |
| 652 |
\pgfsetpath@loop |
| 653 |
}% |
| 654 |
|
| 655 |
% Defines \pgfretval to be the reversed path of #1. |
| 656 |
% |
| 657 |
% #1 is supposed to be a macro containing a path without rounding specials (i.e. a result |
| 658 |
% of \pgfprocessround) |
| 659 |
\def\pgfcomputereversepath#1{% |
| 660 |
% unfortunately, this is already used by internal macros... |
| 661 |
\pgf@reverse@path#1% |
| 662 |
}% |
| 663 |
\def\pgf@reverse@path#1{% |
| 664 |
% ATTENTION: this here is a special implementation which |
| 665 |
% operates directly on softpaths. It does not make use of \pgf@decorate@inputsegmentobjects@reverse (reverse path decoration) |
| 666 |
% because (a) decorations require their own special format and (b) |
| 667 |
% this implementation is faster (both with respect to runtime asymptotics and runtime constant). |
| 668 |
\def\pgf@reverse@first@type{}% |
| 669 |
\def\pgf@reverse@last@pt{}% |
| 670 |
\def\b@pgf@reversepath@last@is@close{0}% |
| 671 |
\pgfprependlistnewempty{pgfretval}% |
| 672 |
\let\pgfreverse@iterate=\pgfreverse@checkfirst@then |
| 673 |
\expandafter\pgf@reverse@loop#1\pgf@stop |
| 674 |
% |
| 675 |
\if 0\b@pgf@reversepath@last@is@close% |
| 676 |
\expandafter\pgfreverse@prepend@last\expandafter{\pgf@reverse@first@type}{x}{x}% |
| 677 |
\else |
| 678 |
% as soon as a closepathtoken is encountered, the associated |
| 679 |
% moveto is processed right away. |
| 680 |
% |
| 681 |
% FIXME : I doubt that the implementation works if more than |
| 682 |
% one closepathtoken is in here ... |
| 683 |
\fi |
| 684 |
\pgfprependlistlet\pgfretval={pgfretval}% |
| 685 |
% |
| 686 |
}% |
| 687 |
|
| 688 |
\def\pgf@reverse@loop#1{% |
| 689 |
\ifx#1\pgf@stop% |
| 690 |
\let\pgfreverse@next=\relax% |
| 691 |
\else% |
| 692 |
\def\b@pgf@reversepath@last@is@close{0}% |
| 693 |
\ifx#1\pgfsyssoftpath@movetotoken% |
| 694 |
\let\pgfreverse@next=\pgfreverse@token@moveto% |
| 695 |
\else% |
| 696 |
\ifx#1\pgfsyssoftpath@linetotoken% |
| 697 |
\let\pgfreverse@next=\pgfreverse@token@lineto% |
| 698 |
\else% |
| 699 |
\ifx#1\pgfsyssoftpath@closepathtoken% |
| 700 |
\let\pgfreverse@next=\pgfreverse@token@close% |
| 701 |
\else% |
| 702 |
\ifx#1\pgfsyssoftpath@curvetosupportatoken% |
| 703 |
\let\pgfreverse@next=\pgfreverse@token@curveto% |
| 704 |
\else% |
| 705 |
\ifx#1\pgfsyssoftpath@rectcornertoken% |
| 706 |
\let\pgfreverse@next=\pgfreverse@token@rect% |
| 707 |
\fi% |
| 708 |
\fi% |
| 709 |
\fi% |
| 710 |
\fi% |
| 711 |
\fi% |
| 712 |
\fi% |
| 713 |
\pgfreverse@next} |
| 714 |
|
| 715 |
\def\pgfreverse@checkfirst@then#1{% |
| 716 |
\def\pgf@reverse@first@type{#1}% |
| 717 |
\let\pgfreverse@iterate=\pgfutil@gobble |
| 718 |
}% |
| 719 |
|
| 720 |
\def\pgfreverse@prepend@last#1#2#3{% |
| 721 |
\ifx\pgf@reverse@last@pt\pgfutil@empty |
| 722 |
\else |
| 723 |
\t@pgf@toka={#1}% |
| 724 |
\t@pgf@tokb=\expandafter{\pgf@reverse@last@pt}% |
| 725 |
\edef\pgf@marshal{\the\t@pgf@toka\the\t@pgf@tokb}% |
| 726 |
\expandafter\pgfprependlistpushfront\pgf@marshal\to{pgfretval}% |
| 727 |
\fi |
| 728 |
\def\pgf@reverse@last@pt{{#2}{#3}}% |
| 729 |
}% |
| 730 |
|
| 731 |
\def\pgfreverse@token@moveto#1#2{% |
| 732 |
\pgfreverse@iterate{\pgfsyssoftpath@movetotoken}% |
| 733 |
\pgfreverse@prepend@last\pgfsyssoftpath@movetotoken{#1}{#2}% |
| 734 |
\pgf@reverse@loop% |
| 735 |
} |
| 736 |
|
| 737 |
\def\pgfreverse@token@lineto#1#2{% |
| 738 |
\pgfreverse@iterate{\pgfsyssoftpath@linetotoken}% |
| 739 |
\pgfreverse@prepend@last\pgfsyssoftpath@linetotoken{#1}{#2}% |
| 740 |
\pgf@reverse@loop |
| 741 |
} |
| 742 |
\def\pgfreverse@token@close#1#2{% |
| 743 |
% close tokens are complicated: they always correspond to the most |
| 744 |
% recent moveto token. |
| 745 |
% |
| 746 |
% First: remember that the last encountered token was 'close': if |
| 747 |
% this is the lastmost token, we must not insert a final moveto. |
| 748 |
\def\b@pgf@reversepath@last@is@close{1}% |
| 749 |
% |
| 750 |
% Second: *append* |
| 751 |
% \pgfsyssoftpath@closepathtoken{<lastx>}{<lasty>}. |
| 752 |
% |
| 753 |
% Appending is unsupported by the prepend-list, so we have to |
| 754 |
% terminate it, append, and reinitialize it with the result: |
| 755 |
\pgfprependlistlet\pgfretval={pgfretval}% |
| 756 |
\t@pgf@toka=\expandafter{\pgfretval}% |
| 757 |
\t@pgf@tokb={\pgfsyssoftpath@closepathtoken}% |
| 758 |
\t@pgf@tokc=\expandafter{\pgf@reverse@last@pt}% |
| 759 |
\edef\pgf@marshal{\the\t@pgf@toka\the\t@pgf@tokb\the\t@pgf@tokc}% |
| 760 |
% |
| 761 |
% ... create a new list with the result: |
| 762 |
\pgfprependlistnewempty{pgfretval}% |
| 763 |
\expandafter\pgfprependlistpushfront\pgf@marshal\to{pgfretval}% |
| 764 |
% |
| 765 |
% and prepend a moveto. |
| 766 |
\pgfreverse@prepend@last\pgfsyssoftpath@movetotoken{#1}{#2}% |
| 767 |
% |
| 768 |
\pgf@reverse@loop |
| 769 |
} |
| 770 |
|
| 771 |
\def\pgfreverse@token@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{% |
| 772 |
\pgfreverse@iterate{\pgfsyssoftpath@curvetosupportatoken{#1}{#2}\pgfsyssoftpath@curvetosupportbtoken{#3}{#4}\pgfsyssoftpath@curvetotoken}% |
| 773 |
\pgfreverse@prepend@last{\pgfsyssoftpath@curvetosupportatoken{#3}{#4}\pgfsyssoftpath@curvetosupportbtoken{#1}{#2}\pgfsyssoftpath@curvetotoken}{#5}{#6}% |
| 774 |
\pgf@reverse@loop |
| 775 |
} |
| 776 |
|
| 777 |
\def\pgfreverse@token@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{% |
| 778 |
% FIXME: UNTESTED |
| 779 |
\pgf@xa=#1\relax% |
| 780 |
\advance\pgf@xa by#3\relax% |
| 781 |
\pgf@ya=#2\relax% |
| 782 |
\advance\pgf@ya by#4\relax% |
| 783 |
\edef\pgf@marshal{% |
| 784 |
\noexpand\pgfsyssoftpath@movetotoken |
| 785 |
{% |
| 786 |
{#1}{#2}% |
| 787 |
\noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{#2}% |
| 788 |
\noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{\the\pgf@ya}% |
| 789 |
\noexpand\pgfsyssoftpath@linetotoken{#1}{\the\pgf@ya}% |
| 790 |
\noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}% |
| 791 |
}% |
| 792 |
}% |
| 793 |
\pgfreverse@iterate\pgfsyssoftpath@movetotoken |
| 794 |
\edef\pgf@reverse@last@pt{{#1}{#2}}% |
| 795 |
\expandafter\pgf@reverse@loop\pgf@marshal% |
| 796 |
} |
| 797 |
|
| 798 |
% ---------------------------------------- |
| 799 |
% Given that some intersections have been computed already (and are in |
| 800 |
% the current scope), this command computes the intersection segments |
| 801 |
% for one of the input arguments. |
| 802 |
% |
| 803 |
% On output, both \pgfretval and \pgfintersectionsegments contain the number of computed segments. The |
| 804 |
% segments as such can be accessed via \pgfgetintersectionsegmentpath. |
| 805 |
% |
| 806 |
% #1 : should be '1' if the FIRST argument of |
| 807 |
% \pgfintersectionofpaths should be used and '2' the SECOND |
| 808 |
% argument of \pgfintersectionofpaths should be used on input. |
| 809 |
% |
| 810 |
% EXAMPLE: |
| 811 |
% |
| 812 |
% \def\inputValue{% |
| 813 |
% \pgfsyssoftpath@movetotoken {56.90549pt}{0.0pt}% |
| 814 |
% \pgfsyssoftpath@linetotoken {85.35823pt}{28.45274pt}% |
| 815 |
% \pgfsyssoftpath@linetotoken {113.81097pt}{0.0pt}% |
| 816 |
% \pgfsyssoftpath@linetotoken {142.26372pt}{28.45274pt}% |
| 817 |
% \pgfsyssoftpath@linetotoken {170.71646pt}{0.0pt}% |
| 818 |
% } |
| 819 |
% |
| 820 |
% \pgfpointintersectionsolution{1}% |
| 821 |
% \pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{71.13918pt, 14.2278pt}{solution 1} |
| 822 |
% \pgfpointintersectionsolution{2}% |
| 823 |
% \pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{99.59497pt, 14.2278pt}{solution 2} |
| 824 |
% \pgfpointintersectionsolution{3}% |
| 825 |
% \pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{128.05057pt, 14.2278pt}{solution 3} |
| 826 |
% \pgfpointintersectionsolution{4}% |
| 827 |
% \pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{156.50636pt, 14.2278pt}{solution 4} |
| 828 |
% |
| 829 |
% |
| 830 |
% \pgfcomputeintersectionsegments{1}% |
| 831 |
% |
| 832 |
% \message{OUTPUT: \meaning\pgfretval^^J}% |
| 833 |
% \expandafter\def\csname expected@a@0\endcsname{% |
| 834 |
% \pgfsyssoftpath@movetotoken {56.90549pt}{0.0pt}% |
| 835 |
% \pgfsyssoftpath@linetotoken{71.13918pt}{14.2278pt}% |
| 836 |
% } |
| 837 |
% \expandafter\def\csname expected@a@1\endcsname{% |
| 838 |
% \pgfsyssoftpath@movetotoken{71.13918pt}{14.2278pt}% |
| 839 |
% \pgfsyssoftpath@linetotoken {85.35823pt}{28.45274pt}% |
| 840 |
% \pgfsyssoftpath@linetotoken{99.59497pt}{14.2278pt}% |
| 841 |
% } |
| 842 |
% \expandafter\def\csname expected@a@2\endcsname{% |
| 843 |
% \pgfsyssoftpath@movetotoken{99.59497pt}{14.2278pt}% |
| 844 |
% \pgfsyssoftpath@linetotoken {113.81097pt}{0.0pt}% |
| 845 |
% \pgfsyssoftpath@linetotoken{128.05057pt}{14.2278pt}% |
| 846 |
% } |
| 847 |
% \expandafter\def\csname expected@a@3\endcsname{% |
| 848 |
% \pgfsyssoftpath@movetotoken{128.05057pt}{14.2278pt}% |
| 849 |
% \pgfsyssoftpath@linetotoken {142.26372pt}{28.45274pt}% |
| 850 |
% \pgfsyssoftpath@linetotoken{156.50636pt}{14.2278pt}% |
| 851 |
% } |
| 852 |
% \expandafter\def\csname expected@a@4\endcsname{% |
| 853 |
% \pgfsyssoftpath@movetotoken{156.50636pt}{14.2278pt}% |
| 854 |
% \pgfsyssoftpath@linetotoken {170.71646pt}{0.0pt}% |
| 855 |
% } |
| 856 |
% % |
| 857 |
\def\pgfcomputeintersectionsegments#1{% |
| 858 |
\pgfcomputeintersectionsegments@set@src{#1}% |
| 859 |
\ifnum\pgfintersectionsolutions=0 % |
| 860 |
\pgfutil@namelet{pgf@intersect@path@split@\pgf@insert@intersections@src @0}{pgf@intersect@path@\pgf@insert@intersections@src}% |
| 861 |
\def\pgfretval{0}% |
| 862 |
\else |
| 863 |
% |
| 864 |
% This algorithm *relies* on an increasing sort order. Sort |
| 865 |
% them: |
| 866 |
\pgfintersectionsolutionsortbytime@@% |
| 867 |
% |
| 868 |
% |
| 869 |
\pgfapplistnewempty{pgfretval@tmp}% |
| 870 |
\def\pgf@insert@cursolution{1}% |
| 871 |
\def\c@pgf@path@result{0}% |
| 872 |
\let\c@pgf@path@segment=\c@pgf@countd |
| 873 |
\let\c@pgf@path@segment@trg=\c@pgf@countc |
| 874 |
\c@pgf@path@segment=0 % |
| 875 |
\pgf@fillbetween@get@time@off{\pgf@insert@intersections@src}{\pgf@insert@cursolution}% |
| 876 |
\c@pgf@path@segment@trg=\pgfretval\relax |
| 877 |
% |
| 878 |
\pgfutil@namelet{pgf@loc@TMPa}{pgf@intersect@path@\pgf@insert@intersections@src}% |
| 879 |
\expandafter\pgf@insert@intersections@loop\pgf@loc@TMPa\pgf@stop |
| 880 |
% |
| 881 |
\pgfapplistlet\pgf@loc@TMPa={pgfretval@tmp}% |
| 882 |
\expandafter\let\csname pgf@intersect@path@split@\pgf@insert@intersections@src @\c@pgf@path@result\endcsname=\pgf@loc@TMPa% |
| 883 |
\pgfutil@advancestringcounter\c@pgf@path@result% |
| 884 |
\let\pgfretval=\c@pgf@path@result% |
| 885 |
\fi |
| 886 |
\let\pgfintersectionsegments=\pgfretval |
| 887 |
}% |
| 888 |
|
| 889 |
% Defines \pgfretval to contain the desired path segment as softpath. |
| 890 |
% |
| 891 |
% @see \pgfsetpath |
| 892 |
% @see \pgfsetpathandBB |
| 893 |
% @see \pgfaddpathandBB |
| 894 |
% |
| 895 |
% #1: the value '1' if results for the FIRST argument of |
| 896 |
% \pgfintersectionofpaths are requested or '2' if results for the |
| 897 |
% SECOND path are requested (compare \pgfcomputeintersectionsegments). |
| 898 |
% #2: the segment index (a number 0<= #2 < numbersegments). |
| 899 |
% The number of segments is \pgfintersectionsegments |
| 900 |
\def\pgfgetintersectionsegmentpath#1#2{% |
| 901 |
\pgfcomputeintersectionsegments@set@src{#1}% |
| 902 |
\pgfmathparse{#2}% |
| 903 |
\afterassignment\pgfcomputeintersectionsegments@set@src@gobble |
| 904 |
\c@pgf@countc=\pgfmathresult\relax% |
| 905 |
\ifnum\c@pgf@countc<0 |
| 906 |
\advance\c@pgf@countc by \pgfintersectionsegments\relax |
| 907 |
\fi |
| 908 |
\expandafter\let\expandafter\pgfretval\csname pgf@intersect@path@split@\pgf@insert@intersections@src @\the\c@pgf@countc\endcsname |
| 909 |
\ifx\pgfretval\relax |
| 910 |
\pgferror{There is no intersection segment '#2' in path '#1'}% |
| 911 |
\fi |
| 912 |
}% |
| 913 |
\def\pgfcomputeintersectionsegments@set@src@gobble#1\relax{} |
| 914 |
|
| 915 |
\def\pgfcomputeintersectionsegments@set@src#1{% |
| 916 |
\ifcase#1\relax |
| 917 |
% 0 |
| 918 |
\pgferror{illegal argument supplied.} |
| 919 |
\or |
| 920 |
\def\pgf@insert@intersections@src{a}% |
| 921 |
\or |
| 922 |
\def\pgf@insert@intersections@src{b}% |
| 923 |
\else |
| 924 |
\pgferror{illegal argument supplied.} |
| 925 |
\fi |
| 926 |
}% |
| 927 |
|
| 928 |
\def\pgfintersectionsolutionsortbytime@@{% |
| 929 |
% this is an O(n^2) sort method. It might suffice provided that |
| 930 |
% the number of intersections is small... and it is the same |
| 931 |
% runtime as that of the intersection lib as such (which is, in |
| 932 |
% fact, worse). |
| 933 |
% |
| 934 |
% Note that this bubble-sort-approach has the benefit that if the |
| 935 |
% input sequence *is* actually sorted, that it will have no effect |
| 936 |
% at all (linear time). |
| 937 |
\pgf@intersect@solutions@sortfinishtrue% |
| 938 |
\pgfmathloop% |
| 939 |
\ifnum\pgfmathcounter<\pgfintersectionsolutions\relax% |
| 940 |
\pgfutil@tempcnta=\pgfmathcounter% |
| 941 |
\advance\pgfutil@tempcnta by1\relax% |
| 942 |
% |
| 943 |
% acquire the sort keys... |
| 944 |
\pgfintersectiongetsolutiontimes{\pgfmathcounter}{\pgf@loc@tmp@A@a}{\pgf@loc@tmp@A@b}% |
| 945 |
\pgfintersectiongetsolutiontimes{\the\pgfutil@tempcnta}{\pgf@loc@tmp@B@a}{\pgf@loc@tmp@B@b}% |
| 946 |
% |
| 947 |
\ifdim\csname pgf@loc@tmp@A@\pgf@insert@intersections@src\endcsname pt>% |
| 948 |
\csname pgf@loc@tmp@B@\pgf@insert@intersections@src\endcsname pt\relax% |
| 949 |
\pgf@intersect@solutions@sortfinishfalse% |
| 950 |
% |
| 951 |
\pgfintersectionsolutionsortbytime@swap{pgfpoint@intersect@solution@\pgfmathcounter}% |
| 952 |
{pgfpoint@intersect@solution@\the\pgfutil@tempcnta}% |
| 953 |
% |
| 954 |
\pgfintersectionsolutionsortbytime@swap{pgf@intersect@solution@props@\pgfmathcounter}% |
| 955 |
{pgf@intersect@solution@props@\the\pgfutil@tempcnta}% |
| 956 |
\fi% |
| 957 |
\repeatpgfmathloop% |
| 958 |
\ifpgf@intersect@solutions@sortfinish% |
| 959 |
\else% |
| 960 |
\expandafter\pgfintersectionsolutionsortbytime@@% |
| 961 |
\fi% |
| 962 |
} |
| 963 |
|
| 964 |
|
| 965 |
% #1: either 'a' or 'b', depending on the required part |
| 966 |
% #2: the solution index (starting with 1) |
| 967 |
% Defines \pgfretval to contain the result. |
| 968 |
\def\pgf@fillbetween@get@time@off#1#2{% |
| 969 |
\pgfintersectiongetsolutionsegmentindices{#2}{\pgf@temp@a}{\pgf@temp@b}% |
| 970 |
\edef\pgfretval{\csname pgf@temp@#1\endcsname}% |
| 971 |
}% |
| 972 |
|
| 973 |
% ---------------------------------------------------------------------------------- |
| 974 |
|
| 975 |
|
| 976 |
% Splits a Bezier curve at a designated time 't' |
| 977 |
% using decasteljau |
| 978 |
%-------------------------------------------------- |
| 979 |
% Point lerp(float t, Point A, Point B) { |
| 980 |
% return A*(1-t) + B*t; // + and * overloaded for Points |
| 981 |
% } |
| 982 |
% |
| 983 |
% void split(t, Point P[4], Point L[4], Point R[4]) { |
| 984 |
% Point P01 = lerp(t, P[0], P[1]); |
| 985 |
% Point P12 = lerp(t, P[1], P[2]); |
| 986 |
% Point P23 = lerp(t, P[2], P[3]); |
| 987 |
% Point P012 = lerp(t, P01, P12); |
| 988 |
% Point P123 = lerp(t, P12, P13); |
| 989 |
% Point Q = lerp(t, P012, P123); |
| 990 |
% L[0] = P[0]; L[1] = P01; L[2] = P012; L[3] = Q; |
| 991 |
% R[0] = Q; |
| 992 |
% R[1] = P123; R[2] = P23; R[3] = P[3]; |
| 993 |
% } |
| 994 |
%-------------------------------------------------- |
| 995 |
% INPUT: |
| 996 |
% #1: a value in the range [0,1] which determines the split point |
| 997 |
% #2,#3,#4,#5: the points of the curve, each of the form {<x>}{<y>} |
| 998 |
% |
| 999 |
% OUTPUT: |
| 1000 |
% \pgfretval@L{{<A>}{<B>}{<C>}{<D>}} |
| 1001 |
% \pgfretval@R{{<A>}{<B>}{<C>}{<D>}} |
| 1002 |
% |
| 1003 |
% @see \pgf@split@curveto@softpaths |
| 1004 |
\def\pgf@split@curveto#1#2#3#4#5{% |
| 1005 |
\begingroup |
| 1006 |
\pgf@xa=-#1pt % |
| 1007 |
\advance\pgf@xa by1pt % |
| 1008 |
\edef\pgf@split@one@m@t{\pgf@sys@tonumber\pgf@xa}% |
| 1009 |
% |
| 1010 |
\pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{#2}{#3}% |
| 1011 |
\pgf@split@curveto@tomacro\pgf@split@curveto@p@AB |
| 1012 |
% |
| 1013 |
\pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{#3}{#4}% |
| 1014 |
\pgf@split@curveto@tomacro\pgf@split@curveto@p@BC |
| 1015 |
% |
| 1016 |
\pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{#4}{#5}% |
| 1017 |
\pgf@split@curveto@tomacro\pgf@split@curveto@p@CD |
| 1018 |
% |
| 1019 |
\pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{\pgf@split@curveto@p@AB}{\pgf@split@curveto@p@BC}% |
| 1020 |
\pgf@split@curveto@tomacro\pgf@split@curveto@p@ABC |
| 1021 |
% |
| 1022 |
\pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{\pgf@split@curveto@p@BC}{\pgf@split@curveto@p@CD}% |
| 1023 |
\pgf@split@curveto@tomacro\pgf@split@curveto@p@BCD |
| 1024 |
% |
| 1025 |
\pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{\pgf@split@curveto@p@ABC}{\pgf@split@curveto@p@BCD}% |
| 1026 |
\pgf@split@curveto@tomacro\pgf@split@curveto@p@Q |
| 1027 |
% |
| 1028 |
\xdef\pgf@marshal{% |
| 1029 |
\edef\noexpand\pgfretval@L{{#2}{\pgf@split@curveto@p@AB}{\pgf@split@curveto@p@ABC}{\pgf@split@curveto@p@Q}}% |
| 1030 |
\edef\noexpand\pgfretval@R{{\pgf@split@curveto@p@Q}{\pgf@split@curveto@p@BCD}{\pgf@split@curveto@p@CD}{#5}}% |
| 1031 |
}% |
| 1032 |
\endgroup |
| 1033 |
\pgf@marshal |
| 1034 |
} |
| 1035 |
|
| 1036 |
% Splits a Bezier curve at a designated time 't' |
| 1037 |
% |
| 1038 |
% This variants takes a part of a softpath as input: |
| 1039 |
% |
| 1040 |
% #1: a curveto- a macro containing a softpath of the form |
| 1041 |
% <x><y>\pgfsyssoftpath@curvetosupportatoken<x><y>\pgfsyssoftpath@curvetosupportbtoken<x><y>\pgfsyssoftpath@curvetotoken<x><y> |
| 1042 |
% #2: t in [0,1] |
| 1043 |
% |
| 1044 |
% OUTPUT: \pgfretval@L contains the LEFT segment (in the same softpath format) and \pgfretval@R contains the RIGHT segment (in the softpath format), \pgfretval contains the intersection point (i.e. the point evaluated at 't') |
| 1045 |
\def\pgf@split@curveto@softpaths#1#2{% |
| 1046 |
\expandafter\pgf@split@curveto@softpaths@#1{#2}% |
| 1047 |
} |
| 1048 |
|
| 1049 |
\def\pgf@split@curveto@softpaths@#1#2\pgfsyssoftpath@curvetosupportatoken#3#4\pgfsyssoftpath@curvetosupportbtoken#5#6\pgfsyssoftpath@curvetotoken#7#8#9{% |
| 1050 |
\pgf@split@curveto{#9}% |
| 1051 |
{{#1}{#2}}% |
| 1052 |
{{#3}{#4}}% |
| 1053 |
{{#5}{#6}}% |
| 1054 |
{{#7}{#8}}% |
| 1055 |
\expandafter\pgf@split@curveto@softpaths@@\pgfretval@L\pgfretval@L |
| 1056 |
\expandafter\pgf@split@curveto@softpaths@@\pgfretval@R\pgfretval@R |
| 1057 |
}% |
| 1058 |
|
| 1059 |
\def\pgf@split@curveto@softpaths@@#1#2#3#4#5{% |
| 1060 |
% we can silently omit the moveto component. |
| 1061 |
\def#5{\pgfsyssoftpath@curvetosupportatoken#2\pgfsyssoftpath@curvetosupportbtoken#3\pgfsyssoftpath@curvetotoken#4}% |
| 1062 |
\def\pgfretval{#1}% |
| 1063 |
}% |
| 1064 |
|
| 1065 |
% ---------------------------------------------------------------------------------- |
| 1066 |
|
| 1067 |
% defines \pgf@x, \pgf@y to be A*(1-t) + B*t |
| 1068 |
% #1: the scalar value 't' in [0,1] |
| 1069 |
% #2: the scalar value '1-t' in [0,1] |
| 1070 |
% #3: a 2d point 'A' of the form {<x>}{<y>} |
| 1071 |
% #4: a 2d point 'B' of the form {<x>}{<y>} |
| 1072 |
\def\pgf@split@curveto@lerp#1#2#3#4{% |
| 1073 |
\pgfpointadd |
| 1074 |
{\pgfqpointscale{#2}{\expandafter\pgfqpoint#3}}% |
| 1075 |
{\pgfqpointscale{#1}{\expandafter\pgfqpoint#4}}% |
| 1076 |
}% |
| 1077 |
|
| 1078 |
\def\pgf@split@curveto@tomacro#1{% |
| 1079 |
\edef#1{{\the\pgf@x}{\the\pgf@y}}% |
| 1080 |
} |
| 1081 |
|
| 1082 |
|
| 1083 |
\def\pgfcomputeintersectionsegments@@{% |
| 1084 |
%\message{processing segment \the\c@pgf@path@segment\space (current solution \pgf@insert@cursolution/\pgfintersectionsolutions; target segment \the\c@pgf@path@segment@trg, currentxy \pgfinsert@intersect@tok@currentxy, lastxy \pgfinsert@intersect@tok@lastxy)^^J}% |
| 1085 |
\pgfmathloop |
| 1086 |
% we need to loop: it is fully acceptable if more than one |
| 1087 |
% solution is on the same segment. |
| 1088 |
\ifnum\c@pgf@path@segment=\c@pgf@path@segment@trg |
| 1089 |
% |
| 1090 |
\pgf@insert@intersections@split@segment |
| 1091 |
\expandafter\pgfapplistpushback\pgfretval\to{pgfretval@tmp}% |
| 1092 |
% |
| 1093 |
% |
| 1094 |
% report the current result segment! |
| 1095 |
\pgfapplistlet\pgf@loc@TMPa={pgfretval@tmp}% |
| 1096 |
\expandafter\let\csname pgf@intersect@path@split@\pgf@insert@intersections@src @\c@pgf@path@result\endcsname=\pgf@loc@TMPa% |
| 1097 |
\pgfutil@advancestringcounter\c@pgf@path@result% |
| 1098 |
% ... and start a new result segment. Keep in mind that it |
| 1099 |
% should start with a moveto: |
| 1100 |
\pgfapplistnewempty{pgfretval@tmp}% |
| 1101 |
\csname pgfpoint@intersect@solution@\pgf@insert@cursolution\endcsname% |
| 1102 |
\edef\pgf@loc@TMPa{\noexpand\pgfsyssoftpath@movetotoken{\the\pgf@x}{\the\pgf@y}}% |
| 1103 |
\expandafter\pgfapplistpushback\pgf@loc@TMPa\to{pgfretval@tmp}% |
| 1104 |
% |
| 1105 |
% |
| 1106 |
% OK, iterate: |
| 1107 |
\ifnum\pgf@insert@cursolution=\pgfintersectionsolutions\relax |
| 1108 |
% collect all remaining ones: |
| 1109 |
\c@pgf@path@segment@trg=10000000 % |
| 1110 |
\else |
| 1111 |
\pgfutil@advancestringcounter\pgf@insert@cursolution |
| 1112 |
\pgf@fillbetween@get@time@off{\pgf@insert@intersections@src}{\pgf@insert@cursolution}% |
| 1113 |
\c@pgf@path@segment@trg=\pgfretval\relax |
| 1114 |
\fi |
| 1115 |
\repeatpgfmathloop |
| 1116 |
\expandafter\pgfapplistpushback\pgfinsert@intersect@tok\to{pgfretval@tmp}% |
| 1117 |
\let\pgfinsert@intersect@tok@lastxy=\pgfinsert@intersect@tok@currentxy |
| 1118 |
\advance\c@pgf@path@segment by1 % |
| 1119 |
}% |
| 1120 |
|
| 1121 |
% INPUT: |
| 1122 |
% - \pgfinsert@intersect@tok@type is the current type (one of \pgfsyssoftpath@linetotoken or \pgfsyssoftpath@curvetotoken) |
| 1123 |
% - \pgf@insert@cursolution is the current intersection index |
| 1124 |
% - \pgfinsert@intersect@tok is the current path segment. On output, it is the *remaining* path segment. |
| 1125 |
% - \pgfinsert@intersect@tok@lastxy the (x,y) coordinates of the last seen coordinate. |
| 1126 |
% |
| 1127 |
% OUTPUT: |
| 1128 |
% - \pgfretval the segment which has been splitted off. It will be appended to the result. |
| 1129 |
% - \pgfinsert@intersect@tok the remaining path segment which is to be processed |
| 1130 |
% - \pgfinsert@intersect@tok@lastxy the (x,y) coordinates of the last seen coordinate which is to be processed. |
| 1131 |
\def\pgf@insert@intersections@split@segment{% |
| 1132 |
\ifx\pgfinsert@intersect@tok@type\pgfsyssoftpath@linetotoken |
| 1133 |
\csname pgfpoint@intersect@solution@\pgf@insert@cursolution\endcsname% |
| 1134 |
\edef\pgfretval{\noexpand\pgfsyssoftpath@linetotoken{\the\pgf@x}{\the\pgf@y}}% |
| 1135 |
% ... and keep \pgfinsert@intersect@tok at its current value (it is \pgfsyssoftpath@linetotoken{<next x>}{<next y>}) |
| 1136 |
\else |
| 1137 |
\ifx\pgfinsert@intersect@tok@type\pgfsyssoftpath@curvetotoken |
| 1138 |
% Ah; a curveto. That's more involved! |
| 1139 |
% First, get the time offset of the current intersection: |
| 1140 |
% |
| 1141 |
% Get the global time: |
| 1142 |
\pgfintersectiongetsolutiontimes{\pgf@insert@cursolution}{\pgf@split@it@time@a}{\pgf@split@it@time@b}% |
| 1143 |
% Get time at the beginning of the current solution segment: |
| 1144 |
\pgfintersectiongetsolutionsegmentindices{\pgf@insert@cursolution}{\pgf@split@it@timeoff@a}{\pgf@split@it@timeoff@b}% |
| 1145 |
% compute local time within the current solution segment: |
| 1146 |
\pgf@xa=\csname pgf@split@it@time@\pgf@insert@intersections@src\endcsname pt % |
| 1147 |
\advance\pgf@xa by-\csname pgf@split@it@timeoff@\pgf@insert@intersections@src\endcsname pt % |
| 1148 |
\edef\pgf@split@it@time{\pgf@sys@tonumber\pgf@xa}% |
| 1149 |
% |
| 1150 |
\let\pgf@split@it@start=\pgfinsert@intersect@tok@lastxy |
| 1151 |
% we have to insert the last XY coordinates: |
| 1152 |
\t@pgf@toka=\expandafter{\pgf@split@it@start}% |
| 1153 |
\t@pgf@tokb=\expandafter{\pgfinsert@intersect@tok}% |
| 1154 |
\edef\pgf@temp{\the\t@pgf@toka\the\t@pgf@tokb}% |
| 1155 |
% Split into TWO curveto operations! |
| 1156 |
\pgf@split@curveto@softpaths{\pgf@temp}{\pgf@split@it@time}% |
| 1157 |
% ok, the first returned sub-curveto is the result of this method... |
| 1158 |
\let\pgfretval=\pgfretval@L |
| 1159 |
% ... and the second is the "remainder" which is still to be processed. |
| 1160 |
\let\pgfinsert@intersect@tok=\pgfretval@R |
| 1161 |
\else |
| 1162 |
\pgferror{Unsupported path type \meaning\pgfinsert@intersect@tok@type. Cannot process these paths.}% |
| 1163 |
\fi |
| 1164 |
\fi |
| 1165 |
% |
| 1166 |
\csname pgfpoint@intersect@solution@\pgf@insert@cursolution\endcsname% |
| 1167 |
\edef\pgfinsert@intersect@tok@lastxy{{\the\pgf@x}{\the\pgf@y}}% |
| 1168 |
}% |
| 1169 |
|
| 1170 |
\def\pgf@insert@intersections@loop#1{% |
| 1171 |
\ifx#1\pgf@stop% |
| 1172 |
\let\pgfinsert@intersect@tok\pgfutil@empty% |
| 1173 |
\let\pgfinsert@intersect@tok@type\pgfutil@empty |
| 1174 |
\pgfcomputeintersectionsegments@@% |
| 1175 |
\let\pgfinsert@intersect@next=\relax% |
| 1176 |
\else% |
| 1177 |
\ifx#1\pgfsyssoftpath@movetotoken% |
| 1178 |
\let\pgfinsert@intersect@next=\pgfinsert@intersect@token@moveto% |
| 1179 |
\else% |
| 1180 |
\ifx#1\pgfsyssoftpath@linetotoken% |
| 1181 |
\let\pgfinsert@intersect@next=\pgfinsert@intersect@token@lineto% |
| 1182 |
\else% |
| 1183 |
\ifx#1\pgfsyssoftpath@closepathtoken% |
| 1184 |
\let\pgfinsert@intersect@next=\pgfinsert@intersect@token@close% |
| 1185 |
\else% |
| 1186 |
\ifx#1\pgfsyssoftpath@curvetosupportatoken% |
| 1187 |
\let\pgfinsert@intersect@next=\pgfinsert@intersect@token@curveto% |
| 1188 |
\else% |
| 1189 |
\ifx#1\pgfsyssoftpath@rectcornertoken% |
| 1190 |
\let\pgfinsert@intersect@next=\pgfinsert@intersect@token@rect% |
| 1191 |
\fi% |
| 1192 |
\fi% |
| 1193 |
\fi% |
| 1194 |
\fi% |
| 1195 |
\fi% |
| 1196 |
\fi% |
| 1197 |
\pgfinsert@intersect@next} |
| 1198 |
|
| 1199 |
\def\pgfinsert@intersect@token@moveto#1#2{% |
| 1200 |
\def\pgfinsert@intersect@tok{\pgfsyssoftpath@movetotoken{#1}{#2}}% |
| 1201 |
\let\pgfinsert@intersect@tok@type\pgfsyssoftpath@movetotoken |
| 1202 |
\def\pgfinsert@intersect@tok@lastxy{{#1}{#2}}% |
| 1203 |
\expandafter\pgfapplistpushback\pgfinsert@intersect@tok\to{pgfretval@tmp}% |
| 1204 |
\pgf@insert@intersections@loop% |
| 1205 |
} |
| 1206 |
|
| 1207 |
\def\pgfinsert@intersect@token@lineto#1#2{% |
| 1208 |
\def\pgfinsert@intersect@tok{\pgfsyssoftpath@linetotoken{#1}{#2}}% |
| 1209 |
\let\pgfinsert@intersect@tok@type\pgfsyssoftpath@linetotoken |
| 1210 |
\def\pgfinsert@intersect@tok@currentxy{{#1}{#2}}% |
| 1211 |
\pgfcomputeintersectionsegments@@% |
| 1212 |
\pgf@insert@intersections@loop |
| 1213 |
} |
| 1214 |
\def\pgfinsert@intersect@token@close#1#2{% |
| 1215 |
\def\pgfinsert@intersect@tok{\pgfsyssoftpath@closepathtoken{#1}{#2}}% |
| 1216 |
\let\pgfinsert@intersect@tok@type\pgfsyssoftpath@linetotoken |
| 1217 |
\def\pgfinsert@intersect@tok@currentxy{{#1}{#2}}% |
| 1218 |
\pgfcomputeintersectionsegments@@% |
| 1219 |
\pgf@insert@intersections@loop |
| 1220 |
} |
| 1221 |
|
| 1222 |
\def\pgfinsert@intersect@token@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{% |
| 1223 |
\def\pgfinsert@intersect@tok{\pgfsyssoftpath@curvetosupportatoken{#1}{#2}\pgfsyssoftpath@curvetosupportbtoken{#3}{#4}\pgfsyssoftpath@curvetotoken{#5}{#6}}% |
| 1224 |
\let\pgfinsert@intersect@tok@type\pgfsyssoftpath@curvetotoken |
| 1225 |
\def\pgfinsert@intersect@tok@currentxy{{#5}{#6}}% |
| 1226 |
\pgfcomputeintersectionsegments@@% |
| 1227 |
\pgf@insert@intersections@loop |
| 1228 |
} |
| 1229 |
|
| 1230 |
\def\pgfinsert@intersect@token@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{% |
| 1231 |
\pgf@xa=#1\relax% |
| 1232 |
\advance\pgf@xa by#3\relax% |
| 1233 |
\pgf@ya=#2\relax% |
| 1234 |
\advance\pgf@ya by#4\relax% |
| 1235 |
\edef\pgf@marshal{% |
| 1236 |
\noexpand\pgfsyssoftpath@movetotoken{#1}{#2}% |
| 1237 |
\noexpand\pgfsyssoftpath@linetotoken{#1}{\the\pgf@ya}% |
| 1238 |
\noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{\the\pgf@ya}% |
| 1239 |
\noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{#2}% |
| 1240 |
\noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}% |
| 1241 |
}% |
| 1242 |
\expandafter\pgf@insert@intersections@loop\pgf@marshal% |
| 1243 |
} |
| 1244 |
|
| 1245 |
|
| 1246 |
% #1: a macro containing the clip path. More precisely, it is supposed to be a return value of \pgfgetpath. |
| 1247 |
\def\pgffillbetweensetsoftclippathfirst#1{% |
| 1248 |
\let\pgfpathfillbetween@softclip@A=#1% |
| 1249 |
}% |
| 1250 |
|
| 1251 |
% #1: a macro containing the clip path. More precisely, it is supposed to be a return value of \pgfgetpath. |
| 1252 |
\def\pgffillbetweensetsoftclippathsecond#1{% |
| 1253 |
\let\pgfpathfillbetween@softclip@B=#1% |
| 1254 |
}% |
| 1255 |
|
| 1256 |
% #1: a macro containing the clip path. More precisely, it is supposed to be a return value of \pgfgetpath. |
| 1257 |
\def\pgffillbetweensetsoftclippath#1{% |
| 1258 |
\pgffillbetweensetsoftclippathfirst{#1}% |
| 1259 |
\pgffillbetweensetsoftclippathsecond{#1}% |
| 1260 |
} |
| 1261 |
|
| 1262 |
% Default: no clip paths |
| 1263 |
\pgffillbetweensetsoftclippathfirst{\pgfutil@empty} |
| 1264 |
\pgffillbetweensetsoftclippathsecond{\pgfutil@empty} |
| 1265 |
\endinput |