| 1 |
% Copyright 2018 by Till Tantau |
| 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 Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
\ProvidesFileRCS{pgfcorepathprocessing.code.tex} |
| 11 |
|
| 12 |
|
| 13 |
% Split a path at the last subpath of a path |
| 14 |
% |
| 15 |
% #1 = a macro that stores a path |
| 16 |
% |
| 17 |
% Description: |
| 18 |
% |
| 19 |
% This command will split the path into two parts: |
| 20 |
% |
| 21 |
% \pgfprocessresultpathprefix |
| 22 |
% The part of the path before the last subpath. |
| 23 |
% |
| 24 |
% \pgfprocessresultpathsuffix |
| 25 |
% The last subpath on the path. |
| 26 |
% |
| 27 |
% #1 will always be equal to the contents of the two above macros |
| 28 |
% concatenated. Normally, your objective will be to modify the |
| 29 |
% \pgfprocessresultpathsuffix and then concatenate the result. |
| 30 |
|
| 31 |
\def\pgfprocesssplitpath#1{% |
| 32 |
\let\pgfprocessresultpathprefix\pgfutil@empty% |
| 33 |
\let\pgfprocessresultpathsuffix\pgfutil@empty% |
| 34 |
\let\pgf@next\pgf@process@split% |
| 35 |
\expandafter\pgf@process@split#1\pgfsyssoftpath@movetotoken{}{}\pgf@stop% |
| 36 |
} |
| 37 |
|
| 38 |
\def\pgf@process@split#1\pgfsyssoftpath@movetotoken#2#3#4{% |
| 39 |
\ifx#4\pgf@stop% ok, end reached! |
| 40 |
\expandafter\def\expandafter\pgfprocessresultpathsuffix\expandafter{\pgfprocessresultpathsuffix#1}% |
| 41 |
\let\pgf@next\pgfutil@gobble% |
| 42 |
\else% |
| 43 |
\expandafter\expandafter\expandafter\def% |
| 44 |
\expandafter\expandafter\expandafter\pgfprocessresultpathprefix% |
| 45 |
\expandafter\expandafter\expandafter{\expandafter\pgfprocessresultpathprefix\pgfprocessresultpathsuffix#1}% |
| 46 |
\def\pgfprocessresultpathsuffix{\pgfsyssoftpath@movetotoken{#2}{#3}}% |
| 47 |
\fi% |
| 48 |
\pgf@next#4% |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
% Split a subpath at the end |
| 54 |
% |
| 55 |
% #1 = a macro that stores an open subpath that contains at least two |
| 56 |
% path commands (so, not just a moveto); |
| 57 |
% |
| 58 |
% Description: |
| 59 |
% |
| 60 |
% Splits the subpath into two parts: |
| 61 |
% |
| 62 |
% \pgfprocessresultsubpathsuffix |
| 63 |
% This macro contains the last two "relevant" path commands: The end |
| 64 |
% of the path command that led to the last path command and this |
| 65 |
% last path command. In essence, this macro contains everything you |
| 66 |
% "need to modify" if you wish to modify the end of the path. |
| 67 |
% |
| 68 |
% \pgfprocessresultsubpathprefix |
| 69 |
% Everything before the previous macro on the subpath. |
| 70 |
|
| 71 |
\def\pgfprocesssplitsubpath#1{% |
| 72 |
% First, we need to find the end: |
| 73 |
\let\pgf@tempa\pgfutil@empty% |
| 74 |
\let\pgf@tempb\pgfutil@empty% |
| 75 |
\let\pgf@tempc\pgfutil@empty% |
| 76 |
\let\pgf@tempd\pgfutil@empty% |
| 77 |
\let\pgfprocessresultsubpathprefix\pgfutil@empty% |
| 78 |
\let\pgfprocessresultsubpathsuffix\pgfutil@empty% |
| 79 |
\let\pgf@next\pgf@split@subpath% |
| 80 |
\expandafter\pgf@split@subpath#1\pgf@stop% |
| 81 |
} |
| 82 |
|
| 83 |
\newif\ifpgf@split@move |
| 84 |
|
| 85 |
\def\pgf@split@subpath#1#2#3#4{% |
| 86 |
\ifx#4\pgf@stop% |
| 87 |
\expandafter\def\expandafter\pgfprocessresultsubpathsuffix\expandafter{\pgfprocessresultsubpathsuffix#1{#2}{#3}}% |
| 88 |
\let\pgf@next\pgfutil@gobble% |
| 89 |
\else% |
| 90 |
\pgf@split@movetrue% |
| 91 |
\ifx#1\pgfsyssoftpath@curvetosupportatoken% |
| 92 |
\pgf@split@movefalse% |
| 93 |
\else |
| 94 |
\ifx#1\pgfsyssoftpath@curvetosupportbtoken% |
| 95 |
\pgf@split@movefalse% |
| 96 |
\fi% |
| 97 |
\fi% |
| 98 |
\ifpgf@split@move% |
| 99 |
\expandafter\expandafter\expandafter\def% |
| 100 |
\expandafter\expandafter\expandafter\pgfprocessresultsubpathprefix% |
| 101 |
\expandafter\expandafter\expandafter{% |
| 102 |
\expandafter\pgfprocessresultsubpathprefix\pgfprocessresultsubpathsuffix}% |
| 103 |
\def\pgfprocessresultsubpathsuffix{#1{#2}{#3}}% |
| 104 |
\else% |
| 105 |
\expandafter\def\expandafter\pgfprocessresultsubpathsuffix\expandafter{\pgfprocessresultsubpathsuffix#1{#2}{#3}}% |
| 106 |
\fi% |
| 107 |
\fi% |
| 108 |
\pgf@next#4% |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
% Extract start and end vectors of a path |
| 115 |
% |
| 116 |
% #1 = a macro that stores a path |
| 117 |
% |
| 118 |
% Description: |
| 119 |
% |
| 120 |
% This command will extract the first and second coordinate on the |
| 121 |
% path as well as the last and second-last. These coordinates will be |
| 122 |
% put in the pgfpoint-macros \pgfpointfirstonpath, |
| 123 |
% \pgfpointsecondonpath, \pgfpointsecondlastonpath, and |
| 124 |
% \pgfpointlastonpath. If the path is empty, these macros are set to |
| 125 |
% \pgfpointorigin. |
| 126 |
% |
| 127 |
% Example: |
| 128 |
% |
| 129 |
% \pgfsyssoftpath@moveto{0}{0} |
| 130 |
% \pgfsyssoftpath@lineto{10}{10} |
| 131 |
% \pgfsyssoftpath@curveto{20}{20}{30}{30}{40}{40} |
| 132 |
% \pgfsyssoftpath@getcurrentpath\mypath |
| 133 |
% \pgfprocesspathextractpoints\mypath |
| 134 |
% |
| 135 |
% % \pgfpointfirstonpath is now \pgfpoint{0}{0} |
| 136 |
% % \pgfpointsecondonpath is now \pgfpoint{10bp}{10bp} |
| 137 |
% % \pgfpointsecondlastonpath is now \pgfpoint{30bp}{30bp} |
| 138 |
% % \pgfpointlastonpath is now \pgfpoint{40bp}{40bp} |
| 139 |
|
| 140 |
\def\pgfprocesspathextractpoints#1{% |
| 141 |
\ifx#1\pgfutil@empty% |
| 142 |
\let\pgfpointfirstonpath=\pgfpointorigin% |
| 143 |
\let\pgfpointsecondonpath=\pgfpointorigin% |
| 144 |
\let\pgfpointsecondlastonpath=\pgfpointorigin% |
| 145 |
\let\pgfpointlastonpath=\pgfpointorigin% |
| 146 |
\else% |
| 147 |
\expandafter\pgf@extractprocessorfirst#1\pgf@stop% |
| 148 |
\fi% |
| 149 |
} |
| 150 |
|
| 151 |
\def\pgf@extractprocessorfirst#1#2#3#4{% |
| 152 |
\def\pgfpointfirstonpath{\pgfqpoint{#2}{#3}}% |
| 153 |
\ifx#4\pgf@stop% |
| 154 |
% pretty short path... |
| 155 |
\let\pgfpointsecondonpath=\pgfpointfirstonpath% |
| 156 |
\let\pgfpointsecondlastonpath=\pgfpointfirstonpath% |
| 157 |
\let\pgfpointlastonpath=\pgfpointfirstonpath% |
| 158 |
\let\next=\pgfutil@gobble% |
| 159 |
\else |
| 160 |
\let\next=\pgf@extractprocessorsecond% |
| 161 |
\fi% |
| 162 |
\next#4% |
| 163 |
} |
| 164 |
|
| 165 |
\def\pgf@extractprocessorsecond#1{% |
| 166 |
\ifx#1\pgfsyssoftpath@movetotoken% |
| 167 |
% Reset things... |
| 168 |
\let\pgf@next=\pgf@extractprocessorfirst% |
| 169 |
\else% |
| 170 |
\let\pgf@next=\pgf@@extractprocessorsecond% |
| 171 |
\fi% |
| 172 |
\pgf@next#1% |
| 173 |
} |
| 174 |
\def\pgf@@extractprocessorsecond#1#2#3#4{% |
| 175 |
\def\pgfpointsecondonpath{\pgfqpoint{#2}{#3}}% |
| 176 |
\let\pgfpointsecondlastonpath=\pgfpointfirstonpath% |
| 177 |
\let\pgfpointlastonpath=\pgfpointsecondonpath% |
| 178 |
\ifx#4\pgf@stop% |
| 179 |
% short path... |
| 180 |
\let\next=\pgfutil@gobble% |
| 181 |
\else |
| 182 |
\let\next=\pgf@extractprocessorother% |
| 183 |
\fi% |
| 184 |
\next#4% |
| 185 |
} |
| 186 |
|
| 187 |
\def\pgf@extractprocessorother#1{% |
| 188 |
\ifx#1\pgfsyssoftpath@movetotoken% |
| 189 |
% Reset things... |
| 190 |
\let\pgf@next=\pgf@extractprocessorfirst% |
| 191 |
\else% |
| 192 |
\let\pgf@next=\pgf@@extractprocessorother% |
| 193 |
\fi% |
| 194 |
\pgf@next#1% |
| 195 |
} |
| 196 |
\def\pgf@@extractprocessorother#1#2#3#4{% |
| 197 |
\let\pgfpointsecondlastonpath=\pgfpointlastonpath% |
| 198 |
\def\pgfpointlastonpath{\pgfqpoint{#2}{#3}}% |
| 199 |
\ifx#4\pgf@stop% |
| 200 |
% end! |
| 201 |
\let\next=\pgfutil@gobble% |
| 202 |
\fi% |
| 203 |
\next#4% |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
% Check for closepath and rectangles |
| 209 |
% |
| 210 |
% #1 = a macro that stores a path |
| 211 |
% #2 = command to be executed when a closepath or a rectangle is encountered |
| 212 |
% |
| 213 |
% Example: |
| 214 |
% |
| 215 |
% \pgfsyssoftpath@moveto{0}{0} |
| 216 |
% \pgfsyssoftpath@lineto{10}{10} |
| 217 |
% \pgfsyssoftpath@curveto{20}{20}{30}{30}{40}{40} |
| 218 |
% \pgfsyssoftpath@getcurrentpath\mypath |
| 219 |
% \pgfprocesscheckclosed{\mypath}{\pgf@drawarrowsfalse} |
| 220 |
|
| 221 |
\def\pgfprocesscheckclosed#1#2{% |
| 222 |
{% |
| 223 |
\global\let\pgf@proc@todo=\relax% |
| 224 |
\let\pgfsyssoftpath@movetotoken=\pgfutil@gobbletwo% |
| 225 |
\let\pgfsyssoftpath@linetotoken=\pgfutil@gobbletwo% |
| 226 |
\let\pgfsyssoftpath@curvetosupportatoken=\pgfutil@gobbletwo% |
| 227 |
\let\pgfsyssoftpath@curvetosupportbtoken=\pgfutil@gobbletwo% |
| 228 |
\let\pgfsyssoftpath@curvetotoken=\pgfutil@gobbletwo% |
| 229 |
\def\pgfsyssoftpath@rectcornertoken{\gdef\pgf@proc@todo{#2}\pgfutil@gobbletwo}% |
| 230 |
\def\pgfsyssoftpath@rectsizetoken{\gdef\pgf@proc@todo{#2}\pgfutil@gobbletwo}% |
| 231 |
\def\pgfsyssoftpath@closepathtoken{\gdef\pgf@proc@todo{#2}\pgfutil@gobbletwo}% |
| 232 |
#1% |
| 233 |
}% |
| 234 |
\pgf@proc@todo% |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
% Resolve specialround |
| 239 |
% |
| 240 |
% #1 = a macro that stores a path |
| 241 |
% #2 = a macro that stores the new path |
| 242 |
% |
| 243 |
% Description: |
| 244 |
% |
| 245 |
% Resolves all specialround tokens. When such a token is encountered, |
| 246 |
% the objective is to replace the next corner by a rounded corner. |
| 247 |
% |
| 248 |
|
| 249 |
\def\pgfprocessround#1#2{% |
| 250 |
% first, check whether #1 contains \pgfsyssoftpath@specialroundtoken. |
| 251 |
% if not, do quick assignment! |
| 252 |
\expandafter\pgf@processroundcheck\expandafter#1\expandafter#2#1\pgfsyssoftpath@specialroundtoken\pgf@stop% |
| 253 |
} |
| 254 |
|
| 255 |
\def\pgf@processroundcheck#1#2#3\pgfsyssoftpath@specialroundtoken#4\pgf@stop{% |
| 256 |
\def\pgf@test{#4}% |
| 257 |
\ifx\pgf@test\pgfutil@empty% |
| 258 |
% ok, nothing to be done! |
| 259 |
\let#2=#1% |
| 260 |
\else% |
| 261 |
% very well... |
| 262 |
\pgf@@processround#1#2% |
| 263 |
\fi% |
| 264 |
} |
| 265 |
|
| 266 |
|
| 267 |
\def\pgf@@processround#1#2{% |
| 268 |
\let\pgfprocess@newpath\pgfutil@empty% |
| 269 |
\let\pgfprocess@moveto\pgfutil@empty% |
| 270 |
\let\pgfprocess@firstto\pgfutil@empty% |
| 271 |
\let\pgfprocess@segment\pgfutil@empty% |
| 272 |
\pgf@xa=0pt% |
| 273 |
\pgf@ya=0pt% |
| 274 |
\expandafter\pgfprocess@round#1\pgf@stop{0pt}{0pt}% |
| 275 |
\expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@moveto}% |
| 276 |
\expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@segment}% |
| 277 |
\let#2=\pgfprocess@newpath% |
| 278 |
} |
| 279 |
|
| 280 |
\def\pgfprocess@round#1#2#3{% |
| 281 |
\ifx#1\pgf@stop% |
| 282 |
\let\next=\relax% |
| 283 |
\else% |
| 284 |
\ifx#1\pgfsyssoftpath@specialroundtoken% |
| 285 |
\def\pgfprocess@savex{#2}% |
| 286 |
\def\pgfprocess@savey{#3}% |
| 287 |
\let\next=\pgfprocess@specialround% |
| 288 |
\ifdim#2=0pt% |
| 289 |
\ifdim#3=0pt% |
| 290 |
\let\next=\pgfprocess@round% skip! |
| 291 |
\fi% |
| 292 |
\fi% |
| 293 |
\else% |
| 294 |
\ifx\pgfprocess@firstto\pgfutil@empty% |
| 295 |
\def\pgfprocess@firstto{{#2}{#3}}% |
| 296 |
\fi% |
| 297 |
\pgf@xa=#2% |
| 298 |
\pgf@ya=#3% |
| 299 |
\ifx#1\pgfsyssoftpath@movetotoken% |
| 300 |
% ok, move old segment to newpath |
| 301 |
\expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@moveto}% |
| 302 |
\expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@newpath\expandafter{\pgfprocess@segment}% |
| 303 |
\def\pgfprocess@moveto{#1{#2}{#3}}% |
| 304 |
\let\pgfprocess@firstto=\pgfutil@empty% |
| 305 |
\let\pgfprocess@segment=\pgfutil@empty% |
| 306 |
\else% |
| 307 |
\pgfutil@g@addto@macro\pgfprocess@segment{#1{#2}{#3}}% |
| 308 |
\fi% |
| 309 |
\let\next=\pgfprocess@round% |
| 310 |
\fi% |
| 311 |
\fi% |
| 312 |
\next% |
| 313 |
} |
| 314 |
|
| 315 |
\def\pgfprocess@specialround#1#2#3{% |
| 316 |
\ifx\pgfprocess@firstto\pgfutil@empty% |
| 317 |
\def\pgfprocess@firstto{{#2}{#3}}% |
| 318 |
\fi% |
| 319 |
\let\next=\pgfprocess@round% default: do nothing |
| 320 |
\ifx#1\pgfsyssoftpath@linetotoken% |
| 321 |
% Ok, round a lineto |
| 322 |
\let\next=\pgfprocess@specialroundcope% |
| 323 |
\else% |
| 324 |
\ifx#1\pgfsyssoftpath@curvetosupportatoken% |
| 325 |
% Ok, round a curveto. |
| 326 |
\let\next=\pgfprocess@specialroundcurveto% |
| 327 |
\else% |
| 328 |
\ifx#1\pgfsyssoftpath@closepathtoken% |
| 329 |
% Ok, round a closepath (this is tricky...) |
| 330 |
\let\next=\pgfprocess@specialroundclose% |
| 331 |
\fi% |
| 332 |
\fi% |
| 333 |
\fi% |
| 334 |
\next#1{#2}{#3}% |
| 335 |
}% |
| 336 |
|
| 337 |
\def\pgfprocess@specialroundcope#1#2#3#4#5#6{% |
| 338 |
\let\next=\pgfprocess@round% do nothing by default |
| 339 |
\let\pgfprocess@continueafterrounding=\pgfprocess@round% |
| 340 |
\ifx#4\pgfsyssoftpath@linetotoken% |
| 341 |
% ok, let's get kicking... |
| 342 |
\pgf@xc=#5% |
| 343 |
\pgf@yc=#6% |
| 344 |
\let\next=\pgfprocess@@specialround% |
| 345 |
\else% |
| 346 |
\ifx#4\pgfsyssoftpath@curvetosupportatoken% |
| 347 |
\pgf@xc=#5% |
| 348 |
\pgf@yc=#6% |
| 349 |
\let\next=\pgfprocess@@specialround% |
| 350 |
\else% |
| 351 |
\ifx#4\pgfsyssoftpath@closepathtoken% |
| 352 |
\pgf@xc=#5% |
| 353 |
\pgf@yc=#6% |
| 354 |
\let\next=\pgfprocess@@specialround% |
| 355 |
\else |
| 356 |
\ifx#4\pgfsyssoftpath@specialroundtoken% |
| 357 |
\let\next=\pgfprocess@@findrightcoordinates% |
| 358 |
\fi% |
| 359 |
\fi% |
| 360 |
\fi% |
| 361 |
\fi% |
| 362 |
\next#1{#2}{#3}#4{#5}{#6}% |
| 363 |
} |
| 364 |
|
| 365 |
\def\pgfprocess@@findrightcoordinates#1#2#3#4#5#6#7#8#9{% |
| 366 |
\pgf@xc=#8% |
| 367 |
\pgf@yc=#9% |
| 368 |
\pgfprocess@@specialround#1{#2}{#3}#4{#5}{#6}#7{#8}{#9}% |
| 369 |
} |
| 370 |
|
| 371 |
\def\pgfprocess@@specialround#1#2#3{% |
| 372 |
\pgfutil@g@addto@macro\pgfprocess@segment{#1}% |
| 373 |
% calculate start coordinate of the curve |
| 374 |
\pgf@xb=#2% |
| 375 |
\pgf@yb=#3% |
| 376 |
% |
| 377 |
\edef\pgf@marshal% |
| 378 |
{\noexpand\pgfpointlineatdistance{\pgfprocess@savex}% |
| 379 |
{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% |
| 380 |
{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}}% |
| 381 |
\pgf@process{\pgf@marshal}% |
| 382 |
\pgf@xa=\pgf@x% save start point of added curve |
| 383 |
\pgf@ya=\pgf@y% |
| 384 |
\edef\pgfprocess@addition{{\the\pgf@x}{\the\pgf@y}}% |
| 385 |
\expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% |
| 386 |
% |
| 387 |
% now add curve |
| 388 |
% |
| 389 |
\edef\pgf@marshal% |
| 390 |
{\noexpand\pgfpointlineatdistance{\pgfprocess@savey}% |
| 391 |
{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% |
| 392 |
{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}}% |
| 393 |
\pgf@process{\pgf@marshal}% |
| 394 |
\pgf@xc=\pgf@x% save end point of added curve |
| 395 |
\pgf@yc=\pgf@y% |
| 396 |
% calculate first support: |
| 397 |
{% |
| 398 |
\pgf@x=\pgf@xb% |
| 399 |
\pgf@y=\pgf@yb% |
| 400 |
\advance\pgf@x by-\pgf@xa% |
| 401 |
\advance\pgf@y by-\pgf@ya% |
| 402 |
\advance\pgf@xa by 0.5522847\pgf@x% |
| 403 |
\advance\pgf@ya by 0.5522847\pgf@y% |
| 404 |
\edef\pgfprocess@addition{\noexpand\pgfsyssoftpath@curvetosupportatoken{\the\pgf@xa}{\the\pgf@ya}}% |
| 405 |
\expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% |
| 406 |
}% |
| 407 |
% calculate second support: |
| 408 |
{% |
| 409 |
\pgf@x=\pgf@xb% |
| 410 |
\pgf@y=\pgf@yb% |
| 411 |
\advance\pgf@x by-\pgf@xc% |
| 412 |
\advance\pgf@y by-\pgf@yc% |
| 413 |
\advance\pgf@xc by 0.5522847\pgf@x% |
| 414 |
\advance\pgf@yc by 0.5522847\pgf@y% |
| 415 |
\edef\pgfprocess@addition{\noexpand\pgfsyssoftpath@curvetosupportbtoken{\the\pgf@xc}{\the\pgf@yc}}% |
| 416 |
\expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% |
| 417 |
}% |
| 418 |
% add end: |
| 419 |
\edef\pgfprocess@addition{\noexpand\pgfsyssoftpath@curvetotoken{\the\pgf@xc}{\the\pgf@yc}}% |
| 420 |
\expandafter\pgfutil@g@addto@macro\expandafter\pgfprocess@segment\expandafter{\pgfprocess@addition}% |
| 421 |
% |
| 422 |
% continue! |
| 423 |
% |
| 424 |
\pgf@xa=#2% |
| 425 |
\pgf@ya=#3% |
| 426 |
\pgfprocess@continueafterrounding% |
| 427 |
} |
| 428 |
|
| 429 |
\def\pgfprocess@specialroundcurveto#1#2#3#4#5#6{% |
| 430 |
\pgfutil@g@addto@macro\pgfprocess@segment{#1{#2}{#3}#4{#5}{#6}}% supports |
| 431 |
\pgf@xa=#5% |
| 432 |
\pgf@ya=#6% |
| 433 |
\pgfprocess@specialroundcope} |
| 434 |
|
| 435 |
\def\pgfprocess@specialroundclose{% |
| 436 |
\let\next=\pgfprocess@round% |
| 437 |
\ifx\pgfprocess@moveto\pgfutil@empty% |
| 438 |
\else% |
| 439 |
\ifx\pgfprocess@firstto\pgfutil@empty% |
| 440 |
\else% |
| 441 |
\expandafter\pgfprocess@@specialclosetarget\pgfprocess@firstto% |
| 442 |
\let\pgfprocess@continueafterrounding=\pgfprocess@cleanupafterclose% |
| 443 |
\edef\next{% |
| 444 |
\noexpand\pgfprocess@@specialround% |
| 445 |
\expandafter\expandafter\expandafter\noexpand\expandafter\pgfprocess@@specialclosemoveto\pgfprocess@moveto% |
| 446 |
}% |
| 447 |
\fi% |
| 448 |
\fi% |
| 449 |
\next% |
| 450 |
} |
| 451 |
|
| 452 |
\def\pgfprocess@@specialclosetarget#1#2{% |
| 453 |
\pgf@xc=#1% |
| 454 |
\pgf@yc=#2% |
| 455 |
} |
| 456 |
|
| 457 |
\def\pgfprocess@@specialclosemoveto#1#2#3{% |
| 458 |
\pgfsyssoftpath@linetotoken{#2}{#3}% |
| 459 |
} |
| 460 |
|
| 461 |
|
| 462 |
\def\pgfprocess@cleanupafterclose#1#2#3{% |
| 463 |
\edef\pgfprocess@moveto{\noexpand\pgfsyssoftpath@movetotoken{\the\pgf@xc}{\the\pgf@yc}}% |
| 464 |
\edef\pgf@marshal{\noexpand\pgfprocess@round\noexpand\pgfsyssoftpath@closepathtoken{\the\pgf@xc}{\the\pgf@yc}}% |
| 465 |
\pgf@marshal% |
| 466 |
} |
| 467 |
|
| 468 |
|
| 469 |
% Replace start and end coordinates of a path |
| 470 |
% |
| 471 |
% #1 = new start coordinate |
| 472 |
% #2 = new end coordinate |
| 473 |
% |
| 474 |
% Description: |
| 475 |
% |
| 476 |
% This command will replace the first and last coordinates on a path |
| 477 |
% by the given coordinates. |
| 478 |
% |
| 479 |
% Example: |
| 480 |
% |
| 481 |
% \pgfsyssoftpath@moveto{0}{0} |
| 482 |
% \pgfsyssoftpath@lineto{10}{10} |
| 483 |
% \pgfsyssoftpath@curveto{20}{20}{30}{10}{40}{0} |
| 484 |
% \pgfsyssoftpath@getcurrentpath\mypath |
| 485 |
% \pgfsetlinewidth{2pt} |
| 486 |
% \pgfusepath{stroke} |
| 487 |
% \pgfprocesspathextractpoints{\mypath} |
| 488 |
% \pgfprocesspathreplacestartandend{\mypath} |
| 489 |
% {\pgfpointlineatdistance{2pt}{\pgfpointfirstonpath}{\pgfpointsecondonpath}}% |
| 490 |
% {\pgfpointlineatdistance{2pt}{\pgfpointlastonpath}{\pgfpointsecondlastonpath}}% |
| 491 |
% \pgfsyssoftpath@setcurrentpath\mypath |
| 492 |
% \pgfsetlinewidth{1pt} |
| 493 |
% \color{red} |
| 494 |
% \pgfusepath{stroke} |
| 495 |
|
| 496 |
\def\pgfprocesspathreplacestartandend#1#2#3{% |
| 497 |
\ifx#1\pgfutil@empty% |
| 498 |
\else% |
| 499 |
{% |
| 500 |
% We (mis)use the current path to store (in a buffered manner) the |
| 501 |
% rest path. |
| 502 |
\pgfsyssoftpath@getcurrentpath\pgf@replace@origpath% |
| 503 |
\let\pgf@prepath=\pgfutil@empty% |
| 504 |
\pgf@process{#3}% |
| 505 |
\pgf@xa=\pgf@x% |
| 506 |
\pgf@ya=\pgf@y% |
| 507 |
\pgf@process{#2}% |
| 508 |
\expandafter\pgf@replaceprocessfirst#1\pgf@stop% |
| 509 |
\pgfsyssoftpath@getcurrentpath\pgf@restpath% |
| 510 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef% |
| 511 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter#1% |
| 512 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{% |
| 513 |
\expandafter\expandafter\expandafter\pgf@prepath% |
| 514 |
\expandafter\pgf@newstart\pgf@restpath}% |
| 515 |
% Restore current path |
| 516 |
\pgfsyssoftpath@setcurrentpath\pgf@replace@origpath% |
| 517 |
}% |
| 518 |
\fi% |
| 519 |
} |
| 520 |
|
| 521 |
\def\pgf@replaceprocessfirst#1#2#3#4{% |
| 522 |
\def\pgf@origstart{#1{#2}{#3}}% |
| 523 |
\edef\pgf@newstart{\noexpand#1{\the\pgf@x}{\the\pgf@y}}% |
| 524 |
\pgfsyssoftpath@setcurrentpath\pgfutil@empty% |
| 525 |
\ifx#4\pgf@stop% |
| 526 |
\let\pgf@next=\pgfutil@gobble% |
| 527 |
\else% |
| 528 |
\let\pgf@next=\pgf@replaceprocessother% |
| 529 |
\let\pgf@@next=\pgf@@replaceprocessother% |
| 530 |
\fi% |
| 531 |
\pgf@next#4% |
| 532 |
} |
| 533 |
|
| 534 |
\def\pgf@replaceprocessother#1{% |
| 535 |
\ifx#1\pgfsyssoftpath@movetotoken% |
| 536 |
\pgf@replace@handle@move% |
| 537 |
\fi% |
| 538 |
\pgf@@next#1% |
| 539 |
} |
| 540 |
\def\pgf@@replaceprocessother#1#2#3#4{% |
| 541 |
\ifx#4\pgf@stop% |
| 542 |
\edef\pgf@restpathaddition{{\noexpand#1{\the\pgf@xa}{\the\pgf@ya}}}% |
| 543 |
\expandafter\pgfsyssoftpath@addtocurrentpath\pgf@restpathaddition% |
| 544 |
\let\pgf@next=\pgfutil@gobble% |
| 545 |
\else% |
| 546 |
\pgfsyssoftpath@addtocurrentpath{#1{#2}{#3}}% |
| 547 |
\fi% |
| 548 |
\pgf@next#4% |
| 549 |
} |
| 550 |
|
| 551 |
\def\pgf@replace@handle@move{% |
| 552 |
\pgfsyssoftpath@getcurrentpath\pgf@restpath% |
| 553 |
% Arggghh! Must reset everything! |
| 554 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef% |
| 555 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\pgf@prepath% |
| 556 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{% |
| 557 |
\expandafter\expandafter\expandafter\pgf@prepath% |
| 558 |
\expandafter\pgf@origstart\pgf@restpath}% |
| 559 |
% Redo first. |
| 560 |
\let\pgf@@next=\pgf@replaceprocessfirst% |
| 561 |
} |
| 562 |
|
| 563 |
\endinput |