| 1 |
% Copyright 2022 by Qrrbrbirlbel |
| 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 |
\pgfutil@IfUndefined{pgfnodepartthreebox}{% |
| 9 |
\csname newbox\endcsname\pgfnodepartleftbox |
| 10 |
\csname newbox\endcsname\pgfnodepartrightbox |
| 11 |
}{% |
| 12 |
\let\pgfnodepartleftbox\pgfnodeparttwobox |
| 13 |
\let\pgfnodepartrightbox\pgfnodepartthreebox |
| 14 |
} |
| 15 |
\unless\ifcsname pgfextset\endcsname |
| 16 |
\input tikzext-util.tex |
| 17 |
\fi |
| 18 |
|
| 19 |
\newif\iftikzext@uncenteredrectangle@usesavedcenter |
| 20 |
|
| 21 |
\pgfextset{ |
| 22 |
uncentered rectangle use saved center/.is if=tikzext@uncenteredrectangle@usesavedcenter, |
| 23 |
uncentered rectangle center yshift/.initial=, |
| 24 |
uncentered rectangle center/@center/.initial=2, |
| 25 |
uncentered rectangle center/.is choice, |
| 26 |
uncentered rectangle center/real/.code=\pgfkeyssetvalue{/pgf/ext/uncentered rectangle center/@center}{0}, |
| 27 |
uncentered rectangle center/left/.code=\pgfkeyssetvalue{/pgf/ext/uncentered rectangle center/@center}{1}, |
| 28 |
uncentered rectangle center/text/.code=\pgfkeyssetvalue{/pgf/ext/uncentered rectangle center/@center}{2}, |
| 29 |
uncentered rectangle center/right/.code=\pgfkeyssetvalue{/pgf/ext/uncentered rectangle center/@center}{3}} |
| 30 |
|
| 31 |
\pgfdeclareshape{ext_uncentered rectangle}{% |
| 32 |
\nodeparts{text,left,right}% |
| 33 |
\savedanchor\middleCenter{% |
| 34 |
\pgf@x=.5\wd\pgfnodeparttextbox |
| 35 |
% |
| 36 |
\pgf@y=\dp\pgfnodeparttextbox |
| 37 |
\ifdim\dp\pgfnodepartleftbox>\pgf@y |
| 38 |
\pgf@y=\dp\pgfnodepartleftbox |
| 39 |
\fi |
| 40 |
\ifdim\dp\pgfnodepartrightbox>\pgf@y |
| 41 |
\pgf@y=\dp\pgfnodepartrightbox |
| 42 |
\fi |
| 43 |
% |
| 44 |
\pgf@ya=\ht\pgfnodeparttextbox |
| 45 |
\ifdim\ht\pgfnodepartleftbox>\pgf@ya |
| 46 |
\pgf@ya=\ht\pgfnodepartleftbox |
| 47 |
\fi |
| 48 |
\ifdim\ht\pgfnodepartrightbox>\pgf@ya |
| 49 |
\pgf@ya=\ht\pgfnodepartrightbox |
| 50 |
\fi |
| 51 |
\advance\pgf@ya by -\pgf@y |
| 52 |
\pgf@y=.5\pgf@ya |
| 53 |
}% |
| 54 |
\savedanchor\leftCenter{% |
| 55 |
% y should be still the same as before |
| 56 |
\pgf@x=-.5\wd\pgfnodepartleftbox |
| 57 |
}% |
| 58 |
\savedanchor\rightCenter{% |
| 59 |
% y should be still the same as before |
| 60 |
\pgf@x=.5\wd\pgfnodepartrightbox |
| 61 |
\advance\pgf@x by \wd\pgfnodeparttextbox |
| 62 |
}% |
| 63 |
\savedanchor\realCenter{% |
| 64 |
% y should be still the same as before |
| 65 |
\pgf@x=-.5\wd\pgfnodepartleftbox |
| 66 |
\advance\pgf@x by .5\wd\pgfnodeparttextbox |
| 67 |
\advance\pgf@x by .5\wd\pgfnodepartrightbox |
| 68 |
}% |
| 69 |
\savedanchor\southwest{% |
| 70 |
% total width |
| 71 |
\pgf@xa=\wd\pgfnodepartleftbox |
| 72 |
\advance\pgf@xa by\wd\pgfnodepartrightbox |
| 73 |
\advance\pgf@xa by\wd\pgfnodeparttextbox |
| 74 |
% |
| 75 |
\pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/inner xsep}}% |
| 76 |
\advance\pgf@xa by 2\pgf@xc |
| 77 |
\pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% |
| 78 |
\ifdim\pgf@xb>\pgf@xa |
| 79 |
\pgf@xa=\pgf@xb |
| 80 |
\fi |
| 81 |
% left side of shape |
| 82 |
\advance\pgf@x by -.5\pgf@xa |
| 83 |
\pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% |
| 84 |
\advance\pgf@x by -\pgf@xa |
| 85 |
% |
| 86 |
% total height |
| 87 |
\pgf@ya=\dp\pgfnodepartleftbox |
| 88 |
\ifdim\pgf@ya<\dp\pgfnodeparttextbox |
| 89 |
\pgf@ya=\dp\pgfnodeparttextbox |
| 90 |
\fi |
| 91 |
\ifdim\pgf@ya<\dp\pgfnodepartrightbox |
| 92 |
\pgf@ya=\dp\pgfnodepartrightbox |
| 93 |
\fi |
| 94 |
\pgf@yb=\ht\pgfnodepartleftbox |
| 95 |
\ifdim\pgf@yb<\ht\pgfnodeparttextbox |
| 96 |
\pgf@yb=\ht\pgfnodeparttextbox |
| 97 |
\fi |
| 98 |
\ifdim\pgf@yb<\ht\pgfnodepartrightbox |
| 99 |
\pgf@yb=\ht\pgfnodepartrightbox |
| 100 |
\fi |
| 101 |
\advance\pgf@ya by \pgf@yb |
| 102 |
% |
| 103 |
\pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}% |
| 104 |
\advance\pgf@ya by 2\pgf@yc |
| 105 |
\pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% |
| 106 |
\ifdim\pgf@yb>\pgf@ya |
| 107 |
\pgf@ya=\pgf@yb |
| 108 |
\fi |
| 109 |
% lower side of the shape |
| 110 |
\advance\pgf@y by -.5\pgf@ya |
| 111 |
\pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% |
| 112 |
\advance\pgf@y by -\pgf@ya |
| 113 |
}% |
| 114 |
\savedanchor\northeast{% |
| 115 |
% first, let's calculate the real center again: |
| 116 |
% |
| 117 |
\pgf@x=-.5\wd\pgfnodepartleftbox |
| 118 |
\advance\pgf@x by .5\wd\pgfnodeparttextbox |
| 119 |
\advance\pgf@x by .5\wd\pgfnodepartrightbox |
| 120 |
% |
| 121 |
\pgf@y=\dp\pgfnodeparttextbox |
| 122 |
\ifdim\dp\pgfnodepartleftbox>\pgf@y |
| 123 |
\pgf@y=\dp\pgfnodepartleftbox |
| 124 |
\fi |
| 125 |
\ifdim\dp\pgfnodepartrightbox>\pgf@y |
| 126 |
\pgf@y=\dp\pgfnodepartrightbox |
| 127 |
\fi |
| 128 |
% |
| 129 |
\pgf@ya=\ht\pgfnodeparttextbox |
| 130 |
\ifdim\ht\pgfnodepartleftbox>\pgf@ya |
| 131 |
\pgf@ya=\ht\pgfnodepartleftbox |
| 132 |
\fi |
| 133 |
\ifdim\ht\pgfnodepartrightbox>\pgf@ya |
| 134 |
\pgf@ya=\ht\pgfnodepartrightbox |
| 135 |
\fi |
| 136 |
\advance\pgf@ya by -\pgf@y |
| 137 |
\pgf@y=.5\pgf@ya |
| 138 |
% |
| 139 |
% now we can calculate the anchor |
| 140 |
% total width |
| 141 |
% |
| 142 |
\pgf@xa=\wd\pgfnodepartleftbox |
| 143 |
\advance\pgf@xa by\wd\pgfnodepartrightbox |
| 144 |
\advance\pgf@xa by\wd\pgfnodeparttextbox |
| 145 |
% |
| 146 |
\pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/inner xsep}}% |
| 147 |
\advance\pgf@xa by 2\pgf@xc |
| 148 |
\pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}% |
| 149 |
\ifdim\pgf@xb>\pgf@xa |
| 150 |
\pgf@xa=\pgf@xb |
| 151 |
\fi |
| 152 |
% right side of shape |
| 153 |
\advance\pgf@x by .5\pgf@xa |
| 154 |
\pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}% |
| 155 |
\advance\pgf@x by \pgf@xa |
| 156 |
% |
| 157 |
% total height |
| 158 |
\pgf@ya=\dp\pgfnodepartleftbox |
| 159 |
\ifdim\pgf@ya<\dp\pgfnodeparttextbox |
| 160 |
\pgf@ya=\dp\pgfnodeparttextbox |
| 161 |
\fi |
| 162 |
\ifdim\pgf@ya<\dp\pgfnodepartrightbox |
| 163 |
\pgf@ya=\dp\pgfnodepartrightbox |
| 164 |
\fi |
| 165 |
\pgf@yb=\ht\pgfnodepartleftbox |
| 166 |
\ifdim\pgf@yb<\ht\pgfnodeparttextbox |
| 167 |
\pgf@yb=\ht\pgfnodeparttextbox |
| 168 |
\fi |
| 169 |
\ifdim\pgf@yb<\ht\pgfnodepartrightbox |
| 170 |
\pgf@yb=\ht\pgfnodepartrightbox |
| 171 |
\fi |
| 172 |
\advance\pgf@ya by \pgf@yb |
| 173 |
% |
| 174 |
\pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}% |
| 175 |
\advance\pgf@ya by 2\pgf@yc |
| 176 |
\pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}% |
| 177 |
\ifdim\pgf@yb>\pgf@ya |
| 178 |
\pgf@ya=\pgf@yb |
| 179 |
\fi |
| 180 |
% upper side of the shape |
| 181 |
\advance\pgf@y by .5\pgf@ya |
| 182 |
\pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}% |
| 183 |
\advance\pgf@y by \pgf@ya |
| 184 |
}% |
| 185 |
% |
| 186 |
\savedmacro\center{% |
| 187 |
\pgfkeysgetvalue{/pgf/ext/uncentered rectangle center/@center}\center |
| 188 |
} |
| 189 |
\anchor{center}{% |
| 190 |
\ifcase |
| 191 |
\iftikzext@uncenteredrectangle@usesavedcenter |
| 192 |
\center |
| 193 |
\else |
| 194 |
\pgfkeysvalueof{/pgf/ext/uncentered rectangle center/@center}% |
| 195 |
\fi\relax |
| 196 |
\realCenter\or |
| 197 |
\leftCenter\or |
| 198 |
\middleCenter\or |
| 199 |
\rightCenter\else |
| 200 |
\realCenter |
| 201 |
\fi |
| 202 |
\pgfkeysgetvalue{/pgf/ext/uncentered rectangle center yshift}\pgf@temp |
| 203 |
\pgfutil@ifxempty\pgf@temp{% real center used |
| 204 |
}{% calculate center |
| 205 |
\pgfmathsetlength\pgf@y{\pgf@temp}% |
| 206 |
}% |
| 207 |
}% |
| 208 |
\anchor{left} {\leftCenter \multiply\pgf@x by2 \pgf@y=0pt } |
| 209 |
\anchor{right} {\middleCenter\multiply\pgf@x by2 \pgf@y=0pt } |
| 210 |
\anchor{real center} {\realCenter} |
| 211 |
\anchor{left center} {\leftCenter} |
| 212 |
\anchor{right center}{\rightCenter} |
| 213 |
\anchor{text center} {\middleCenter} |
| 214 |
\anchor{south west} {\southwest} |
| 215 |
\anchor{north east} {\northeast} |
| 216 |
\anchor{mid}{% |
| 217 |
\csname pgf@anchor@ext_uncentered rectangle@center\endcsname |
| 218 |
\pgfmathsetlength\pgf@y{.5ex}}% |
| 219 |
\anchor{base}{% |
| 220 |
\csname pgf@anchor@ext_uncentered rectangle@center\endcsname |
| 221 |
\pgf@y=0pt |
| 222 |
}% |
| 223 |
\anchor{left mid} {\leftCenter \pgfmathsetlength\pgf@y{+.5ex}} |
| 224 |
\anchor{text mid} {\middleCenter\pgfmathsetlength\pgf@y{+.5ex}} |
| 225 |
\anchor{right mid} {\rightCenter \pgfmathsetlength\pgf@y{+.5ex}} |
| 226 |
\anchor{real mid} {\realCenter \pgfmathsetlength\pgf@y{+.5ex}} |
| 227 |
\anchor{left base} {\leftCenter \pgf@y=0pt } |
| 228 |
\anchor{text base} {\middleCenter\pgf@y=0pt } |
| 229 |
\anchor{right base} {\rightCenter \pgf@y=0pt } |
| 230 |
\anchor{real base} {\realCenter \pgf@y=0pt } |
| 231 |
\anchor{real south} {\pgf@anchor@rectangle@south} |
| 232 |
\anchor{real north} {\pgf@anchor@rectangle@north} |
| 233 |
\anchor{text north} {\pgf@anchor@rectangle@north\pgf@ya=\pgf@y\middleCenter\pgf@y=\pgf@ya} |
| 234 |
\anchor{left north} {\pgf@anchor@rectangle@north\pgf@ya=\pgf@y\leftCenter \pgf@y=\pgf@ya} |
| 235 |
\anchor{right north}{\pgf@anchor@rectangle@north\pgf@ya=\pgf@y\rightCenter \pgf@y=\pgf@ya} |
| 236 |
\anchor{text south} {\pgf@anchor@rectangle@south\pgf@ya=\pgf@y\middleCenter\pgf@y=\pgf@ya} |
| 237 |
\anchor{left south} {\pgf@anchor@rectangle@south\pgf@ya=\pgf@y\leftCenter \pgf@y=\pgf@ya} |
| 238 |
\anchor{right south}{\pgf@anchor@rectangle@south\pgf@ya=\pgf@y\rightCenter \pgf@y=\pgf@ya} |
| 239 |
\anchor{north}{% |
| 240 |
\pgf@anchor@rectangle@north |
| 241 |
\pgf@ya=\pgf@y |
| 242 |
\csname pgf@anchor@ext_uncentered rectangle@center\endcsname |
| 243 |
\pgf@y=\pgf@ya |
| 244 |
} |
| 245 |
\anchor{south}{% |
| 246 |
\pgf@anchor@rectangle@south |
| 247 |
\pgf@ya=\pgf@y |
| 248 |
\csname pgf@anchor@ext_uncentered rectangle@center\endcsname |
| 249 |
\pgf@y=\pgf@ya |
| 250 |
} |
| 251 |
%\anchor{base right}{\middleCenter\pgf@xa=2\pgf@x}% TODO |
| 252 |
\anchor{real west}{% |
| 253 |
\pgf@process{\northeast}% |
| 254 |
\pgf@ya=.5\pgf@y |
| 255 |
\pgf@process{\southwest}% |
| 256 |
\pgf@y=.5\pgf@y |
| 257 |
\advance\pgf@y by \pgf@ya |
| 258 |
}% |
| 259 |
\anchor{real east}{% |
| 260 |
\pgf@process{\southwest}% |
| 261 |
\pgf@ya=.5\pgf@y |
| 262 |
\pgf@process{\northeast}% |
| 263 |
\pgf@y=.5\pgf@y |
| 264 |
\advance\pgf@y by \pgf@ya |
| 265 |
}% |
| 266 |
\anchor{west}{% |
| 267 |
\pgf@process{\southwest}% |
| 268 |
\pgf@xa=\pgf@x |
| 269 |
\pgf@process{\csname pgf@anchor@ext_uncentered rectangle@center\endcsname}% |
| 270 |
\pgf@x=\pgf@xa |
| 271 |
}% |
| 272 |
\anchor{east}{% |
| 273 |
\pgf@process{\northeast}% |
| 274 |
\pgf@xa=\pgf@x |
| 275 |
\pgf@process{\csname pgf@anchor@ext_uncentered rectangle@center\endcsname}% |
| 276 |
\pgf@x=\pgf@xa |
| 277 |
}% |
| 278 |
\inheritanchor[from=rectangle]{south west} |
| 279 |
\inheritanchor[from=rectangle]{north west} |
| 280 |
\inheritanchor[from=rectangle]{south east} |
| 281 |
\inheritanchor[from=rectangle]{north east} |
| 282 |
\inheritanchor[from=rectangle]{mid west} |
| 283 |
\inheritanchor[from=rectangle]{mid east} |
| 284 |
\inheritanchor[from=rectangle]{base west} |
| 285 |
\inheritanchor[from=rectangle]{base east} |
| 286 |
\inheritbackgroundpath[from=rectangle] |
| 287 |
\anchorborder{% |
| 288 |
% xa/ya is target |
| 289 |
\pgf@xa=\pgf@x |
| 290 |
\pgf@ya=\pgf@y |
| 291 |
% xc/yc is "center" |
| 292 |
\pgf@process{\csname pgf@anchor@ext_uncentered rectangle@center\endcsname}% |
| 293 |
\pgf@xc=\pgf@x |
| 294 |
\pgf@yc=\pgf@y |
| 295 |
\ifdim\pgf@xa<0pt |
| 296 |
% left side |
| 297 |
\southwest |
| 298 |
\pgf@xb=\pgf@x |
| 299 |
\pgf@yb=\pgf@y |
| 300 |
\advance\pgf@xb by -\pgf@xc |
| 301 |
\ifdim\pgf@ya<0pt |
| 302 |
% south west side |
| 303 |
\advance\pgf@yb by -\pgf@yc |
| 304 |
\pgf@yb=-\pgf@yb |
| 305 |
\else |
| 306 |
% north west side |
| 307 |
\northeast |
| 308 |
\pgf@yb=\pgf@y |
| 309 |
\advance\pgf@yb by -\pgf@yc |
| 310 |
\fi |
| 311 |
\pgf@xb=-\pgf@xb |
| 312 |
\edef\pgf@marshal{% |
| 313 |
\noexpand\pgfpointborderrectangle |
| 314 |
{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}} |
| 315 |
{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% |
| 316 |
}% |
| 317 |
\else |
| 318 |
% right side |
| 319 |
\northeast |
| 320 |
\pgf@xb=\pgf@x |
| 321 |
\pgf@yb=\pgf@y |
| 322 |
\advance\pgf@xb by -\pgf@xc |
| 323 |
\ifdim\pgf@ya>0pt |
| 324 |
% north east side |
| 325 |
\advance\pgf@yb by -\pgf@yc |
| 326 |
\else |
| 327 |
% south east side |
| 328 |
\southwest |
| 329 |
\pgf@yb=\pgf@y |
| 330 |
\advance\pgf@yb by -\pgf@yc |
| 331 |
\pgf@yb=-\pgf@yb |
| 332 |
\fi |
| 333 |
\edef\pgf@marshal{% |
| 334 |
\noexpand\pgfpointborderrectangle |
| 335 |
{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}} |
| 336 |
{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% |
| 337 |
}% |
| 338 |
\fi |
| 339 |
\pgf@process{\pgf@marshal}% |
| 340 |
\advance\pgf@x by\pgf@xc |
| 341 |
\advance\pgf@y by\pgf@yc |
| 342 |
}% |
| 343 |
} |
| 344 |
%%% Compatibility |
| 345 |
\pgfkeysifdefined{/tikz/ext/compat/shapes/.@cmd}{}{\pgfextset{/tikz-ext/compat/add library={shapes}{pre 0.6}}} |
| 346 |
\tikzextset{ |
| 347 |
compat/shapes/warn/.append style=/tikz/ext/compat/shapes.uncenteredrectangle/warn, |
| 348 |
compat/shapes/pre 0.6/.append style=/tikz/ext/compat/shapes.uncenteredrectangle/pre 0.6, |
| 349 |
compat/shapes.uncenteredrectangle/warn/.code={% |
| 350 |
\tikzextutil@compatwarning@key{shapes}{pre 0.6}{/pgf/uncentered rectangle use saved center}[true]{/pgf/ext/uncentered rectangle use saved center}% |
| 351 |
\tikzextutil@compatwarning@valuekey{shapes}{pre 0.6}{/pgf/uncentered rectangle center yshift}{/pgf/ext/uncentered rectangle center yshift} |
| 352 |
\tikzextutil@compatwarning@key{shapes}{pre 0.6}{/pgf/uncentered rectangle center}{/pgf/ext/uncentered rectangle center} |
| 353 |
\tikzextutil@compat@cloneshape{uncentered rectangle}{text,north,north west,north east,center,west,east,mid,mid west,mid east,base,base west,base east,south,south west,south east,center,real center,real mid,real base,real south,left,left north,left center,left mid,left base,left south,text north,text center,text mid,text base,text south,right north,right center,right mid,right base,right south}% |
| 354 |
\def\tikzext@temp{\tikzextutil@compatmaybewarning{shape 'uncentered rectangle'}{'ext_uncentered rectangle'}{shapes = pre 0.6}}% |
| 355 |
\expandafter\tikzextutil@prefix@macrotomacro\csname pgf@sh@s@uncentered rectangle\endcsname\tikzext@temp |
| 356 |
}, |
| 357 |
compat/shapes.uncenteredrectangle/pre 0.6/.code={% |
| 358 |
\pgfkeysdef{/pgf/uncentered rectangle use saved center}{\pgfkeysvalueof{/pgf/ext/uncentered rectangle use saved center/.@cmd}##1\pgfeov}% |
| 359 |
\pgfkeyssetvalue{/pgf/uncentered rectangle use saved center/.@def}{true}% |
| 360 |
\pgfkeysdef{/pgf/uncentered rectangle center}{\pgfkeysvalueof{/pgf/ext/uncentered rectangle center/.@cmd}##1\pgfeov}% |
| 361 |
\pgfkeysdef{/pgf/uncentered rectangle center yshift}{\pgfkeyssetvalue{/pgf/ext/uncentered rectangle center yshift}{##1}}% |
| 362 |
\pgfkeyssetvalue{/pgf/uncentered rectangle center yshift}{\pgfkeysvalueof{/pgf/ext/uncentered rectangle center yshift}}% |
| 363 |
\tikzextutil@compat@cloneshape{uncentered rectangle}{text,north,north west,north east,center,west,east,mid,mid west,mid east,base,base west,base east,south,south west,south east,center,real center,real mid,real base,real south,left,left north,left center,left mid,left base,left south,text north,text center,text mid,text base,text south,right north,right center,right mid,right base,right south}% |
| 364 |
}, |
| 365 |
compat/shapes.uncenteredrectangle/\pgfkeysvalueof{/tikz/ext/compat/shapes}% |
| 366 |
} |
| 367 |
\endinput |