| 1 |
% Copyright 2019 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{pgfcorepathconstruct.code.tex} |
| 11 |
|
| 12 |
|
| 13 |
\newdimen\pgf@path@lastx |
| 14 |
\newdimen\pgf@path@lasty |
| 15 |
|
| 16 |
\let\pgfgetpath=\pgfsyssoftpath@getcurrentpath |
| 17 |
\let\pgfsetpath=\pgfsyssoftpath@setcurrentpath |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
% Replace corners by arcs. |
| 22 |
% |
| 23 |
% #1 = in-size of arc |
| 24 |
% #2 = out-size of arc |
| 25 |
% |
| 26 |
% Description: |
| 27 |
% |
| 28 |
% This command influences path construction command like |
| 29 |
% \pgfpathlineto or \pgfpatharc. It will cause the corners at the end |
| 30 |
% of these commands to be replaced by little arcs. If the |
| 31 |
% corner is a 90 degrees corner and if #1=#2, a quarter-circle of |
| 32 |
% radius #1 is put in place of the corner. If #1 and #2 are different, |
| 33 |
% the quarter circle will instead by a quarter ellipse. If the angle |
| 34 |
% is different from 90 degrees, a deformed quarter circle will |
| 35 |
% result, which may or may not be desirable. For a ``perfect'' arc you |
| 36 |
% must use the \pgfpatharc command. |
| 37 |
% |
| 38 |
% |
| 39 |
% Example: One rounded corner. |
| 40 |
% |
| 41 |
% \pgfpathmoveto{\pgfpointxy{0}{0}} |
| 42 |
% \pgfsetcornersarced{4pt}{4pt} |
| 43 |
% \pgfpathlineto{\pgfpointxy{0}{1}} |
| 44 |
% \pgfpathlineto{\pgfpointxy{1}{1}} |
| 45 |
% \pgfstroke |
| 46 |
% |
| 47 |
% Example: A rounded rectangle |
| 48 |
% |
| 49 |
% \pgfsetcornersarced{4pt}{4pt} |
| 50 |
% \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{1cm}{1cm}} |
| 51 |
% \pgfstroke |
| 52 |
% |
| 53 |
% Example: A rounded triangles |
| 54 |
% |
| 55 |
% \pgfsetcornersarced{4pt}{4pt} |
| 56 |
% \pgfpathmoveto{\pgfpointorigin} |
| 57 |
% \pgfpathlineto{\pgfpoint{1cm}{0cm}} |
| 58 |
% \pgfpathlineto{\pgfpoint{1cm}{1cm}} |
| 59 |
% \pgfpathclose |
| 60 |
% \pgfstroke |
| 61 |
|
| 62 |
\newif\ifpgf@arccorners |
| 63 |
|
| 64 |
\def\pgfsetcornersarced#1{% |
| 65 |
\pgf@process{#1}% |
| 66 |
\edef\pgf@corner@arc{{\the\pgf@x}{\the\pgf@y}}% |
| 67 |
\pgf@arccornerstrue% |
| 68 |
\ifdim\pgf@x=0pt% |
| 69 |
\ifdim\pgf@y=0pt\relax% |
| 70 |
\pgf@arccornersfalse% |
| 71 |
\fi% |
| 72 |
\fi% |
| 73 |
} |
| 74 |
|
| 75 |
\def\pgf@roundcornerifneeded{% |
| 76 |
\ifpgf@arccorners\expandafter\pgfsyssoftpath@specialround\pgf@corner@arc\fi% |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
% The following protocol the passed sizes and all the corresponding |
| 82 |
% softpath commands. The nonlinear transformation (nlt) module |
| 83 |
% overwrites these commands. |
| 84 |
|
| 85 |
\def\pgf@lt@moveto#1#2{% |
| 86 |
\pgf@protocolsizes{#1}{#2}% |
| 87 |
\pgfsyssoftpath@moveto{\the#1}{\the#2}% |
| 88 |
} |
| 89 |
\def\pgf@lt@lineto#1#2{% |
| 90 |
\pgf@protocolsizes{#1}{#2}% |
| 91 |
\pgfsyssoftpath@lineto{\the#1}{\the#2}% |
| 92 |
} |
| 93 |
\def\pgf@lt@curveto#1#2#3#4#5#6{% |
| 94 |
\pgf@protocolsizes{#1}{#2}% |
| 95 |
\pgf@protocolsizes{#3}{#4}% |
| 96 |
\pgf@protocolsizes{#5}{#6}% |
| 97 |
\pgfsyssoftpath@curveto{\the#1}{\the#2}{\the#3}{\the#4}{\the#5}{\the#6}% |
| 98 |
} |
| 99 |
|
| 100 |
\let\pgf@lt@closepath\pgfsyssoftpath@closepath |
| 101 |
|
| 102 |
\let\pgf@nlt@moveto\pgf@lt@moveto |
| 103 |
\let\pgf@nlt@lineto\pgf@lt@lineto |
| 104 |
\let\pgf@nlt@curveto\pgf@lt@curveto |
| 105 |
\let\pgf@nlt@closepath\pgf@lt@closepath |
| 106 |
|
| 107 |
\let\pgf@nlt@list\pgfutil@empty % If non-empty, the nlt module is active |
| 108 |
|
| 109 |
|
| 110 |
% Move current point to #1. |
| 111 |
% |
| 112 |
% #1 = new current point |
| 113 |
% |
| 114 |
% Example: |
| 115 |
% |
| 116 |
% \pgfpathmoveto{\pgfxy(0,0)} |
| 117 |
% \pgfpathlineto{\pgfxy(0,1)} |
| 118 |
% \pgfstroke |
| 119 |
|
| 120 |
\def\pgfpathmoveto#1{% |
| 121 |
\pgfpointtransformed{#1}% |
| 122 |
\pgf@nlt@moveto{\pgf@x}{\pgf@y}% |
| 123 |
\global\pgf@path@lastx=\pgf@x% |
| 124 |
\global\pgf@path@lasty=\pgf@y% |
| 125 |
} |
| 126 |
|
| 127 |
\def\pgf@protocolsizes#1#2{% |
| 128 |
\ifpgf@relevantforpicturesize% |
| 129 |
\ifdim#1<\pgf@picminx\global\pgf@picminx#1\fi% |
| 130 |
\ifdim#1>\pgf@picmaxx\global\pgf@picmaxx#1\fi% |
| 131 |
\ifdim#2<\pgf@picminy\global\pgf@picminy#2\fi% |
| 132 |
\ifdim#2>\pgf@picmaxy\global\pgf@picmaxy#2\fi% |
| 133 |
\ifpgf@size@hooked% |
| 134 |
\let\pgf@size@hook@x#1\let\pgf@size@hook@y#2\pgf@path@size@hook% |
| 135 |
\fi% |
| 136 |
\fi% |
| 137 |
\ifdim#1<\pgf@pathminx\global\pgf@pathminx#1\fi% |
| 138 |
\ifdim#1>\pgf@pathmaxx\global\pgf@pathmaxx#1\fi% |
| 139 |
\ifdim#2<\pgf@pathminy\global\pgf@pathminy#2\fi% |
| 140 |
\ifdim#2>\pgf@pathmaxy\global\pgf@pathmaxy#2\fi% |
| 141 |
} |
| 142 |
\newif\ifpgf@size@hooked |
| 143 |
\let\pgf@path@size@hook=\pgfutil@empty% |
| 144 |
|
| 145 |
\def\pgf@resetpathsizes{% |
| 146 |
\global\pgf@pathmaxx=-16000pt\relax% |
| 147 |
\global\pgf@pathminx=16000pt\relax% |
| 148 |
\global\pgf@pathmaxy=-16000pt\relax% |
| 149 |
\global\pgf@pathminy=16000pt\relax% |
| 150 |
} |
| 151 |
|
| 152 |
\def\pgf@getpathsizes#1{% |
| 153 |
\edef#1{{\the\pgf@pathmaxx}{\the\pgf@pathminx}{\the\pgf@pathmaxy}{\the\pgf@pathminy}}% |
| 154 |
} |
| 155 |
\def\pgf@setpathsizes#1{% |
| 156 |
\expandafter\pgf@@setpathsizes#1% |
| 157 |
} |
| 158 |
\def\pgf@@setpathsizes#1#2#3#4{% |
| 159 |
\global\pgf@pathmaxx=#1\relax% |
| 160 |
\global\pgf@pathminx=#2\relax% |
| 161 |
\global\pgf@pathmaxy=#3\relax% |
| 162 |
\global\pgf@pathminy=#4\relax% |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
% Append a line from the current point to #1 to the current path. |
| 170 |
% |
| 171 |
% #1 = end of line |
| 172 |
% |
| 173 |
% Example: |
| 174 |
% |
| 175 |
% \pgfpathmoveto{\pgfxy(0,0)} |
| 176 |
% \pgfpathlineto{\pgfxy(0,1)} |
| 177 |
% \pgfstroke |
| 178 |
|
| 179 |
\def\pgfpathlineto#1{% |
| 180 |
\pgfpointtransformed{#1}% |
| 181 |
\pgf@roundcornerifneeded% |
| 182 |
\pgf@nlt@lineto{\pgf@x}{\pgf@y}% |
| 183 |
\global\pgf@path@lastx=\pgf@x% |
| 184 |
\global\pgf@path@lasty=\pgf@y% |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
% Close the current path. |
| 190 |
% |
| 191 |
% Example: |
| 192 |
% |
| 193 |
% % Draws two triangles |
| 194 |
% \pgfpathmoveto{\pgfxy(0,0)} |
| 195 |
% \pgfpathlineto{\pgfxy(0,1)} |
| 196 |
% \pgfpathlineto{\pgfxy(1,0)} |
| 197 |
% \pgfclosepath |
| 198 |
% \pgfpathmoveto{\pgfxy(2,0)} |
| 199 |
% \pgfpathlineto{\pgfxy(2,1)} |
| 200 |
% \pgfpathlineto{\pgfxy(3,0)} |
| 201 |
% \pgfpathclose |
| 202 |
% \pgfstroke |
| 203 |
|
| 204 |
\def\pgfpathclose{% |
| 205 |
\pgf@roundcornerifneeded% |
| 206 |
\pgf@nlt@closepath% |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
% Append a cubic bezier spline from the current point to #3 with control |
| 211 |
% points #1 and #2 to the current path. |
| 212 |
% |
| 213 |
% #1 = first control point |
| 214 |
% #2 = second control point |
| 215 |
% #3 = end point |
| 216 |
% |
| 217 |
% Example: |
| 218 |
% |
| 219 |
% \pgfpathmoveto{\pgfpointxy{0}{0}} |
| 220 |
% \pgfpathcurveto{\pgfpointxy{0}{1}}{\pgfpointxy{1}{1}}{\pgfpointxy{1}{2}} |
| 221 |
% \pgfstroke |
| 222 |
|
| 223 |
\def\pgfpathcurveto#1#2#3{% |
| 224 |
\pgfpointtransformed{#3}% |
| 225 |
\pgf@xb=\pgf@x% |
| 226 |
\pgf@yb=\pgf@y% |
| 227 |
\pgfpointtransformed{#2}% |
| 228 |
\pgf@xa=\pgf@x% |
| 229 |
\pgf@ya=\pgf@y% |
| 230 |
\pgfpointtransformed{#1}% |
| 231 |
\pgf@roundcornerifneeded% |
| 232 |
\pgf@nlt@curveto{\pgf@x}{\pgf@y}{\pgf@xa}{\pgf@ya}{\pgf@xb}{\pgf@yb}% |
| 233 |
\global\pgf@path@lastx=\pgf@xb% |
| 234 |
\global\pgf@path@lasty=\pgf@yb% |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
% Append a quadratic bezier spline from the current point to #2 with |
| 240 |
% control point #1 to the current path. |
| 241 |
% |
| 242 |
% #1 = control point |
| 243 |
% #2 = end point |
| 244 |
% |
| 245 |
% Example: |
| 246 |
% |
| 247 |
% \pgfpathmoveto{\pgfpointxy{0}{0}} |
| 248 |
% \pgfpathquadraticcurveto{\pgfpointxy{1}{1}}{\pgfpointxy{2}{0}} |
| 249 |
% \pgfstroke |
| 250 |
|
| 251 |
\def\pgfpathquadraticcurveto#1#2{% |
| 252 |
\pgfpointtransformed{#2}% |
| 253 |
\pgf@xb=\pgf@x% |
| 254 |
\pgf@yb=\pgf@y% |
| 255 |
\pgfpointtransformed{#1}% |
| 256 |
\pgf@xc=.6666666\pgf@x% |
| 257 |
\pgf@yc=.6666666\pgf@y% |
| 258 |
% compute second control point: |
| 259 |
\pgf@xa=.33333333\pgf@xb% |
| 260 |
\pgf@ya=.33333333\pgf@yb% |
| 261 |
\advance\pgf@xa by\pgf@xc% |
| 262 |
\advance\pgf@ya by\pgf@yc% |
| 263 |
% compute first control point |
| 264 |
\advance\pgf@xc by.3333333\pgf@path@lastx% |
| 265 |
\advance\pgf@yc by.3333333\pgf@path@lasty% |
| 266 |
\pgf@roundcornerifneeded% |
| 267 |
\pgf@nlt@curveto{\pgf@xc}{\pgf@yc}{\pgf@xa}{\pgf@ya}{\pgf@xb}{\pgf@yb}% |
| 268 |
\global\pgf@path@lastx=\pgf@xb% |
| 269 |
\global\pgf@path@lasty=\pgf@yb% |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
% Append an arc to the current point, where the current point is at |
| 276 |
% angle #1 and the end is at angle #2. If #2 > #1, the arc is drawn |
| 277 |
% counter-clockwise, otherwise it is clockwise. |
| 278 |
% |
| 279 |
% #1 = angle of first point |
| 280 |
% #2 = angle of second point |
| 281 |
% #3 = radius or x-radius/y-radius |
| 282 |
% |
| 283 |
% Example: |
| 284 |
% |
| 285 |
% \pgfpathmoveto{\pgfxy(0,0)} |
| 286 |
% \pgfpatharc{0}{90}{2cm} |
| 287 |
% \pgfstroke |
| 288 |
|
| 289 |
\def\pgfpatharc#1#2#3{% |
| 290 |
{% |
| 291 |
\pgfmathparse{#1}\let\pgf@temp@a=\pgfmathresult% |
| 292 |
\pgfmathparse{#2}\let\pgf@temp@b=\pgfmathresult% |
| 293 |
\pgfutil@in@{and }{#3}% |
| 294 |
\ifpgfutil@in@% |
| 295 |
\pgf@arc@get@radii#3\pgf@arc@stop% |
| 296 |
\else |
| 297 |
\pgf@arc@get@radii#3and #3\pgf@arc@stop% |
| 298 |
\fi% |
| 299 |
\pgf@arc@local@angle@a=\pgf@temp@a pt% |
| 300 |
\pgf@arc@local@angle@b=\pgf@temp@b pt% |
| 301 |
\loop% |
| 302 |
\pgfutil@tempdima=\pgf@arc@local@angle@a% |
| 303 |
\advance\pgfutil@tempdima by-\pgf@arc@local@angle@b\relax% |
| 304 |
\ifdim\pgfutil@tempdima<0pt\relax% |
| 305 |
\pgfutil@tempdima=-\pgfutil@tempdima\relax% |
| 306 |
\fi% |
| 307 |
\ifdim\pgfutil@tempdima>90pt\relax% |
| 308 |
\ifdim\pgfutil@tempdima>115pt\relax% |
| 309 |
\pgf@arc@temp=90pt% big skip |
| 310 |
\else% |
| 311 |
\pgf@arc@temp=60pt% smaller skip to ensure wide segments |
| 312 |
% (important shortened end segments because |
| 313 |
% of arrow tips) |
| 314 |
\fi% |
| 315 |
\ifdim\pgf@arc@local@angle@b>\pgf@arc@local@angle@a\relax% |
| 316 |
{% |
| 317 |
\pgf@arc@local@angle@b=\pgf@arc@local@angle@a\relax% |
| 318 |
\advance\pgf@arc@local@angle@b by\pgf@arc@temp\relax% |
| 319 |
\pgf@arc% |
| 320 |
} |
| 321 |
\advance\pgf@arc@local@angle@a by\pgf@arc@temp\relax% |
| 322 |
\else |
| 323 |
{% |
| 324 |
\pgf@arc@local@angle@b=\pgf@arc@local@angle@a\relax% |
| 325 |
\advance\pgf@arc@local@angle@b by-\pgf@arc@temp\relax% |
| 326 |
\pgf@arc% |
| 327 |
}% |
| 328 |
\advance\pgf@arc@local@angle@a by-\pgf@arc@temp\relax% |
| 329 |
\fi% |
| 330 |
\repeat% |
| 331 |
\pgf@roundcornerifneeded% |
| 332 |
\pgf@arc% |
| 333 |
}% |
| 334 |
} |
| 335 |
\dimendef\pgf@arc@local@angle@a=0 |
| 336 |
\dimendef\pgf@arc@local@angle@b=1 |
| 337 |
\dimendef\pgf@arc@temp=2 |
| 338 |
|
| 339 |
\def\pgf@arc@get@radii#1and #2\pgf@arc@stop{% |
| 340 |
\pgfmathparse{#1}\let\pgf@arc@radius@a=\pgfmathresult% |
| 341 |
\pgfmathparse{#2}\let\pgf@arc@radius@b=\pgfmathresult% |
| 342 |
} |
| 343 |
|
| 344 |
|
| 345 |
\def\pgf@arc{% |
| 346 |
{% |
| 347 |
\pgfutil@tempdima=\pgf@arc@radius@a pt% |
| 348 |
\pgfutil@tempdimb=\pgf@arc@radius@b pt% |
| 349 |
% |
| 350 |
\pgf@xa=\pgf@arc@local@angle@a\relax% |
| 351 |
\pgf@xb=\pgf@arc@local@angle@b\relax% |
| 352 |
\advance\pgf@xb by-\pgf@xa\relax% |
| 353 |
\ifdim\pgf@xb<0pt\relax% |
| 354 |
\pgf@xb=-\pgf@xb\relax% |
| 355 |
\fi% |
| 356 |
\ifdim\pgf@xb=90.0pt% |
| 357 |
\def\pgfmathresult{0.55228475}% |
| 358 |
\else% |
| 359 |
\pgfmathparse{1.333333333*tan(.25*\pgf@sys@tonumber{\pgf@xb})}% many thanks to Ken Starks |
| 360 |
\fi% |
| 361 |
\pgfutil@tempdima=\pgfmathresult\pgfutil@tempdima% |
| 362 |
\pgfutil@tempdimb=\pgfmathresult\pgfutil@tempdimb% |
| 363 |
%.. controls +(\pgf@xa+90:\pgfutil@tempdima) and +(\pgf@xb-90:\pgfutil@tempdima) .. +(-(#1:#3)+(#2:#3))% |
| 364 |
% store first support vector in xa/ya: |
| 365 |
\pgf@xa=\pgf@arc@local@angle@a\relax% |
| 366 |
\ifdim\pgf@arc@local@angle@b>\pgf@arc@local@angle@a\relax% |
| 367 |
\advance\pgf@xa by 90pt\relax% |
| 368 |
\else% |
| 369 |
\advance\pgf@xa by -90pt\relax% |
| 370 |
\fi% |
| 371 |
\edef\pgf@arc@angle{\pgf@sys@tonumber{\pgf@xa}}% |
| 372 |
\pgfpointtransformed{\pgfpointpolar{\pgf@arc@angle}{\pgfutil@tempdima and \pgfutil@tempdimb}}% |
| 373 |
\advance\pgf@x by-\pgf@pt@x% |
| 374 |
\advance\pgf@y by-\pgf@pt@y% |
| 375 |
\pgf@xa=\pgf@path@lastx% |
| 376 |
\pgf@ya=\pgf@path@lasty% |
| 377 |
\advance\pgf@xa by \pgf@x% |
| 378 |
\advance\pgf@ya by \pgf@y% |
| 379 |
% store target in xb/yb: |
| 380 |
\pgfpointtransformed{\pgfpointpolar{\pgf@sys@tonumber{\pgf@arc@local@angle@a}}{\pgf@arc@radius@a pt and \pgf@arc@radius@b pt}}% |
| 381 |
\pgf@xb=\pgf@path@lastx% |
| 382 |
\pgf@yb=\pgf@path@lasty% |
| 383 |
\advance\pgf@xb by -\pgf@x% |
| 384 |
\advance\pgf@yb by -\pgf@y% |
| 385 |
\pgfpointtransformed{\pgfpointpolar{\pgf@sys@tonumber{\pgf@arc@local@angle@b}}{\pgf@arc@radius@a pt and \pgf@arc@radius@b pt}}% |
| 386 |
\advance\pgf@xb by \pgf@x% |
| 387 |
\advance\pgf@yb by \pgf@y% |
| 388 |
% store second support xc/yc: |
| 389 |
\ifdim\pgf@arc@local@angle@b>\pgf@arc@local@angle@a\relax% |
| 390 |
\advance\pgf@arc@local@angle@b by -90pt\relax% |
| 391 |
\else% |
| 392 |
\advance\pgf@arc@local@angle@b by 90pt\relax% |
| 393 |
\fi% |
| 394 |
\pgfpointtransformed{\pgfpointpolar{\pgf@sys@tonumber{\pgf@arc@local@angle@b}}{\pgfutil@tempdima and \pgfutil@tempdimb}}% |
| 395 |
\advance\pgf@x by-\pgf@pt@x% |
| 396 |
\advance\pgf@y by-\pgf@pt@y% |
| 397 |
\pgf@xc=\pgf@xb\relax% |
| 398 |
\pgf@yc=\pgf@yb\relax% |
| 399 |
\advance \pgf@xc by \pgf@x\relax% |
| 400 |
\advance \pgf@yc by \pgf@y\relax% |
| 401 |
\pgf@nlt@curveto{\pgf@xa}{\pgf@ya}{\pgf@xc}{\pgf@yc}{\pgf@xb}{\pgf@yb}% |
| 402 |
\global\pgf@path@lastx=\pgf@xb% |
| 403 |
\global\pgf@path@lasty=\pgf@yb% |
| 404 |
}% |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
% Append an arc to the current point, where the arc is on an ellipse |
| 409 |
% given by two axis vectors. |
| 410 |
% |
| 411 |
% #1 = angle of first point |
| 412 |
% #2 = angle of second point |
| 413 |
% #3 = first axis |
| 414 |
% #4 = second axis |
| 415 |
% |
| 416 |
% Example: |
| 417 |
% |
| 418 |
% \pgfpathmoveto{\pgfxy(0,0)} |
| 419 |
% \pgfpatharcaxes{0}{90}{\pgfpointxy{2}{0}}{\pgfpointxy{0}{2}} |
| 420 |
% \pgfstroke |
| 421 |
|
| 422 |
\def\pgfpatharcaxes#1#2#3#4{% |
| 423 |
{% |
| 424 |
\pgftransformtriangle{\pgfpointorigin}{#3}{#4}% |
| 425 |
\pgfpatharc{#1}{#2}{1pt}% |
| 426 |
}% |
| 427 |
} |
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
% Append an arc to the current point that ends at a given position. |
| 432 |
% |
| 433 |
% #1 = x-radius |
| 434 |
% #2 = y-radius |
| 435 |
% #3 = x-axis-rotation (in degrees) |
| 436 |
% #4 = large-arc-sweep-flag (0 or 1) |
| 437 |
% #5 = sweep-flag (0 or 1) |
| 438 |
% #6 = target point |
| 439 |
% |
| 440 |
% Description: |
| 441 |
% |
| 442 |
% This command implements an arc drawing where a given target |
| 443 |
% coordinate (#6) is given and the task is to draw an arc of an |
| 444 |
% ellipse with the given radii. The center point of the ellipse is not |
| 445 |
% give, but computed automatically. |
| 446 |
% |
| 447 |
% This kind of "endpoint parameterization" of an arc is exactly the |
| 448 |
% same as the one specified by the SVG-specification for the "A" and |
| 449 |
% "a" path commands. Please see the SVG-specification for details. |
| 450 |
% |
| 451 |
% Note that the problem is internally converted to drawing an arc |
| 452 |
% using \pgfpatharc. This means that there may be a heavy loss of |
| 453 |
% accuracy. |
| 454 |
% |
| 455 |
% Example: |
| 456 |
% |
| 457 |
% \pgfpathmoveto{\pgfpoint{1cm}{1cm}} |
| 458 |
% \pgfpatharcto{1cm}{1cm}{0}{0}{0}{\pgfpoint{0cm}{2cm}} |
| 459 |
|
| 460 |
\def\pgfpatharcto#1#2#3#4#5#6{% |
| 461 |
{% |
| 462 |
% The following code is based on the transformation described in svg |
| 463 |
% 1.1 specification Section F.6.5 |
| 464 |
% |
| 465 |
% Step 1: store the simple parameters (xa=x1 since TeX does not |
| 466 |
% allow numbers in names) |
| 467 |
% |
| 468 |
\pgfmathsetmacro\pgf@arcto@rx{abs(#1)}% |
| 469 |
\pgfmathsetmacro\pgf@arcto@ry{abs(#2)}% |
| 470 |
\ifdim\pgf@arcto@rx pt=0pt% special rule: zero radius=straight line |
| 471 |
\gdef\pgf@marshal{\pgfpathlineto{#6}}% |
| 472 |
\else |
| 473 |
\ifdim\pgf@arcto@ry pt=0pt% special rule: zero radius=straight line |
| 474 |
\gdef\pgf@marshal{\pgfpathlineto{#6}}% |
| 475 |
\else |
| 476 |
\pgfmathsetmacro\pgf@arcto@phi{#3}% |
| 477 |
\pgfmathsetmacro\pgf@arcto@fA{#4}% |
| 478 |
\ifdim\pgf@arcto@fA pt=0pt |
| 479 |
\else |
| 480 |
\pgfmathsetmacro\pgf@arcto@fA{1.0} % Special rule: every non-zero value is 1. |
| 481 |
\fi |
| 482 |
\pgfmathsetmacro\pgf@arcto@fS{#5}% |
| 483 |
\ifdim\pgf@arcto@fS pt=0pt |
| 484 |
\else |
| 485 |
\pgfmathsetmacro\pgf@arcto@fS{1.0} % Special rule: every non-zero value is 1. |
| 486 |
\fi |
| 487 |
\pgf@process{#6} |
| 488 |
\edef\pgf@arcto@xb{\the\pgf@x}% |
| 489 |
\edef\pgf@arcto@yb{\the\pgf@y}% |
| 490 |
% |
| 491 |
% Step 2: x1,y1 is more complicated to compute: It is given by lastx |
| 492 |
% and lasty, but these are transformed coordinates, we need the |
| 493 |
% untransformed ones. So, we inverse the transformation (arghh...) |
| 494 |
% |
| 495 |
\pgftransforminvert% |
| 496 |
\pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@path@lastx}{\pgf@path@lasty}}} |
| 497 |
\edef\pgf@arcto@xa{\the\pgf@x} |
| 498 |
\edef\pgf@arcto@ya{\the\pgf@y} |
| 499 |
\edef\pgf@temp@a{\pgf@arcto@xa,\pgf@arcto@ya} |
| 500 |
\edef\pgf@temp@b{\pgf@arcto@xb,\pgf@arcto@yb} |
| 501 |
\ifx\pgf@temp@a\pgf@temp@b% special rule: skip! |
| 502 |
\global\let\pgf@marshal\pgfutil@empty |
| 503 |
\else |
| 504 |
% |
| 505 |
% Ok, now we got all the parameters setup. Now comes the |
| 506 |
% computation... |
| 507 |
% |
| 508 |
% |
| 509 |
% Step 3: Start with a new coordinate system and rotate everything |
| 510 |
% by the negated phi. |
| 511 |
% |
| 512 |
\pgftransformreset |
| 513 |
\pgftransformrotate{-\pgf@arcto@phi} |
| 514 |
% Ok, using \pgfpointtransformed we now get transformed points... |
| 515 |
% |
| 516 |
% Step 4: Compute x1' and y1' (xaprime and yaprime) |
| 517 |
% |
| 518 |
\pgf@process{ |
| 519 |
\pgfpointtransformed{\pgfpointscale{.5}{\pgfpointdiff |
| 520 |
{\pgfqpoint{\pgf@arcto@xb}{\pgf@arcto@yb}} |
| 521 |
{\pgfqpoint{\pgf@arcto@xa}{\pgf@arcto@ya}} |
| 522 |
} |
| 523 |
} |
| 524 |
} |
| 525 |
\edef\pgf@arcto@xaprime{\pgf@sys@tonumber\pgf@x} |
| 526 |
\edef\pgf@arcto@yaprime{\pgf@sys@tonumber\pgf@y} |
| 527 |
% |
| 528 |
% Compute Lambda |
| 529 |
% |
| 530 |
\pgfmathsetmacro\pgf@arcto@frac@x{\pgf@arcto@xaprime/\pgf@arcto@rx} |
| 531 |
\pgfmathsetmacro\pgf@arcto@frac@y{\pgf@arcto@yaprime/\pgf@arcto@ry} |
| 532 |
\pgfmathsetmacro\pgf@arcto@lambda{ |
| 533 |
\pgf@arcto@frac@x*\pgf@arcto@frac@x+\pgf@arcto@frac@y*\pgf@arcto@frac@y |
| 534 |
} |
| 535 |
\ifdim\pgf@arcto@lambda pt>1pt% |
| 536 |
\pgfmathsetmacro\pgf@arcto@sqrt@lambda{sqrt(\pgf@arcto@lambda)} |
| 537 |
\pgfmathsetmacro\pgf@arcto@rx{\pgf@arcto@sqrt@lambda*\pgf@arcto@rx} |
| 538 |
\pgfmathsetmacro\pgf@arcto@ry{\pgf@arcto@sqrt@lambda*\pgf@arcto@ry} |
| 539 |
\fi |
| 540 |
% |
| 541 |
% Do some scaling |
| 542 |
% |
| 543 |
\pgfmathsetmacro\pgf@arcto@xaprime@abs{abs(\pgf@arcto@xaprime)} |
| 544 |
\pgfmathsetmacro\pgf@arcto@yaprime@abs{abs(\pgf@arcto@yaprime)} |
| 545 |
\pgfmathmax@{\pgf@arcto@rx,\pgf@arcto@ry,\pgf@arcto@xaprime@abs,\pgf@arcto@yaprime@abs} |
| 546 |
\pgfmathsetmacro\pgf@arcto@scaling{20/\pgfmathresult} |
| 547 |
\pgfmathsetmacro\pgf@arcto@rx@scaled{\pgf@arcto@scaling*\pgf@arcto@rx} |
| 548 |
\pgfmathsetmacro\pgf@arcto@ry@scaled{\pgf@arcto@scaling*\pgf@arcto@ry} |
| 549 |
\pgfmathsetmacro\pgf@arcto@xaprime@scaled{\pgf@arcto@scaling*\pgf@arcto@xaprime} |
| 550 |
\pgfmathsetmacro\pgf@arcto@yaprime@scaled{\pgf@arcto@scaling*\pgf@arcto@yaprime} |
| 551 |
% |
| 552 |
% Step 5: Now comes the messy computation of c1' and c2'. |
| 553 |
% |
| 554 |
\ifdim\pgf@arcto@rx pt>\pgf@arcto@ry pt% |
| 555 |
\pgfmathsetmacro\pgf@arcto@rx@over@ry{\pgf@arcto@rx/\pgf@arcto@ry} |
| 556 |
\pgfmathsetmacro\pgf@arcto@ry@over@rx{\pgf@arcto@ry/\pgf@arcto@rx} |
| 557 |
\pgfmathsetmacro\pgf@arcto@temp{\pgf@arcto@ry@over@rx*\pgf@arcto@xaprime@scaled} |
| 558 |
\pgfmathsetmacro\pgf@arcto@numerator{ |
| 559 |
\pgf@arcto@ry@scaled*\pgf@arcto@ry@scaled- |
| 560 |
\pgf@arcto@yaprime@scaled*\pgf@arcto@yaprime@scaled- |
| 561 |
\pgf@arcto@temp*\pgf@arcto@temp |
| 562 |
} |
| 563 |
\pgfmathsetmacro\pgf@arcto@denominator{ |
| 564 |
\pgf@arcto@yaprime@scaled*\pgf@arcto@yaprime@scaled+ |
| 565 |
\pgf@arcto@temp*\pgf@arcto@temp |
| 566 |
} |
| 567 |
\else |
| 568 |
\pgfmathsetmacro\pgf@arcto@rx@over@ry{\pgf@arcto@rx/\pgf@arcto@ry} |
| 569 |
\pgfmathsetmacro\pgf@arcto@ry@over@rx{\pgf@arcto@ry/\pgf@arcto@rx} |
| 570 |
\pgfmathsetmacro\pgf@arcto@temp{\pgf@arcto@rx@over@ry*\pgf@arcto@yaprime@scaled} |
| 571 |
\pgfmathsetmacro\pgf@arcto@numerator{ |
| 572 |
\pgf@arcto@rx@scaled*\pgf@arcto@rx@scaled- |
| 573 |
\pgf@arcto@xaprime@scaled*\pgf@arcto@xaprime@scaled- |
| 574 |
\pgf@arcto@temp*\pgf@arcto@temp |
| 575 |
} |
| 576 |
\pgfmathsetmacro\pgf@arcto@denominator{ |
| 577 |
\pgf@arcto@xaprime@scaled*\pgf@arcto@xaprime@scaled+ |
| 578 |
\pgf@arcto@temp*\pgf@arcto@temp |
| 579 |
} |
| 580 |
\fi |
| 581 |
\pgfmathsetmacro\pgf@arcto@frac{ |
| 582 |
\pgf@arcto@numerator/\pgf@arcto@denominator |
| 583 |
} |
| 584 |
\ifdim\pgf@arcto@frac pt<0pt |
| 585 |
\pgfmathsetmacro\pgf@arcto@factor{0} |
| 586 |
\else |
| 587 |
\pgfmathsetmacro\pgf@arcto@factor{sqrt(\pgf@arcto@frac)} |
| 588 |
\fi |
| 589 |
\ifx\pgf@arcto@fA\pgf@arcto@fS |
| 590 |
\pgfmathsetmacro\pgf@arcto@factor{-\pgf@arcto@factor} |
| 591 |
\fi |
| 592 |
\pgfmathsetmacro\pgf@arcto@cxprime{ |
| 593 |
\pgf@arcto@factor*\pgf@arcto@rx@over@ry*\pgf@arcto@yaprime |
| 594 |
} |
| 595 |
\pgfmathsetmacro\pgf@arcto@cyprime{ |
| 596 |
-\pgf@arcto@factor*\pgf@arcto@ry@over@rx*\pgf@arcto@xaprime |
| 597 |
} |
| 598 |
% |
| 599 |
% Step 6: Ok, now compute cx,cy |
| 600 |
% |
| 601 |
\pgftransformreset |
| 602 |
\pgftransformrotate{\pgf@arcto@phi} |
| 603 |
\pgf@process{ |
| 604 |
\pgfpointtransformed{\pgfqpoint{\pgf@arcto@cxprime pt}{\pgf@arcto@cyprime pt}} |
| 605 |
} |
| 606 |
\edef\pgf@arcto@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}} |
| 607 |
\pgf@process{\pgfpointadd{\pgf@arcto@temp}{ |
| 608 |
\pgfpointscale{.5}{ |
| 609 |
\pgfpointadd |
| 610 |
{\pgfqpoint{\pgf@arcto@xa}{\pgf@arcto@ya}} |
| 611 |
{\pgfqpoint{\pgf@arcto@xb}{\pgf@arcto@yb}} } |
| 612 |
} |
| 613 |
} |
| 614 |
\edef\pgf@arcto@cx{\the\pgf@x} |
| 615 |
\edef\pgf@arcto@cy{\the\pgf@y} |
| 616 |
% |
| 617 |
% Step 7: Compute start angle: |
| 618 |
% |
| 619 |
\pgfmathsetmacro\pgf@arcto@vec@x{(\pgf@arcto@xaprime-\pgf@arcto@cxprime)/\pgf@arcto@rx} |
| 620 |
\pgfmathsetmacro\pgf@arcto@vec@y{(\pgf@arcto@yaprime-\pgf@arcto@cyprime)/\pgf@arcto@ry} |
| 621 |
\pgfmathsetmacro\pgf@arcto@denominator{veclen(\pgf@arcto@vec@x,\pgf@arcto@vec@y)} |
| 622 |
\pgfmathsetmacro\pgf@arcto@frac{\pgf@arcto@vec@x/\pgf@arcto@denominator} |
| 623 |
\pgfmathsetmacro\pgf@arcto@theta@start{acos(\pgf@arcto@frac)} |
| 624 |
\ifdim\pgf@arcto@vec@y pt<0pt |
| 625 |
\pgfmathsetmacro\pgf@arcto@theta@start{-\pgf@arcto@theta@start} |
| 626 |
\fi |
| 627 |
% |
| 628 |
% Step 8: Compute end angle: |
| 629 |
% |
| 630 |
\pgfmathsetmacro\pgf@arcto@vec@x{(-\pgf@arcto@xaprime-\pgf@arcto@cxprime)/\pgf@arcto@rx} |
| 631 |
\pgfmathsetmacro\pgf@arcto@vec@y{(-\pgf@arcto@yaprime-\pgf@arcto@cyprime)/\pgf@arcto@ry} |
| 632 |
\pgfmathsetmacro\pgf@arcto@denominator{veclen(\pgf@arcto@vec@x,\pgf@arcto@vec@y)} |
| 633 |
\pgfmathsetmacro\pgf@arcto@frac{\pgf@arcto@vec@x/\pgf@arcto@denominator} |
| 634 |
\pgfmathsetmacro\pgf@arcto@theta@end{acos(\pgf@arcto@frac)} |
| 635 |
\ifdim\pgf@arcto@vec@y pt<0pt |
| 636 |
\pgfmathsetmacro\pgf@arcto@theta@end{-\pgf@arcto@theta@end} |
| 637 |
\fi |
| 638 |
\pgfmathsetmacro\pgf@arcto@delta@theta{abs(\pgf@arcto@theta@start-\pgf@arcto@theta@end)} |
| 639 |
\ifdim\pgf@arcto@fA pt=0pt% |
| 640 |
\ifdim\pgf@arcto@delta@theta pt>180pt% |
| 641 |
% Ok, we need to adjust the angle! |
| 642 |
\ifdim\pgf@arcto@theta@end pt>\pgf@arcto@theta@start pt |
| 643 |
\pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end-360} |
| 644 |
\else |
| 645 |
\pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end+360} |
| 646 |
\fi |
| 647 |
\fi |
| 648 |
\else |
| 649 |
\ifdim\pgf@arcto@delta@theta pt<180pt% |
| 650 |
% Ok, we need to adjust the angle! |
| 651 |
\ifdim\pgf@arcto@theta@end pt>\pgf@arcto@theta@start pt |
| 652 |
\pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end-360} |
| 653 |
\else |
| 654 |
\pgfmathsetmacro\pgf@arcto@theta@end{\pgf@arcto@theta@end+360} |
| 655 |
\fi |
| 656 |
\fi |
| 657 |
\fi |
| 658 |
\xdef\pgf@marshal{\noexpand |
| 659 |
\pgfpatharcaxes{\pgf@arcto@theta@start}{\pgf@arcto@theta@end} |
| 660 |
{\noexpand\pgfpointpolar{\pgf@arcto@phi}{\pgf@arcto@rx}} |
| 661 |
{\noexpand\pgfpointpolar{\pgf@arcto@phi+90}{\pgf@arcto@ry}} |
| 662 |
} |
| 663 |
\fi\fi\fi |
| 664 |
} |
| 665 |
\pgf@marshal |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
% the quality of arc approximation by means of Bezier splines is |
| 671 |
% controlled by a mesh width. |
| 672 |
% |
| 673 |
% The mesh width is provided in (full!) degrees. The smaller the mesh |
| 674 |
% width, the more precise the arc approximation. |
| 675 |
% |
| 676 |
% Use an empty value to disable spline approximation (uses a single |
| 677 |
% cubic polynomial for the complete arc). |
| 678 |
% |
| 679 |
% The value must be an integer! |
| 680 |
\def\pgfpatharctomaxstepsize{45} |
| 681 |
|
| 682 |
% A specialized arc operation for an arc on an (axis--parallel) ellipse. |
| 683 |
% |
| 684 |
% In contrast to \pgfpatharc, it explicitly interpolates start- and end points. |
| 685 |
% |
| 686 |
% In contrast to \pgfpatharcto, this routine is numerically stable and |
| 687 |
% quite fast since it relies on a lot of precomputed information. |
| 688 |
% |
| 689 |
% #1 center of ellipse |
| 690 |
% #2 angle of last path position inside of the ellipse |
| 691 |
% #3 end angle |
| 692 |
% #4 end point (a \pgfpoint) |
| 693 |
% #5 xradius |
| 694 |
% #6 yradius |
| 695 |
% #7 the ratio xradius/yradius of the ellipse |
| 696 |
% #8 the ratio yradius/xradius of the ellipse |
| 697 |
% Example: |
| 698 |
% \def\cx{1cm}% center x |
| 699 |
% \def\cy{1cm}% center y |
| 700 |
% \def\startangle{0}% |
| 701 |
% \def\endangle{45}% |
| 702 |
% \def\a{5cm}% xradius |
| 703 |
% \def\b{10cm}% yradius |
| 704 |
% \pgfmathparse{\a/\b}\let\abratio=\pgfmathresult |
| 705 |
% \pgfmathparse{\b/\a}\let\baratio=\pgfmathresult |
| 706 |
% |
| 707 |
% \pgfpathmoveto{\pgfpoint{\cx+\a*cos(\startangle)}{\cy+\b*sin(\startangle)}}% |
| 708 |
% \pgfpatharctoprecomputed |
| 709 |
% {\pgfpoint{\cx}{\cy}} |
| 710 |
% {\startangle} |
| 711 |
% {\endangle} |
| 712 |
% {\pgfpoint{\cx+\a*cos(\endangle)}{\cy+\b*sin(\endangle)}}% |
| 713 |
% {\a} |
| 714 |
% {\b} |
| 715 |
% {\abratio} |
| 716 |
% {\baratio} |
| 717 |
% |
| 718 |
\def\pgfpatharctoprecomputed#1#2#3#4#5#6#7#8{% |
| 719 |
\begingroup |
| 720 |
% Implementation idea: |
| 721 |
% |
| 722 |
% let |
| 723 |
% m = center (#1) |
| 724 |
% \gamma_0 = start angle |
| 725 |
% \gamma_1 = end angle |
| 726 |
% a = x radius |
| 727 |
% b = y radius |
| 728 |
% |
| 729 |
% an axis parallel ellipse is parameterized by |
| 730 |
% C(\gamma) = m + ( a cos(\gamma), b sin(\gamma) ), \gamma in [0,360]. |
| 731 |
% |
| 732 |
% Now, consider the segment \gamma(t), |
| 733 |
% \gamma:[0,1] -> [\gamma_0,\gamma_1], |
| 734 |
% t -> \gamma_0 + t(\gamma_1 - \gamma_0) |
| 735 |
% and |
| 736 |
% C(\gamma(t)) which is defined on [0,1]. |
| 737 |
% |
| 738 |
% I'd like to approximate the arc by one or more cubic bezier |
| 739 |
% splines which interpolate through the last and first provided |
| 740 |
% points. |
| 741 |
% |
| 742 |
% In general, a Bezier spline C:[0,1] -> \R of order n fulfills |
| 743 |
% C'(0) = n ( P_1 - P_0 ), |
| 744 |
% C'(1) = n ( P_n - P_{n-1} ). |
| 745 |
% For n=3 and given P_0 and P_3, I can directly compute P_1 and P_2 once I know |
| 746 |
% the derivatives at t=0 and t=1. |
| 747 |
% |
| 748 |
% The derivatives in our case are |
| 749 |
% ( C \circ \gamma )'(t) = C'[\gamma(t)] * \gamma'(t) |
| 750 |
% = ( -a pi/180 sin(\gamma(t)), b pi/180 cos(\gamma(t)) ) * (\gamma_1 - \gamma_0). |
| 751 |
% The pi/180 comes into play since we are working with degrees. |
| 752 |
% |
| 753 |
% Expression (C\circ\gamma)'(0) using P_0 and (C \circ \gamma)'(1) |
| 754 |
% using P_3 yields the expressions |
| 755 |
% (C \circ \gamma)'(0) = |
| 756 |
% pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_0^y - my), b/a (P_0^x - mx) ] |
| 757 |
% (C \circ \gamma)'(1) = |
| 758 |
% pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_3^y - my), b/a (P_3^x - mx) ] |
| 759 |
% |
| 760 |
% defining |
| 761 |
% scaleA = a/b * pi / (3*180) * (\gamma_1 - \gamma_0) |
| 762 |
% and |
| 763 |
% scaleB = b/a * pi / (3*180) * (\gamma_1 - \gamma_0) |
| 764 |
% yields the direct expressions for the intermediate bezier |
| 765 |
% control points |
| 766 |
% |
| 767 |
% P_1 = [ |
| 768 |
% P_0^x - scaleA* ( P_0^y -my), |
| 769 |
% P_0^y + scaleB* ( P_0^x -mx) ] |
| 770 |
% and |
| 771 |
% P_2 = [ |
| 772 |
% P_3^x + scaleA* ( P_3^y -my), |
| 773 |
% P_3^y - scaleB* ( P_3^x -mx) ]. |
| 774 |
% |
| 775 |
% This works fast, with few operations, if |
| 776 |
% - a/b and b/a are known in advance |
| 777 |
% - P_0 and P_3 are known in advance |
| 778 |
% - \gamma_0 and \gamma_1 are known. |
| 779 |
% |
| 780 |
% It is also reliable if (\gamma_1 - \gamma_0) is small |
| 781 |
% |
| 782 |
\pgf@process{#1}% |
| 783 |
\edef\pgfpath@center@x{\the\pgf@x}% |
| 784 |
\edef\pgfpath@center@y{\the\pgf@y}% |
| 785 |
\def\pgfpath@completearcend{#4}% |
| 786 |
% compute scale (#3-#2) * pi/(3*180) = (#3 - #2) * pi/27 * 1/20 |
| 787 |
% splitting pi/(3*180) into two scales has higher TeX accuracy |
| 788 |
\pgf@xa=#2pt |
| 789 |
\pgf@xb=#3pt |
| 790 |
\edef\pgfpath@startangle{#2pt}% |
| 791 |
\edef\pgfpath@endangle{\pgf@sys@tonumber\pgf@xb}% |
| 792 |
% |
| 793 |
\pgf@ya=\pgf@xb |
| 794 |
\advance\pgf@ya by-\pgf@xa |
| 795 |
% |
| 796 |
\ifx\pgfpatharctomaxstepsize\pgfutil@empty |
| 797 |
\def\pgfpath@N{1}% |
| 798 |
\pgf@xc=\pgf@ya |
| 799 |
\else |
| 800 |
\pgf@xc=\pgf@ya% compute N = floor((gamma_1 - gamma_0) / max) +1 |
| 801 |
\ifdim\pgf@xc<0pt |
| 802 |
\multiply\pgf@xc by-1 |
| 803 |
\fi |
| 804 |
\divide\pgf@xc by\pgfpatharctomaxstepsize\relax |
| 805 |
\afterassignment\pgfutil@gobble@until@relax |
| 806 |
\c@pgf@counta=\the\pgf@xc\relax |
| 807 |
\advance\c@pgf@counta by1 |
| 808 |
\edef\pgfpath@N{\the\c@pgf@counta}% |
| 809 |
% |
| 810 |
\pgf@xc=\pgf@ya |
| 811 |
\divide\pgf@xc by\c@pgf@counta |
| 812 |
\fi |
| 813 |
% |
| 814 |
\edef\pgfpath@h{\pgf@sys@tonumber\pgf@xc}% |
| 815 |
% |
| 816 |
%\message{pgfpathellipse: using N =\pgfpath@N\space spline points y0 = \pgfpath@startangle, y0+i*h, yN=\pgfpath@endangle, i=1,...,(\pgfpath@N-1), with h=\pgfpath@h\space mesh width (total arc angle \pgf@sys@tonumber\pgf@ya).}% |
| 817 |
% |
| 818 |
% |
| 819 |
\pgf@xc=0.116355283466289\pgf@xc % pi/27 |
| 820 |
\divide\pgf@xc by20 |
| 821 |
\pgf@xa=#7\pgf@xc |
| 822 |
\edef\pgfpath@scale@A{\pgf@sys@tonumber\pgf@xa}% |
| 823 |
\pgf@xa=#8\pgf@xc |
| 824 |
\edef\pgfpath@scale@B{\pgf@sys@tonumber\pgf@xa}% |
| 825 |
% |
| 826 |
% compute intermediate spline segments for |
| 827 |
% i = 1,...,N-1 |
| 828 |
% this is a no-op for N=1. |
| 829 |
\c@pgf@countd=1 |
| 830 |
\pgfutil@loop |
| 831 |
\ifnum\c@pgf@countd<\pgfpath@N\relax |
| 832 |
% |
| 833 |
\pgf@xa=\pgfpath@startangle % compute \pgf@xa = y_0 + i*h |
| 834 |
\pgf@xb=\pgfpath@h pt |
| 835 |
\multiply\pgf@xb by\c@pgf@countd |
| 836 |
\advance\pgf@xa by\pgf@xb |
| 837 |
\edef\pgfpath@angle@i{\pgf@sys@tonumber\pgf@xa}% |
| 838 |
%\message{angle \the\c@pgf@countd: \pgfpath@angle@i...}% |
| 839 |
% |
| 840 |
\pgfpatharcofellipse@{% |
| 841 |
\pgfpoint |
| 842 |
{\pgfpath@center@x + #5*cos(\pgfpath@angle@i)} |
| 843 |
{\pgfpath@center@y + #6*sin(\pgfpath@angle@i)}% |
| 844 |
}% |
| 845 |
% |
| 846 |
\advance\c@pgf@countd by1 |
| 847 |
\pgfutil@repeat |
| 848 |
% |
| 849 |
% compute final spline segment. It only differs insofar as the |
| 850 |
% final point is already known explicitly and should be |
| 851 |
% interpolated without additional math error. |
| 852 |
%\message{angle \pgfpath@N: \pgfpath@endangle...}% |
| 853 |
\pgfpatharcofellipse@{\pgfpath@completearcend}% |
| 854 |
\endgroup |
| 855 |
}% |
| 856 |
\def\pgfpatharcofellipse@#1{% |
| 857 |
\begingroup |
| 858 |
\pgf@process{#1}% |
| 859 |
\edef\pgfpath@endpt{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% |
| 860 |
% |
| 861 |
\pgfpathcurveto{ |
| 862 |
\begingroup |
| 863 |
\global\pgf@x=\pgf@path@lastx |
| 864 |
\global\pgf@y=\pgf@path@lasty |
| 865 |
\pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x |
| 866 |
\pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y |
| 867 |
\global\advance\pgf@x by-\pgfpath@scale@A\pgf@ya |
| 868 |
\global\advance\pgf@y by \pgfpath@scale@B\pgf@xa |
| 869 |
\endgroup |
| 870 |
}{% |
| 871 |
\begingroup |
| 872 |
\pgfpath@endpt |
| 873 |
\pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x |
| 874 |
\pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y |
| 875 |
\global\advance\pgf@x by \pgfpath@scale@A\pgf@ya |
| 876 |
\global\advance\pgf@y by-\pgfpath@scale@B\pgf@xa |
| 877 |
\endgroup |
| 878 |
}{% |
| 879 |
\pgfpath@endpt |
| 880 |
}% |
| 881 |
\endgroup |
| 882 |
} |
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
% Append an ellipse to the current path. |
| 893 |
% |
| 894 |
% #1 = center |
| 895 |
% #2 = first axis |
| 896 |
% #3 = second axis |
| 897 |
% |
| 898 |
% Example: |
| 899 |
% |
| 900 |
% % Add a circle of radius 3cm around the origin |
| 901 |
% \pgfpathellipse{\pgforigin}{\pgfxy(2,0)}{\pgfxy(0,1)} |
| 902 |
% |
| 903 |
% % Draw a non-filled circle of radius 1cm around the point (1,1) |
| 904 |
% \pgfpathellipse{\pgfxy(1,1)}{\pgfxy(1,1)}{\pgfxy(-2,2)} |
| 905 |
% \pgfstroke |
| 906 |
|
| 907 |
\def\pgfpathellipse#1#2#3{% |
| 908 |
\pgfpointtransformed{#1}% store center in xc/yc |
| 909 |
\pgf@xc=\pgf@x% |
| 910 |
\pgf@yc=\pgf@y% |
| 911 |
\pgfpointtransformed{#2}% |
| 912 |
\pgf@xa=\pgf@x% store first axis in xa/ya |
| 913 |
\pgf@ya=\pgf@y% |
| 914 |
\advance\pgf@xa by-\pgf@pt@x% |
| 915 |
\advance\pgf@ya by-\pgf@pt@y% |
| 916 |
\pgfpointtransformed{#3}% |
| 917 |
\pgf@xb=\pgf@x% store second axis in xb/yb |
| 918 |
\pgf@yb=\pgf@y% |
| 919 |
\advance\pgf@xb by-\pgf@pt@x% |
| 920 |
\advance\pgf@yb by-\pgf@pt@y% |
| 921 |
{% |
| 922 |
\advance\pgf@xa by\pgf@xc% |
| 923 |
\advance\pgf@ya by\pgf@yc% |
| 924 |
\pgf@nlt@moveto{\pgf@xa}{\pgf@ya}% |
| 925 |
}% |
| 926 |
\pgf@x=0.55228475\pgf@xb% first arc |
| 927 |
\pgf@y=0.55228475\pgf@yb% |
| 928 |
\advance\pgf@x by\pgf@xa% |
| 929 |
\advance\pgf@y by\pgf@ya% |
| 930 |
\advance\pgf@x by\pgf@xc% |
| 931 |
\advance\pgf@y by\pgf@yc% |
| 932 |
\edef\pgf@temp{\pgf@xc\the\pgf@x\pgf@yc\the\pgf@y}% |
| 933 |
\pgf@x=0.55228475\pgf@xa% |
| 934 |
\pgf@y=0.55228475\pgf@ya% |
| 935 |
\advance\pgf@x by\pgf@xb% |
| 936 |
\advance\pgf@y by\pgf@yb% |
| 937 |
{% |
| 938 |
\advance\pgf@x by\pgf@xc% |
| 939 |
\advance\pgf@y by\pgf@yc% |
| 940 |
\advance\pgf@xb by\pgf@xc% |
| 941 |
\advance\pgf@yb by\pgf@yc% |
| 942 |
\pgf@temp% |
| 943 |
\pgf@nlt@curveto{\pgf@xc}{\pgf@yc}{\pgf@x}{\pgf@y}{\pgf@xb}{\pgf@yb}% |
| 944 |
}% |
| 945 |
\pgf@xa=-\pgf@xa% flip first axis |
| 946 |
\pgf@ya=-\pgf@ya% |
| 947 |
\pgf@x=0.55228475\pgf@xa% second arc |
| 948 |
\pgf@y=0.55228475\pgf@ya% |
| 949 |
\advance\pgf@x by\pgf@xb% |
| 950 |
\advance\pgf@y by\pgf@yb% |
| 951 |
\advance\pgf@x by\pgf@xc% |
| 952 |
\advance\pgf@y by\pgf@yc% |
| 953 |
\edef\pgf@temp{\pgf@xc\the\pgf@x\pgf@yc\the\pgf@y}% |
| 954 |
\pgf@x=0.55228475\pgf@xb% |
| 955 |
\pgf@y=0.55228475\pgf@yb% |
| 956 |
\advance\pgf@x by\pgf@xa% |
| 957 |
\advance\pgf@y by\pgf@ya% |
| 958 |
{% |
| 959 |
\advance\pgf@x by\pgf@xc% |
| 960 |
\advance\pgf@y by\pgf@yc% |
| 961 |
\advance\pgf@xa by\pgf@xc% |
| 962 |
\advance\pgf@ya by\pgf@yc% |
| 963 |
\pgf@temp% |
| 964 |
\pgf@nlt@curveto{\pgf@xc}{\pgf@yc}{\pgf@x}{\pgf@y}{\pgf@xa}{\pgf@ya}% |
| 965 |
}% |
| 966 |
\pgf@xb=-\pgf@xb% flip second axis |
| 967 |
\pgf@yb=-\pgf@yb% |
| 968 |
\pgf@x=0.55228475\pgf@xb% third arc |
| 969 |
\pgf@y=0.55228475\pgf@yb% |
| 970 |
\advance\pgf@x by\pgf@xa% |
| 971 |
\advance\pgf@y by\pgf@ya% |
| 972 |
\advance\pgf@x by\pgf@xc% |
| 973 |
\advance\pgf@y by\pgf@yc% |
| 974 |
\edef\pgf@temp{\pgf@xc\the\pgf@x\pgf@yc\the\pgf@y}% |
| 975 |
\pgf@x=0.55228475\pgf@xa% |
| 976 |
\pgf@y=0.55228475\pgf@ya% |
| 977 |
\advance\pgf@x by\pgf@xb% |
| 978 |
\advance\pgf@y by\pgf@yb% |
| 979 |
{% |
| 980 |
\advance\pgf@x by\pgf@xc% |
| 981 |
\advance\pgf@y by\pgf@yc% |
| 982 |
\advance\pgf@xb by\pgf@xc% |
| 983 |
\advance\pgf@yb by\pgf@yc% |
| 984 |
\pgf@temp% |
| 985 |
\pgf@nlt@curveto{\pgf@xc}{\pgf@yc}{\pgf@x}{\pgf@y}{\pgf@xb}{\pgf@yb}% |
| 986 |
}% |
| 987 |
\pgf@xa=-\pgf@xa% flip first axis once more |
| 988 |
\pgf@ya=-\pgf@ya% |
| 989 |
\pgf@x=0.55228475\pgf@xa% fourth arc |
| 990 |
\pgf@y=0.55228475\pgf@ya% |
| 991 |
\advance\pgf@x by\pgf@xb% |
| 992 |
\advance\pgf@y by\pgf@yb% |
| 993 |
\advance\pgf@x by\pgf@xc% |
| 994 |
\advance\pgf@y by\pgf@yc% |
| 995 |
\edef\pgf@temp{\pgf@xc\the\pgf@x\pgf@yc\the\pgf@y}% |
| 996 |
\pgf@x=0.55228475\pgf@xb% |
| 997 |
\pgf@y=0.55228475\pgf@yb% |
| 998 |
\advance\pgf@x by\pgf@xa% |
| 999 |
\advance\pgf@y by\pgf@ya% |
| 1000 |
{% |
| 1001 |
\advance\pgf@x by\pgf@xc% |
| 1002 |
\advance\pgf@y by\pgf@yc% |
| 1003 |
\advance\pgf@xa by\pgf@xc% |
| 1004 |
\advance\pgf@ya by\pgf@yc% |
| 1005 |
\pgf@temp% |
| 1006 |
\pgf@nlt@curveto{\pgf@xc}{\pgf@yc}{\pgf@x}{\pgf@y}{\pgf@xa}{\pgf@ya}% |
| 1007 |
}% |
| 1008 |
\pgf@nlt@closepath% |
| 1009 |
\pgf@nlt@moveto{\pgf@xc}{\pgf@yc}% |
| 1010 |
} |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
% Append a circle to the current path |
| 1015 |
% |
| 1016 |
% #1 = center |
| 1017 |
% #2 = radius |
| 1018 |
% |
| 1019 |
% Example: |
| 1020 |
% |
| 1021 |
% % Append a circle of radius 3cm around the point (1,1) |
| 1022 |
% \pgfpathcircle{\pgxy(1,1)}{3cm} |
| 1023 |
|
| 1024 |
\def\pgfpathcircle#1#2{\pgfpathellipse{#1}{\pgfpoint{#2}{0pt}}{\pgfpoint{0pt}{#2}}} |
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
% Append a rectangle to the current path |
| 1030 |
% |
| 1031 |
% #1 = lower left corner point of rectangle |
| 1032 |
% #2 = width and height vector |
| 1033 |
% |
| 1034 |
% Example: |
| 1035 |
% |
| 1036 |
% % A rectangle with corners (2,2) and (3,3) |
| 1037 |
% \pgfpathrectangle{\pgfpointxy{2}{2}}{\pgfpointxy{1}{1}} |
| 1038 |
|
| 1039 |
\def\pgfpathrectangle{% |
| 1040 |
\let\pgfrect@next=\pgf@specialrect% |
| 1041 |
\ifpgf@pt@identity% |
| 1042 |
\ifpgf@arccorners% |
| 1043 |
\else% |
| 1044 |
\ifx\pgf@nlt@list\pgfutil@empty% |
| 1045 |
\let\pgfrect@next=\pgf@normalrect% |
| 1046 |
\fi% |
| 1047 |
\fi% |
| 1048 |
\fi% |
| 1049 |
\pgfrect@next% |
| 1050 |
} |
| 1051 |
|
| 1052 |
\def\pgf@normalrect#1#2{% |
| 1053 |
\pgf@process{#2}% |
| 1054 |
\pgf@xa=\pgf@x% |
| 1055 |
\pgf@ya=\pgf@y% |
| 1056 |
\pgfpointtransformed{#1}% |
| 1057 |
\pgfsyssoftpath@rect{\the\pgf@x}{\the\pgf@y}{\the\pgf@xa}{\the\pgf@ya}% |
| 1058 |
\pgf@protocolsizes{\pgf@x}{\pgf@y}% |
| 1059 |
\advance\pgf@x by\pgf@xa\relax% |
| 1060 |
\advance\pgf@y by\pgf@ya\relax% |
| 1061 |
\pgf@protocolsizes{\pgf@x}{\pgf@y}% |
| 1062 |
} |
| 1063 |
|
| 1064 |
\def\pgf@specialrect#1#2{% |
| 1065 |
\pgf@process{#2}% |
| 1066 |
\pgf@xa=\pgf@x% |
| 1067 |
\pgf@ya=\pgf@y% |
| 1068 |
\pgf@process{#1}% |
| 1069 |
\pgf@xb=\pgf@x% |
| 1070 |
\pgf@yb=\pgf@y% |
| 1071 |
\advance\pgf@xa by\pgf@xb% |
| 1072 |
\advance\pgf@ya by\pgf@yb% |
| 1073 |
\pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% |
| 1074 |
\pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}}% |
| 1075 |
\pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}}% |
| 1076 |
\pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% |
| 1077 |
\pgfpathclose% |
| 1078 |
\pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@yb}}% |
| 1079 |
} |
| 1080 |
|
| 1081 |
% Append a rectangle to the current path |
| 1082 |
% |
| 1083 |
% #1 = one corner of the rectangle |
| 1084 |
% #2 = opposite corner of the rectangle |
| 1085 |
% |
| 1086 |
% Example: |
| 1087 |
% |
| 1088 |
% % A rectangle with corners (2,2) and (3,3) |
| 1089 |
% \pgfpathrectanglecorners{\pgfpointxy{2}{2}}{\pgfpointxy{3}{3}} |
| 1090 |
|
| 1091 |
\def\pgfpathrectanglecorners#1#2{% |
| 1092 |
\pgf@process{#2}% |
| 1093 |
\pgf@xc=\pgf@x% |
| 1094 |
\pgf@yc=\pgf@y% |
| 1095 |
\pgf@process{#1}% |
| 1096 |
\advance\pgf@xc by-\pgf@x% |
| 1097 |
\advance\pgf@yc by-\pgf@y% |
| 1098 |
\pgfpathrectangle{#1}{\pgfqpoint{\pgf@xc}{\pgf@yc}}% |
| 1099 |
} |
| 1100 |
|
| 1101 |
|
| 1102 |
% Append a grid to the current path. |
| 1103 |
% |
| 1104 |
% #1 = first corner point of grid |
| 1105 |
% #2 = second corner point of grid |
| 1106 |
% |
| 1107 |
% Options: |
| 1108 |
% |
| 1109 |
% stepx = x-step dimension (default 1cm) |
| 1110 |
% stepy = y-step dimension (default 1cm) |
| 1111 |
% step = dimension vector |
| 1112 |
% |
| 1113 |
% Example: |
| 1114 |
% |
| 1115 |
% \pgfsetlinewidth{0.8pt} |
| 1116 |
% \pgfgrid{\pgfxy(0,0)}{\pgfxy(3,2)} |
| 1117 |
% \pgfsetlinewidth{0.4pt} |
| 1118 |
% \pgfgrid[stepx=1cm,stepy=1cm]{\pgfxy(0,0)}{\pgfxy(3,2)} |
| 1119 |
|
| 1120 |
\pgfkeys{ |
| 1121 |
/pgf/stepx/.initial=1cm, |
| 1122 |
/pgf/stepy/.initial=1cm, |
| 1123 |
/pgf/step/.code={\pgf@process{#1}\pgfkeysalso{/pgf/stepx/.expanded=\the\pgf@x,/pgf/stepy/.expanded=\the\pgf@y}}, |
| 1124 |
/pgf/step/.value required |
| 1125 |
} |
| 1126 |
|
| 1127 |
\def\pgfpathgrid{\pgfutil@ifnextchar[{\pgf@pathgrid}{\pgf@pathgrid[]}} |
| 1128 |
\def\pgf@pathgrid[#1]#2#3{% |
| 1129 |
\pgfset{#1}% |
| 1130 |
\pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/stepx}}% |
| 1131 |
\pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/stepy}}% |
| 1132 |
\pgf@process{#3}% |
| 1133 |
\pgf@xb=\pgf@x% |
| 1134 |
\pgf@yb=\pgf@y% |
| 1135 |
\pgf@process{#2}% |
| 1136 |
\pgf@xa=\pgf@x% |
| 1137 |
\pgf@ya=\pgf@y% |
| 1138 |
% Swap coordinates if one of them is smaller than the other: |
| 1139 |
\ifdim\pgf@xa>\pgf@xb% |
| 1140 |
\pgf@x=\pgf@xb% |
| 1141 |
\pgf@xb=\pgf@xa% |
| 1142 |
\pgf@xa=\pgf@x% |
| 1143 |
\fi% |
| 1144 |
\ifdim\pgf@ya>\pgf@yb% |
| 1145 |
\pgf@y=\pgf@yb% |
| 1146 |
\pgf@yb=\pgf@ya% |
| 1147 |
\pgf@ya=\pgf@y% |
| 1148 |
\fi% |
| 1149 |
\ifdim \pgf@yc > .01pt\relax% if to draw horizontal lines |
| 1150 |
\c@pgf@counta=\pgf@ya\relax% |
| 1151 |
\c@pgf@countb=\pgf@yc\relax% |
| 1152 |
\divide\c@pgf@counta by\c@pgf@countb\relax% |
| 1153 |
\pgfutil@tempdima=\c@pgf@counta\pgf@yc\relax% |
| 1154 |
\ifdim\pgfutil@tempdima<\pgf@ya% |
| 1155 |
\advance\pgfutil@tempdima by\pgf@yc% |
| 1156 |
\fi% |
| 1157 |
\pgfutil@tempdimb\pgf@x |
| 1158 |
\pgfutil@loop% horizontal lines |
| 1159 |
{% |
| 1160 |
\pgf@xa=\pgfutil@tempdimb% |
| 1161 |
\pgf@ya=\pgfutil@tempdima% |
| 1162 |
\pgf@pos@transform{\pgf@xa}{\pgf@ya} |
| 1163 |
\pgf@nlt@moveto{\pgf@xa}{\pgf@ya}% |
| 1164 |
\pgf@xa=\pgf@xb% |
| 1165 |
\pgf@ya=\pgfutil@tempdima% |
| 1166 |
\pgf@pos@transform{\pgf@xa}{\pgf@ya} |
| 1167 |
\pgf@nlt@lineto{\pgf@xa}{\pgf@ya}% |
| 1168 |
}% |
| 1169 |
\advance\pgfutil@tempdima by\pgf@yc% |
| 1170 |
\ifdim\pgfutil@tempdima<\pgf@yb% |
| 1171 |
\pgfutil@repeat% |
| 1172 |
\advance\pgfutil@tempdima by-0.01pt\relax% |
| 1173 |
\ifdim\pgfutil@tempdima<\pgf@yb% |
| 1174 |
{% |
| 1175 |
\pgf@xa=\pgfutil@tempdimb% |
| 1176 |
\pgf@ya=\pgfutil@tempdima% |
| 1177 |
\pgf@pos@transform{\pgf@xa}{\pgf@ya} |
| 1178 |
\pgf@nlt@moveto{\pgf@xa}{\pgf@ya}% |
| 1179 |
\pgf@xa=\pgf@xb% |
| 1180 |
\pgf@ya=\pgfutil@tempdima% |
| 1181 |
\pgf@pos@transform{\pgf@xa}{\pgf@ya} |
| 1182 |
\pgf@nlt@lineto{\pgf@xa}{\pgf@ya}% |
| 1183 |
}% |
| 1184 |
\fi% |
| 1185 |
\fi% |
| 1186 |
\ifdim \pgf@xc > .01pt\relax% if to draw vertical lines |
| 1187 |
\c@pgf@counta=\pgf@xa\relax% |
| 1188 |
\c@pgf@countb=\pgf@xc\relax% |
| 1189 |
\divide\c@pgf@counta by\c@pgf@countb\relax% |
| 1190 |
\pgfutil@tempdimb=\c@pgf@counta\pgf@xc\relax% |
| 1191 |
\ifdim\pgfutil@tempdimb<\pgf@xa% |
| 1192 |
\advance\pgfutil@tempdimb by\pgf@xc% |
| 1193 |
\fi% |
| 1194 |
\pgfutil@loop% vertical lines |
| 1195 |
{% |
| 1196 |
\pgf@xc=\pgfutil@tempdimb% |
| 1197 |
\pgf@yc=\pgf@ya% |
| 1198 |
\pgf@pos@transform{\pgf@xc}{\pgf@yc} |
| 1199 |
\pgf@nlt@moveto{\pgf@xc}{\pgf@yc}% |
| 1200 |
\pgf@xc=\pgfutil@tempdimb% |
| 1201 |
\pgf@yc=\pgf@yb% |
| 1202 |
\pgf@pos@transform{\pgf@xc}{\pgf@yc} |
| 1203 |
\pgf@nlt@lineto{\pgf@xc}{\pgf@yc}% |
| 1204 |
}% |
| 1205 |
\advance\pgfutil@tempdimb by\pgf@xc% |
| 1206 |
\ifdim\pgfutil@tempdimb<\pgf@xb% |
| 1207 |
\pgfutil@repeat% |
| 1208 |
\advance\pgfutil@tempdimb by-0.01pt\relax% |
| 1209 |
\ifdim\pgfutil@tempdimb<\pgf@xb% |
| 1210 |
{% |
| 1211 |
\pgf@xc=\pgfutil@tempdimb% |
| 1212 |
\pgf@yc=\pgf@ya% |
| 1213 |
\pgf@pos@transform{\pgf@xc}{\pgf@yc} |
| 1214 |
\pgf@nlt@moveto{\pgf@xc}{\pgf@yc}% |
| 1215 |
\pgf@xc=\pgfutil@tempdimb% |
| 1216 |
\pgf@yc=\pgf@yb% |
| 1217 |
\pgf@pos@transform{\pgf@xc}{\pgf@yc} |
| 1218 |
\pgf@nlt@lineto{\pgf@xc}{\pgf@yc}% |
| 1219 |
}% |
| 1220 |
\fi% |
| 1221 |
\fi% |
| 1222 |
\pgf@process{#3}% |
| 1223 |
\pgf@pos@transform{\pgf@x}{\pgf@y}% |
| 1224 |
\pgf@nlt@moveto{\pgf@x}{\pgf@y}% |
| 1225 |
} |
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
% Append two half-parabolas to the path |
| 1230 |
% |
| 1231 |
% #1 = bend (relative to current point) |
| 1232 |
% #2 = end point (relative to bend point) |
| 1233 |
% |
| 1234 |
% Description: |
| 1235 |
% |
| 1236 |
% This command appends a half-parabola that starts at the current point |
| 1237 |
% and has its bend at #1+current point. Then, a second parabola is |
| 1238 |
% appended that starts at #1+current point, where it also has its |
| 1239 |
% minimum/maximum, and ends at #1+current point+#2, which becomes the |
| 1240 |
% new current point. |
| 1241 |
% |
| 1242 |
% By setting #2 = (0,0) you draw only a half parabola that goes from the |
| 1243 |
% current point to the bend; by setting #1 = (0,0) |
| 1244 |
% you draw a half parabola that going to current point + #2 and has its |
| 1245 |
% bend at the current point. |
| 1246 |
% |
| 1247 |
% Examples: |
| 1248 |
% |
| 1249 |
% % Half-parabola going ``up and right'' |
| 1250 |
% \pgfpathmoveto{\pgfpointorigin} |
| 1251 |
% \pgfpathparabola{\pgfpointorigin}{\pgfpoint{2cm}{4cm}} |
| 1252 |
% |
| 1253 |
% % Half-parabola going ``down and right'' |
| 1254 |
% \pgfpathmoveto{\pgfpointorigin} |
| 1255 |
% \pgfpathparabola{\pgfpoint{-2cm}{4cm}}}{\pgfpointorigin} |
| 1256 |
% |
| 1257 |
% % Full parabola |
| 1258 |
% \pgfpathmoveto{\pgfpointorigin} |
| 1259 |
% \pgfpathparabola{\pgfpoint{-2cm}{4cm}}{\pgfpoint{2cm}{4cm}} |
| 1260 |
|
| 1261 |
\def\pgfpathparabola#1#2{% |
| 1262 |
{% |
| 1263 |
\pgf@process{#2}% untransformed |
| 1264 |
\pgf@xb=\pgf@x% |
| 1265 |
\pgf@yb=\pgf@y% |
| 1266 |
\pgf@process{#1}% untransformed |
| 1267 |
\pgf@xc=\pgf@x% |
| 1268 |
\pgf@yc=\pgf@y% |
| 1269 |
\pgfutil@tempswatrue% |
| 1270 |
\ifdim\pgf@xb=0pt\relax% |
| 1271 |
\ifdim\pgf@yb=0pt\relax% |
| 1272 |
\pgfutil@tempswafalse% |
| 1273 |
\fi% |
| 1274 |
\fi% |
| 1275 |
{% |
| 1276 |
\ifpgfutil@tempswa% |
| 1277 |
\pgf@arccornersfalse |
| 1278 |
\else% |
| 1279 |
\fi% |
| 1280 |
\pgfutil@tempswatrue% |
| 1281 |
\ifdim\pgf@xc=0pt\relax% |
| 1282 |
\ifdim\pgf@yc=0pt\relax% |
| 1283 |
\pgfutil@tempswafalse% |
| 1284 |
\fi% |
| 1285 |
\fi% |
| 1286 |
\ifpgfutil@tempswa |
| 1287 |
{% |
| 1288 |
\pgf@pt@x=\pgf@path@lastx% |
| 1289 |
\pgf@pt@y=\pgf@path@lasty% |
| 1290 |
\pgfpathcurveto% |
| 1291 |
{\pgfqpoint{.1125\pgf@xc}{.225\pgf@yc}}% found by trial and error |
| 1292 |
{\pgfqpoint{.5\pgf@xc}{\pgf@yc}}% found by trial and error |
| 1293 |
{\pgfqpoint{\pgf@xc}{\pgf@yc}}% |
| 1294 |
}% |
| 1295 |
\fi% |
| 1296 |
}% |
| 1297 |
\ifpgfutil@tempswa% |
| 1298 |
\pgf@xc=\pgf@xb% |
| 1299 |
\pgf@yc=\pgf@yb% |
| 1300 |
{% |
| 1301 |
\pgf@pt@x=\pgf@path@lastx% |
| 1302 |
\pgf@pt@y=\pgf@path@lasty% |
| 1303 |
\pgfpathcurveto% |
| 1304 |
{\pgfqpoint{.5\pgf@xc}{0\pgf@yc}}% found by trial and error |
| 1305 |
{\pgfqpoint{.8875\pgf@xc}{.775\pgf@yc}}% found by trial and error |
| 1306 |
{\pgfqpoint{\pgf@xc}{\pgf@yc}}% |
| 1307 |
}% |
| 1308 |
\fi% |
| 1309 |
}% |
| 1310 |
} |
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
% Append a sine curve between 0 and \pi/2 to the path. |
| 1316 |
% |
| 1317 |
% #1 = vector, describing the width and height of the curve |
| 1318 |
% |
| 1319 |
% Description: |
| 1320 |
% |
| 1321 |
% This command appends a sine curve in the interval 0 and \pi/2 to the |
| 1322 |
% current path. The sine curve ends at currentpoint+#1. |
| 1323 |
% |
| 1324 |
% Examples: |
| 1325 |
% |
| 1326 |
% % One complete sine in the interval [0,\pi] |
| 1327 |
% \pgfpathmoveto{\pgfpointorigin} |
| 1328 |
% \pgfpathsine{\pgfpoint{1.57cm}{1cm}} |
| 1329 |
% \pgfpathcosine{\pgfpoint{3.141cm}{0cm}} |
| 1330 |
|
| 1331 |
\def\pgfpathsine#1{% |
| 1332 |
{% |
| 1333 |
\pgf@process{#1}% untransformed |
| 1334 |
\pgf@xc=\pgf@x% |
| 1335 |
\pgf@yc=\pgf@y% |
| 1336 |
\pgf@pt@x=\pgf@path@lastx% evil trickery to transform to the last point |
| 1337 |
\pgf@pt@y=\pgf@path@lasty% |
| 1338 |
\pgfpathcurveto% |
| 1339 |
{\pgfqpoint{.3260\pgf@xc}{.5120\pgf@yc}}% |
| 1340 |
{\pgfqpoint{.6380\pgf@xc}{\pgf@yc}}% |
| 1341 |
{\pgfqpoint{\pgf@xc}{\pgf@yc}}% |
| 1342 |
}% |
| 1343 |
} |
| 1344 |
|
| 1345 |
% Append a cosine curve between 0 and \pi/2 to the path. |
| 1346 |
% |
| 1347 |
% #1 = vector, describing the width and height of the curve |
| 1348 |
% |
| 1349 |
% Examples: |
| 1350 |
% |
| 1351 |
% % One complete sine in the interval [0,\pi] |
| 1352 |
% \pgfpathmoveto{\pgfpointorigin} |
| 1353 |
% \pgfpathsine{\pgfpoint{1.57cm}{1cm}} |
| 1354 |
% \pgfpathcosine{\pgfpoint{3.141cm}{0cm}} |
| 1355 |
|
| 1356 |
\def\pgfpathcosine#1{% |
| 1357 |
{% |
| 1358 |
\pgf@process{#1}% untransformed |
| 1359 |
\pgf@xc=\pgf@x% |
| 1360 |
\pgf@yc=\pgf@y% |
| 1361 |
\pgf@pt@x=\pgf@path@lastx% evil trickery to transform to the last point |
| 1362 |
\pgf@pt@y=\pgf@path@lasty% |
| 1363 |
\pgfpathcurveto% |
| 1364 |
{\pgfqpoint{.3620\pgf@xc}{0pt}}% |
| 1365 |
{\pgfqpoint{.6740\pgf@xc}{.4880\pgf@yc}}% |
| 1366 |
{\pgfqpoint{\pgf@xc}{\pgf@yc}}% |
| 1367 |
}% |
| 1368 |
} |
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
% Draw part of a curve between two specified times s and t. |
| 1373 |
% |
| 1374 |
% #1 - a start time s. |
| 1375 |
% #2 - an end time t. |
| 1376 |
% #3 - start point of the curve |
| 1377 |
% #4 - first control |
| 1378 |
% #5 - second control |
| 1379 |
% #6 - end point of the curve |
| 1380 |
% |
| 1381 |
% There are two versions, \pgfpathcurvebetweentime and |
| 1382 |
% \pgfpathcurvebetweentimecontinue. The latter does not insert a |
| 1383 |
% moveto to the first point. |
| 1384 |
% |
| 1385 |
\def\pgfpathcurvebetweentime{\pgf@ignoremovetofalse\pgf@@pathcurvebetweentime} |
| 1386 |
\def\pgfpathcurvebetweentimecontinue{\pgf@ignoremovetotrue\pgf@@pathcurvebetweentime} |
| 1387 |
\newif\ifpgf@ignoremoveto |
| 1388 |
|
| 1389 |
\def\pgf@@pathcurvebetweentime#1#2#3#4#5#6{% |
| 1390 |
\pgfmathparse{#1}% |
| 1391 |
\let\pgf@time@s=\pgfmathresult% |
| 1392 |
\pgfmathparse{#2}% |
| 1393 |
\let\pgf@time@t=\pgfmathresult% |
| 1394 |
\ifdim\pgf@time@s pt>\pgf@time@t pt\relax% |
| 1395 |
\pgfmathsetmacro\pgf@time@s{1-#1}% |
| 1396 |
\pgfmathsetmacro\pgf@time@t{1-#2}% |
| 1397 |
\pgf@@@pathcurvebetweentime{\pgf@time@t}{#6}{#5}{#4}{#3}% |
| 1398 |
\else% |
| 1399 |
\pgf@@@pathcurvebetweentime{\pgf@time@t}{#3}{#4}{#5}{#6}% |
| 1400 |
\fi% |
| 1401 |
} |
| 1402 |
|
| 1403 |
\def\pgf@@@pathcurvebetweentime#1#2#3#4#5{% |
| 1404 |
% Q1 = P1. |
| 1405 |
\pgf@process{#2}% |
| 1406 |
\pgf@xc=\pgf@x% |
| 1407 |
\pgf@yc=\pgf@y% |
| 1408 |
% Q2 = P1 + t*(P2-P1). |
| 1409 |
\pgf@process{% |
| 1410 |
\pgf@process{#3}% |
| 1411 |
\pgf@xa=#1\pgf@x% |
| 1412 |
\pgf@ya=#1\pgf@y% |
| 1413 |
\pgf@process{#2}% |
| 1414 |
\pgf@xb=\pgf@x% |
| 1415 |
\pgf@yb=\pgf@y% |
| 1416 |
\advance\pgf@x by-#1\pgf@xb% |
| 1417 |
\advance\pgf@y by-#1\pgf@yb% |
| 1418 |
\advance\pgf@x by\pgf@xa% |
| 1419 |
\advance\pgf@y by\pgf@ya% |
| 1420 |
}% |
| 1421 |
\pgf@xb=\pgf@x% |
| 1422 |
\pgf@yb=\pgf@y% |
| 1423 |
% Q3 = Q2 + t*((P2 + t*(P3-P2)) - Q2). |
| 1424 |
\pgf@process{% |
| 1425 |
\pgf@process{#4}% |
| 1426 |
\pgf@xa=#1\pgf@x% |
| 1427 |
\pgf@ya=#1\pgf@y% |
| 1428 |
% |
| 1429 |
\pgf@process{#3}% |
| 1430 |
\pgf@xc=\pgf@x% |
| 1431 |
\pgf@yc=\pgf@y% |
| 1432 |
\advance\pgf@xc by-#1\pgf@x% |
| 1433 |
\advance\pgf@yc by-#1\pgf@y% |
| 1434 |
% |
| 1435 |
\pgf@x=\pgf@xb% |
| 1436 |
\pgf@y=\pgf@yb% |
| 1437 |
\advance\pgf@x by#1\pgf@xa% |
| 1438 |
\advance\pgf@y by#1\pgf@ya% |
| 1439 |
\advance\pgf@x by-#1\pgf@xb% |
| 1440 |
\advance\pgf@y by-#1\pgf@yb% |
| 1441 |
\advance\pgf@x by#1\pgf@xc% |
| 1442 |
\advance\pgf@y by#1\pgf@yc% |
| 1443 |
}% |
| 1444 |
\pgf@xa=\pgf@x% |
| 1445 |
\pgf@ya=\pgf@y% |
| 1446 |
% Q4 = (1-t)^3*P1 + 3*t(1-t)^2*P2 + 3*t^2(1-t)*P3 + t^3*P4. |
| 1447 |
\pgf@process{\pgfpointcurveattime{#1}{#2}{#3}{#4}{#5}}% |
| 1448 |
\ifx#1\pgf@time@t% |
| 1449 |
% First time round... |
| 1450 |
\pgfmathdivide@{\pgf@time@s}{\pgf@time@t}% |
| 1451 |
\pgfmathadd@{-\pgfmathresult}{1}% |
| 1452 |
\let\pgf@time@s=\pgfmathresult% |
| 1453 |
\edef\pgf@marshal{% |
| 1454 |
\noexpand\pgf@@@pathcurvebetweentime{\noexpand\pgf@time@s}% |
| 1455 |
{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% |
| 1456 |
{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% |
| 1457 |
}% |
| 1458 |
\else% |
| 1459 |
% ...second time round. |
| 1460 |
\ifpgf@ignoremoveto% |
| 1461 |
\edef\pgf@marshal{% |
| 1462 |
\noexpand\pgfpathcurveto{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% |
| 1463 |
{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% |
| 1464 |
}% |
| 1465 |
\else% |
| 1466 |
\edef\pgf@marshal{% |
| 1467 |
\noexpand\pgfpathmoveto{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% |
| 1468 |
\noexpand\pgfpathcurveto{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% |
| 1469 |
{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% |
| 1470 |
}% |
| 1471 |
\fi% |
| 1472 |
\fi% |
| 1473 |
\pgf@marshal% |
| 1474 |
} |
| 1475 |
|
| 1476 |
|
| 1477 |
\endinput |