Debian Codegraph @

texmf-dist/tex/latex/tqft/tqft.sty

raw
1 %%
2 %% This is file `tqft.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% tqft_code.dtx (with options: `package')
8 %% ----------------------------------------------------------------
9 %% tqft --- a TikZ library for drawing TQFT diagrams
10 %% E-mail: [email protected]
11 %% Released under the LaTeX Project Public License v1.3c or later
12 %% See http://www.latex-project.org/lppl.txt
13 %% ----------------------------------------------------------------
14 %%
15 \NeedsTeXFormat{LaTeX2e}
16 \ProvidesPackage{tqft}[2017/06/01 v2.1 Tikz/PGF commands for drawing TQFT diagrams]
17 \RequirePackage{pgfkeys}
18 \RequirePackage{pgf}
19 \def\pgf@tqft@minus{-}
20 \let\pgf@tqft@upper\@empty
21 \let\pgf@tqft@lower\pgf@tqft@minus
22 \def\tqftset#1{\pgfkeys{/pgf/tqft/.cd,#1}}
23 \def\tqft@process#1#2{%
24 \edef\tqft@px{#1}
25 \edef\tqft@py{#2}
26 \pgf@process{
27 \pgftransformreset
28 \let\tikz@transform=\pgfutil@empty
29 \expandafter\tikzset\expandafter{\tqft@transformation}
30 \tikz@transform
31 \pgfpointtransformed{\pgfqpoint{\tqft@px}{\tqft@py}}
32 }
33 }
34 \newdimen\tqft@xa
35 \newdimen\tqft@xb
36 \newdimen\tqft@c
37 \newdimen\tqft@ch
38 \newdimen\tqft@h
39 \newdimen\tqft@s
40 \newdimen\tqft@w
41 \newif\iftqft@within@node
42 \pgfkeys{
43 /tikz/tqft/use nodes/.is choice,
44 /tikz/tqft/use nodes/true/.code={%
45 \tikzset{
46 tqft/.style={%
47 /tikz/shape=tqft cobordism,
48 /pgf/tqft,
49 /tikz/every tqft/.try
50 },
51 tqft/.unknown/.code={%
52 \let\tqft@searchname=\pgfkeyscurrentname%
53 \pgfkeys{%
54 /pgf/tqft/\tqft@searchname={##1}
55 }
56 },
57 }%
58 },
59 /tikz/tqft/use nodes/false/.code={%
60 \tikzset{
61 tqft/.style={%
62 pic type=cobordism,
63 tqft/.cd,
64 every tqft/.try,
65 },
66 tqft/.unknown/.code={%
67 \let\tqft@searchname=\pgfkeyscurrentname%
68 \pgfkeys{%
69 /tikz/\tqft@searchname={##1}
70 }
71 },
72 }%
73 },
74 /tikz/tqft/use nodes=true,
75 /pgf/tqft/.unknown/.code={%
76 \let\tqft@searchname=\pgfkeyscurrentname%
77 \pgfkeysalso{%
78 /tikz/\tqft@searchname={#1}
79 }
80 },
81 /pgf/tqft/.is family,
82 /pgf/tqft,
83 boundary circle/.style={
84 /tikz/shape=tqft boundary circle
85 },
86 incoming boundary components/.initial=5,
87 outgoing boundary components/.initial=4,
88 offset/.initial=0,
89 cobordism height/.initial=2cm,
90 boundary separation/.initial=2cm,
91 circle width/.initial=10pt,
92 circle depth/.initial=5pt,
93 outer xsep/.initial=0pt,
94 outer ysep/.initial=0pt,
95 outer sep/.style={
96 outer xsep=#1,
97 outer ysep=#1
98 },
99 flow/.code={%
100 \pgfkeys{/pgf/tqft/flow transformation/.expand twice/.expand once=\pgfkeysvalueof{/pgf/tqft/flow transformation #1}}
101 },
102 flow transformation south/.initial={},
103 flow transformation north/.initial={%
104 xscale=-1,rotate=180
105 },
106 flow transformation east/.initial={%
107 rotate=90,xscale=-1
108 },
109 flow transformation west/.initial={%
110 rotate=270
111 },
112 flow transformation/.initial={},
113 view from/.is choice,
114 view from/incoming/.code={%
115 \let\pgf@tqft@upper\pgf@tqft@minus
116 \let\pgf@tqft@lower\@empty
117 },
118 view from/outgoing/.code={%
119 \let\pgf@tqft@lower\pgf@tqft@minus
120 \let\pgf@tqft@upper\@empty
121 },
122 boundary lower style contents/.initial={},
123 boundary lower style/.code={%
124 \pgfkeys{/pgf/tqft/boundary lower style contents/.style={%
125 /tikz/.cd,#1
126 }
127 }
128 },
129 boundary style contents/.initial={},
130 boundary style/.code={%
131 \pgfkeys{/pgf/tqft/boundary style contents/.style={%
132 /tikz/.cd,#1
133 }
134 }
135 },
136 boundary upper style contents/.initial={},
137 boundary upper style/.code={%
138 \pgfkeys{/pgf/tqft/boundary upper style contents/.style={%
139 /tikz/.cd,#1
140 }
141 }
142 },
143 cobordism style contents/.initial={},
144 cobordism style/.code={%
145 \pgfkeys{/pgf/tqft/cobordism style contents/.style={%
146 /tikz/.cd,#1%
147 }
148 }
149 },
150 pair of pants/.style={
151 /tikz/tqft,
152 incoming boundary components=1,
153 outgoing boundary components=2,
154 offset=-.5
155 },
156 /tikz/tqft pair of pants/.style={
157 /pgf/tqft/pair of pants,
158 },
159 reverse pair of pants/.style={
160 /tikz/tqft,
161 incoming boundary components=2,
162 outgoing boundary components=1,
163 offset=.5
164 },
165 /tikz/tqft reverse pair of pants/.style={
166 /pgf/tqft/reverse pair of pants,
167 },
168 cylinder to prior/.style={
169 /tikz/tqft,
170 incoming boundary components=1,
171 outgoing boundary components=1,
172 offset=-.5
173 },
174 /tikz/tqft cylinder to prior/.style={
175 /pgf/tqft/cylinder to prior,
176 },
177 cylinder to next/.style={
178 /tikz/tqft,
179 incoming boundary components=1,
180 outgoing boundary components=1,
181 offset=.5
182 },
183 /tikz/tqft cylinder to next/.style={
184 /pgf/tqft/cylinder to next,
185 },
186 cylinder/.style={
187 /tikz/tqft,
188 incoming boundary components=1,
189 outgoing boundary components=1
190 },
191 /tikz/tqft cylinder/.style={
192 /pgf/tqft/cylinder,
193 },
194 cup/.style={
195 /tikz/tqft,
196 incoming boundary components=1,
197 outgoing boundary components=0
198 },
199 /tikz/tqft cup/.style={
200 /pgf/tqft/cup,
201 },
202 cap/.style={
203 /tikz/tqft,
204 incoming boundary components=0,
205 outgoing boundary components=1
206 },
207 /tikz/tqft cap/.style={
208 /pgf/tqft/cap,
209 },
210 }
211 \pgfdeclareshape{tqft cobordism}{
212 \savedmacro{\tqft@incoming}{\edef\tqft@incoming{\pgfkeysvalueof{/pgf/tqft/incoming boundary components}}}
213 \savedmacro{\tqft@outgoing}{\edef\tqft@outgoing{\pgfkeysvalueof{/pgf/tqft/outgoing boundary components}}}
214 \savedmacro{\tqft@offset}{\edef\tqft@offset{\pgfkeysvalueof{/pgf/tqft/offset}}}
215 \saveddimen{\tqft@height}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/cobordism height}}
216 \saveddimen{\tqft@separation}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/boundary separation}}
217 \saveddimen{\tqft@width}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/circle width}}
218 \saveddimen{\tqft@depth}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/circle depth}}
219 \saveddimen{\tqft@outerxsep}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/outer xsep}}
220 \saveddimen{\tqft@outerysep}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/outer ysep}}
221 \saveddimen{\tqft@control}{
222 \pgfkeysgetvalue{/pgf/tqft/cobordism height}{\tqft@tempa}
223 \pgfkeysgetvalue{/pgf/tqft/circle depth}{\tqft@tempb}
224 \pgfmathsetlength{\pgf@x}{.5 * \tqft@tempa - 4 * \tqft@tempb}
225 }
226 \savedmacro{\tqft@transformation}{%
227 \pgfkeysgetvalue{/pgf/tqft/flow transformation}{\tqft@transformation}
228 }
229 \savedanchor{\tqft@start@incoming}{%
230 \pgfmathsetlength{\pgf@x}{-(max(\pgfkeysvalueof{/pgf/tqft/incoming boundary components} - 1,\pgfkeysvalueof{/pgf/tqft/outgoing boundary components} - 1 + \pgfkeysvalueof{/pgf/tqft/offset}) + min(0,\pgfkeysvalueof{/pgf/tqft/offset}) )*\pgfkeysvalueof{/pgf/tqft/boundary separation}/2}
231 \pgfmathsetlength{\pgf@y}{.5 * \pgfkeysvalueof{/pgf/tqft/cobordism height}}
232 }
233 \savedanchor{\tqft@start@outgoing}{%
234 \pgfmathsetlength{\pgf@x}{-(max(\pgfkeysvalueof{/pgf/tqft/incoming boundary components} - 1,\pgfkeysvalueof{/pgf/tqft/outgoing boundary components} - 1 + \pgfkeysvalueof{/pgf/tqft/offset}) + min(0,\pgfkeysvalueof{/pgf/tqft/offset})- 2*\pgfkeysvalueof{/pgf/tqft/offset})*\pgfkeysvalueof{/pgf/tqft/boundary separation}/2}
235 \pgfmathsetlength{\pgf@y}{-.5 * \pgfkeysvalueof{/pgf/tqft/cobordism height}}
236 }
237 \savedanchor{\tqft@textsize}{%
238 \pgf@y=-.5\ht\pgfnodeparttextbox%
239 \pgf@x=-.5\wd\pgfnodeparttextbox%
240 }
241 \anchor{centre}{\pgfpointorigin}
242 \anchor{center}{\pgfpointorigin}
243 \anchor{text}{
244 \tqft@textsize
245 }
246 \anchor{north}{%
247 \pgf@ya=\tqft@height\relax
248 \pgf@yb=.5\pgf@ya
249 \advance\pgf@yb by \tqft@outerysep\relax
250 \tqft@process{0pt}{\the\pgf@yb}
251 }
252 \anchor{south}{%
253 \pgf@yb=\tqft@height\relax
254 \pgf@ya=.5\pgf@yb
255 \advance\pgf@ya by \tqft@outerysep\relax
256 \pgf@yb=-\pgf@ya
257 \tqft@process{0pt}{\the\pgf@yb}
258 }
259 \anchor{west}{%
260 \tqft@start@incoming
261 \pgf@xa=\pgf@x
262 \advance\pgf@xa by -\tqft@width
263 \pgf@ya=\pgf@y
264 \tqft@start@outgoing
265 \pgf@xb=\pgf@x
266 \advance\pgf@xb by -\tqft@width
267 \pgf@yb=\pgf@y
268 \pgf@xc=.5\pgf@xa
269 \advance\pgf@xc by .5\pgf@xb
270 \pgf@yc=.5\pgf@ya
271 \advance\pgf@yc by .5\pgf@yb
272 \advance\pgf@xc by -\tqft@outerxsep\relax
273 \tqft@process{\the\pgf@xc}{\the\pgf@yc}
274 }
275 \anchor{east}{%
276 \tqft@start@incoming
277 \pgf@xa=\pgf@x
278 \pgfmathsetlength{\pgf@xa}{\pgf@xa + (\tqft@incoming - 1) * \tqft@separation}
279 \advance\pgf@xa by \tqft@width\relax
280 \pgf@ya=\pgf@y
281 \tqft@start@outgoing
282 \pgf@xb=\pgf@x
283 \pgfmathsetlength{\pgf@xb}{\pgf@xb + (\tqft@outgoing - 1) * \tqft@separation}
284 \advance\pgf@xb by \tqft@width\relax
285 \pgf@yb=\pgf@y
286 \pgf@xc=.5\pgf@xa
287 \advance\pgf@xc by .5\pgf@xb
288 \pgf@yc=.5\pgf@ya
289 \advance\pgf@yc by .5\pgf@yb
290 \advance\pgf@xc by \tqft@outerxsep\relax
291 \tqft@process{\the\pgf@xc}{\the\pgf@yc}
292 }
293 \anchor{north west}{
294 \tqft@start@incoming
295 \pgf@xc=\pgf@x
296 \pgf@yc=\pgf@y
297 \advance\pgf@xc by -\tqft@width\relax
298 \advance\pgf@yc by \tqft@outerysep\relax
299 \advance\pgf@xc by -\tqft@outerxsep\relax
300 \tqft@process{\the\pgf@xc}{\the\pgf@yc}
301 }
302 \anchor{south west}{
303 \tqft@start@outgoing
304 \pgf@xc=\pgf@x
305 \pgf@yc=\pgf@y
306 \advance\pgf@xc by -\tqft@width\relax
307 \advance\pgf@yc by -\tqft@outerysep\relax
308 \advance\pgf@xc by -\tqft@outerxsep\relax
309 \tqft@process{\the\pgf@xc}{\the\pgf@yc}
310 }
311 \anchor{north east}{
312 \tqft@start@incoming
313 \pgf@xc=\pgf@x
314 \pgfmathsetlength{\pgf@xc}{\pgf@xc + (\tqft@incoming - 1)*\tqft@separation}
315 \pgf@yc=\pgf@y
316 \advance\pgf@xc by \tqft@width\relax
317 \advance\pgf@yc by \tqft@outerysep\relax
318 \advance\pgf@xc by \tqft@outerxsep\relax
319 \tqft@process{\the\pgf@xc}{\the\pgf@yc}
320 }
321 \anchor{south east}{
322 \tqft@start@outgoing
323 \pgf@xc=\pgf@x
324 \pgfmathsetlength{\pgf@xc}{\pgf@xc + (\tqft@outgoing - 1)*\tqft@separation}
325 \pgf@yc=\pgf@y
326 \advance\pgf@xc by \tqft@width\relax
327 \advance\pgf@yc by -\tqft@outerysep\relax
328 \advance\pgf@xc by \tqft@outerxsep\relax
329 \tqft@process{\the\pgf@xc}{\the\pgf@yc}
330 }
331 \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@tqft cobordism\endcsname{%
332 \c@pgf@counta\tqft@incoming\relax%
333 \pgfmathloop%
334 \ifnum\c@pgf@counta>0\relax%
335 \pgfutil@ifundefined{pgf@anchor@tqft cobordism@incoming boundary\space\the\c@pgf@counta}{%
336 \expandafter\xdef\csname pgf@anchor@tqft cobordism@incoming boundary\space\the\c@pgf@counta\endcsname{%
337 \noexpand\tqft@start@incoming
338 \noexpand\pgfmathsetlength{\noexpand\pgf@y}{\noexpand\pgf@y + \noexpand\tqft@outerysep}
339 \noexpand\pgfmathsetlength{\noexpand\pgf@x}{\noexpand\pgf@x + (\the\c@pgf@counta - 1) * \noexpand\tqft@separation}
340 \noexpand\tqft@process{\noexpand\the\noexpand\pgf@x}{\noexpand\the\noexpand\pgf@y}
341 }
342 }{\c@pgf@counta0\relax}%
343 \advance\c@pgf@counta-1\relax%
344 \repeatpgfmathloop%
345 }
346 \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@tqft cobordism\endcsname{%
347 \c@pgf@counta\tqft@outgoing\relax%
348 \pgfmathloop%
349 \ifnum\c@pgf@counta>0\relax%
350 \pgfutil@ifundefined{pgf@anchor@tqft cobordism@outgoing boundary\space\the\c@pgf@counta}{%
351 \expandafter\xdef\csname pgf@anchor@tqft cobordism@outgoing boundary\space\the\c@pgf@counta\endcsname{%
352 \noexpand\tqft@start@outgoing
353 \noexpand\pgfmathsetlength{\noexpand\pgf@y}{\noexpand\pgf@y - \noexpand\tqft@outerysep}
354 \noexpand\pgfmathsetlength{\noexpand\pgf@x}{\noexpand\pgf@x + (\the\c@pgf@counta - 1) * \noexpand\tqft@separation}
355 \noexpand\tqft@process{\noexpand\the\noexpand\pgf@x}{\noexpand\the\noexpand\pgf@y}
356 }
357 }{\c@pgf@counta0\relax}%
358 \advance\c@pgf@counta-1\relax%
359 \repeatpgfmathloop%
360 }
361 \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@tqft cobordism\endcsname{%
362 \c@pgf@counta\tqft@incoming\relax%
363 \advance\c@pgf@counta-1\relax
364 \pgfmathloop%
365 \ifnum\c@pgf@counta>0\relax%
366 \pgfutil@ifundefined{pgf@anchor@tqft cobordism@after incoming boundary\space\the\c@pgf@counta}{%
367 \expandafter\xdef\csname pgf@anchor@tqft cobordism@after incoming boundary\space\the\c@pgf@counta\endcsname{%
368 \noexpand\tqft@start@incoming
369 \noexpand\pgfmathsetlength{\noexpand\pgf@y}{.25 * \noexpand\pgf@y +.75 * \noexpand\tqft@control + \noexpand\tqft@outerysep}
370 \noexpand\pgfmathsetlength{\noexpand\pgf@x}{\noexpand\pgf@x + (\the\c@pgf@counta - .5) * \noexpand\tqft@separation}
371 \noexpand\tqft@process{\noexpand\the\noexpand\pgf@x}{\noexpand\the\noexpand\pgf@y}
372 }
373 }{\c@pgf@counta0\relax}%
374 \advance\c@pgf@counta-1\relax%
375 \repeatpgfmathloop%
376 }
377 \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@tqft cobordism\endcsname{%
378 \c@pgf@counta\tqft@outgoing\relax%
379 \advance\c@pgf@counta-1\relax
380 \pgfmathloop%
381 \ifnum\c@pgf@counta>0\relax%
382 \pgfutil@ifundefined{pgf@anchor@tqft cobordism@after outgoing boundary\space\the\c@pgf@counta}{%
383 \expandafter\xdef\csname pgf@anchor@tqft cobordism@after outgoing boundary\space\the\c@pgf@counta\endcsname{%
384 \noexpand\tqft@start@outgoing
385 \noexpand\pgfmathsetlength{\noexpand\pgf@y}{.25 * \noexpand\pgf@y -.75 * \noexpand\tqft@control - \noexpand\tqft@outerysep}
386 \noexpand\pgfmathsetlength{\noexpand\pgf@x}{\noexpand\pgf@x + (\the\c@pgf@counta - .5) * \noexpand\tqft@separation}
387 \noexpand\tqft@process{\noexpand\the\noexpand\pgf@x}{\noexpand\the\noexpand\pgf@y}
388 }
389 }{\c@pgf@counta0\relax}%
390 \advance\c@pgf@counta-1\relax%
391 \repeatpgfmathloop%
392 }
393 \backgroundpath{
394 \let\tikz@transform=\pgfutil@empty
395 \expandafter\tikzset\expandafter{\tqft@transformation}
396 \tikz@transform
397 \pgfmathsetlength{\tqft@s}{\tqft@separation}
398 \pgfmathsetlength{\tqft@w}{2*\tqft@width}
399 \tqft@start@incoming
400 \tqft@xa=\pgf@x
401 \advance\tqft@xa by -.5\tqft@w\relax
402 \tqft@h=\pgf@y
403 \tqft@xb=\tqft@xa
404 \advance\tqft@xb by \tqft@w\relax
405 \tqft@c=\tqft@control\relax
406 \ifnum\tqft@incoming>0
407 \pgfpathmoveto{\pgfqpoint{\tqft@xa}{\tqft@h}}
408 \pgfpatharc{\pgf@tqft@upper180}{0}{\tqft@width and \tqft@depth}
409 \ifnum\tqft@incoming>1
410 \foreach \tqft@k in {2,...,\tqft@incoming} {
411 \advance\tqft@xa by \tqft@k\tqft@s
412 \advance\tqft@xb by \tqft@k\tqft@s
413 \advance\tqft@xb by -2\tqft@s
414 \advance\tqft@xa by -\tqft@s
415 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{\tqft@c}}{\pgfqpoint{\tqft@xa}{\tqft@c}}{\pgfqpoint{\tqft@xa}{\tqft@h}}
416 \pgfpatharc{\pgf@tqft@upper180}{0}{\tqft@width and \tqft@depth}
417 }
418 \fi
419 \ifnum\tqft@outgoing=0
420 \advance\tqft@xb by \tqft@incoming\tqft@s
421 \advance\tqft@xb by -\tqft@s
422 \pgfmathsetlength{\tqft@ch}{min(0,max(-\tqft@h,\tqft@h - (\tqft@h - \tqft@c) * ((abs(\tqft@xb - \tqft@xa) - \tqft@w)/\tqft@s + 1)))}
423 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{\tqft@ch}}{\pgfqpoint{\tqft@xa}{\tqft@ch}}{\pgfqpoint{\tqft@xa}{\tqft@h}}
424 \fi
425 \fi
426 \ifnum\tqft@outgoing>0
427 \advance\tqft@xb by \tqft@incoming\tqft@s
428 \advance\tqft@xb by -\tqft@s
429 \pgfmathsetlength{\tqft@xa}{\tqft@xa + (\tqft@outgoing - 1 + \tqft@offset) * \tqft@separation + 2*\tqft@width}
430 \ifnum\tqft@incoming>0
431 \pgfmathsetlength{\tqft@ch}{min(0,max(-\tqft@h,\tqft@h - (\tqft@h - \tqft@c) * ((abs(\tqft@xb - \tqft@xa) - \tqft@w)/\tqft@s + 1)))}
432 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{\tqft@ch}}{\pgfqpoint{\tqft@xa}{-\tqft@ch}}{\pgfqpoint{\tqft@xa}{-\tqft@h}}
433 \else
434 \pgfpathmoveto{\pgfqpoint{\tqft@xa}{-\tqft@h}}
435 \fi
436 \tqft@xb=\tqft@xa
437 \advance\tqft@xb by -\tqft@w
438 \pgfpatharc{0}{\pgf@tqft@upper180}{\tqft@width and \tqft@depth}
439 \ifnum\tqft@outgoing>1
440 \foreach \tqft@k in {2,...,\tqft@outgoing} {
441 \advance\tqft@xa by -\tqft@k\tqft@s
442 \advance\tqft@xb by -\tqft@k\tqft@s
443 \advance\tqft@xb by 2\tqft@s
444 \advance\tqft@xa by \tqft@s
445 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{-\tqft@c}}{\pgfqpoint{\tqft@xa}{-\tqft@c}}{\pgfqpoint{\tqft@xa}{-\tqft@h}}
446 \pgfpatharc{0}{\pgf@tqft@upper180}{\tqft@width and \tqft@depth}
447 }
448 \fi
449 \advance\tqft@xb by -\tqft@outgoing\tqft@s
450 \advance\tqft@xb by \tqft@s
451 \ifnum\tqft@incoming>0
452 \pgfmathsetlength{\tqft@xa}{\tqft@xa - (\tqft@outgoing -1 + \tqft@offset) * \tqft@separation - 2*\tqft@width}
453 \pgfmathsetlength{\tqft@ch}{min(0,max(-\tqft@h,\tqft@h - (\tqft@h - \tqft@c) * ((abs(\tqft@xb - \tqft@xa) - \tqft@w)/\tqft@s + 1)))}
454 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{-\tqft@ch}}{\pgfqpoint{\tqft@xa}{\tqft@ch}}{\pgfqpoint{\tqft@xa}{\tqft@h}}
455 \else
456 \pgfmathsetlength{\tqft@ch}{min(0,max(-\tqft@h,\tqft@h - (\tqft@h - \tqft@c) * ((abs(\tqft@xb - \tqft@xa) - \tqft@w)/\tqft@s + 1)))}
457 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{-\tqft@ch}}{\pgfqpoint{\tqft@xa}{-\tqft@ch}}{\pgfqpoint{\tqft@xa}{-\tqft@h}}
458 \fi
459 \fi
460 \pgfpathclose
461 }
462 \behindbackgroundpath{
463 \let\tikz@transform=\pgfutil@empty
464 \expandafter\tikzset\expandafter{\tqft@transformation}
465 \tikz@transform
466 \pgfmathsetlength{\tqft@s}{\tqft@separation}
467 \pgfmathsetlength{\tqft@w}{2*\tqft@width}
468 \pgfmathsetlength{\tqft@xa}{-(max(\tqft@incoming - 1,\tqft@outgoing - 1 + \tqft@offset) + min(0,\tqft@offset) + 2)*\tqft@separation/2}
469 \pgfmathsetlength{\tqft@h}{.5 * \tqft@height}
470 {
471 \tikz@mode@fillfalse%
472 \tikz@mode@drawfalse%
473 \let\tikz@mode=\pgfutil@empty
474 \let\tikz@options=\pgfutil@empty
475 \tqftset{boundary style contents}
476 \tikz@mode
477 \tikz@options
478 \ifnum\tqft@incoming>0
479 \foreach \tqft@k in {1,...,\tqft@incoming} {
480 \advance\tqft@xa by \tqft@k\tqft@s
481 \pgfpathellipse{\pgfqpoint{\tqft@xa}{\tqft@h}}{\pgfqpoint{\tqft@width}{0pt}}{\pgfqpoint{0pt}{\tqft@depth}}
482 }
483 \fi
484 \ifnum\tqft@outgoing>0
485 \pgfmathsetlength{\tqft@xa}{\tqft@xa + (\tqft@outgoing + \tqft@offset + 1) * \tqft@separation}
486 \foreach \tqft@k in {1,...,\tqft@outgoing} {
487 \advance\tqft@xa by -\tqft@k\tqft@s
488 \pgfpathellipse{\pgfqpoint{\tqft@xa}{-\tqft@h}}{\pgfqpoint{\tqft@width}{0pt}}{\pgfqpoint{0pt}{\tqft@depth}}
489 }
490 \fi
491 \edef\tikz@temp{\noexpand\pgfusepath{%
492 \iftikz@mode@fill fill,\fi%
493 \iftikz@mode@draw draw\fi%
494 }}%
495 \tikz@temp
496 }
497 {
498 \tikz@mode@fillfalse%
499 \tikz@mode@drawfalse%
500 \let\tikz@mode=\pgfutil@empty
501 \let\tikz@options=\pgfutil@empty
502 \tqftset{boundary lower style contents}
503 \tikz@mode
504 \tikz@options
505 \advance\tqft@xa by .5\tqft@w
506 \ifnum\tqft@incoming>0
507 \foreach \tqft@k in {1,...,\tqft@incoming} {
508 \advance\tqft@xa by \tqft@k\tqft@s
509 \pgfpathmoveto{\pgfqpoint{\tqft@xa}{\tqft@h}}
510 \pgfpatharc{0}{\pgf@tqft@lower180}{\tqft@width and \tqft@depth}
511 }
512 \fi
513 \ifnum\tqft@outgoing>0
514 \pgfmathsetlength{\tqft@xa}{\tqft@xa + (\tqft@outgoing + \tqft@offset + 1) * \tqft@separation}
515 \foreach \tqft@k in {1,...,\tqft@outgoing} {
516 \advance\tqft@xa by -\tqft@k\tqft@s
517 \pgfpathmoveto{\pgfqpoint{\tqft@xa}{-\tqft@h}}
518 \pgfpatharc{0}{\pgf@tqft@lower180}{\tqft@width and \tqft@depth}
519 }
520 \fi
521 \edef\tikz@temp{\noexpand\pgfusepath{%
522 \iftikz@mode@fill fill,\fi%
523 \iftikz@mode@draw draw\fi%
524 }}%
525 \tikz@temp
526 }
527 }
528 \beforebackgroundpath{
529 \pgfmathsetlength{\tqft@s}{\tqft@separation}
530 \pgfmathsetlength{\tqft@w}{2*\tqft@width}
531 \pgfmathsetlength{\tqft@xa}{-(max(\tqft@incoming - 1,\tqft@outgoing - 1 + \tqft@offset) + min(0,\tqft@offset))*\tqft@s/2 - \tqft@width}
532 \tqft@xb=\tqft@xa
533 \advance\tqft@xb by \tqft@w
534 \tqft@c=\tqft@control\relax
535 \pgfmathsetlength{\tqft@h}{.5 * \tqft@height}
536 {
537 \tikz@mode@fillfalse%
538 \tikz@mode@drawfalse%
539 \let\tikz@mode=\pgfutil@empty
540 \let\tikz@options=\pgfutil@empty
541 \tqftset{cobordism style contents}
542 \tikz@mode
543 \tikz@options
544 \ifnum\tqft@incoming>0
545 \ifnum\tqft@incoming>1
546 \foreach \tqft@k in {2,...,\tqft@incoming} {
547 \advance\tqft@xa by \tqft@k\tqft@s
548 \advance\tqft@xb by \tqft@k\tqft@s
549 \advance\tqft@xb by -2\tqft@s
550 \advance\tqft@xa by -\tqft@s
551 \pgfpathmoveto{\pgfqpoint{\tqft@xb}{\tqft@h}}
552 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{\tqft@c}}{\pgfqpoint{\tqft@xa}{\tqft@c}}{\pgfqpoint{\tqft@xa}{\tqft@h}}
553 }
554 \fi
555 \ifnum\tqft@outgoing=0
556 \advance\tqft@xb by \tqft@incoming\tqft@s
557 \advance\tqft@xb by -\tqft@s
558 \pgfmathsetlength{\tqft@ch}{min(0,max(-\tqft@h,\tqft@h - (\tqft@h - \tqft@c) * ((abs(\tqft@xb - \tqft@xa) - \tqft@w)/\tqft@s + 1)))}
559 \pgfpathmoveto{\pgfqpoint{\tqft@xb}{\tqft@h}}
560 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{\tqft@ch}}{\pgfqpoint{\tqft@xa}{\tqft@ch}}{\pgfqpoint{\tqft@xa}{\tqft@h}}
561 \fi
562 \fi
563 \ifnum\tqft@outgoing>0
564 \advance\tqft@xb by \tqft@incoming\tqft@s
565 \advance\tqft@xb by -\tqft@s
566 \pgfmathsetlength{\tqft@xa}{\tqft@xa + (\tqft@outgoing - 1 + \tqft@offset) * \tqft@separation + 2*\tqft@width}
567 \ifnum\tqft@incoming>0
568 \pgfmathsetlength{\tqft@ch}{min(0,max(-\tqft@h,\tqft@h - (\tqft@h - \tqft@c) * ((abs(\tqft@xb - \tqft@xa) - \tqft@w)/\tqft@s + 1)))}
569 \pgfpathmoveto{\pgfqpoint{\tqft@xb}{\tqft@h}}
570 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{\tqft@ch}}{\pgfqpoint{\tqft@xa}{-\tqft@ch}}{\pgfqpoint{\tqft@xa}{-\tqft@h}}
571 \else
572 \pgfpathmoveto{\pgfqpoint{\tqft@xa}{-\tqft@h}}
573 \fi
574 \tqft@xb=\tqft@xa
575 \advance\tqft@xb by -\tqft@w
576 \pgfpathmoveto{\pgfqpoint{\tqft@xb}{-\tqft@h}}
577 \ifnum\tqft@outgoing>1
578 \foreach \tqft@k in {2,...,\tqft@outgoing} {
579 \advance\tqft@xa by -\tqft@k\tqft@s
580 \advance\tqft@xb by -\tqft@k\tqft@s
581 \advance\tqft@xb by 2\tqft@s
582 \advance\tqft@xa by \tqft@s
583 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{-\tqft@c}}{\pgfqpoint{\tqft@xa}{-\tqft@c}}{\pgfqpoint{\tqft@xa}{-\tqft@h}}
584 \advance\tqft@xa by -\tqft@w
585 \pgfpathmoveto{\pgfqpoint{\tqft@xa}{-\tqft@h}}
586 }
587 \fi
588 \advance\tqft@xb by -\tqft@outgoing\tqft@s
589 \advance\tqft@xb by \tqft@s
590 \ifnum\tqft@incoming>0
591 \pgfmathsetlength{\tqft@xa}{\tqft@xa - (\tqft@outgoing -1 + \tqft@offset) * \tqft@separation - 2*\tqft@width}
592 \pgfmathsetlength{\tqft@ch}{min(0,max(-\tqft@h,\tqft@h - (\tqft@h - \tqft@c) * ((abs(\tqft@xb - \tqft@xa) - \tqft@w)/\tqft@s + 1)))}
593 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{-\tqft@ch}}{\pgfqpoint{\tqft@xa}{\tqft@ch}}{\pgfqpoint{\tqft@xa}{\tqft@h}}
594 \else
595 \pgfmathsetlength{\tqft@ch}{min(0,max(-\tqft@h,\tqft@h - (\tqft@h - \tqft@c) * ((abs(\tqft@xb - \tqft@xa) - \tqft@w)/\tqft@s + 1)))}
596 \pgfpathcurveto{\pgfqpoint{\tqft@xb}{-\tqft@ch}}{\pgfqpoint{\tqft@xa}{-\tqft@ch}}{\pgfqpoint{\tqft@xa}{-\tqft@h}}
597 \fi
598 \fi
599 \edef\tikz@temp{\noexpand\pgfusepath{%
600 \iftikz@mode@fill fill,\fi%
601 \iftikz@mode@draw draw\fi%
602 }}%
603 \tikz@temp
604 }
605 {
606 \let\tqft@bdry@path=\pgfutil@empty
607 \let\tqft@bdry@node@path=\pgfutil@empty
608 \pgfsyssoftpath@setcurrentpath{\tqft@bdry@path}
609 \tikz@mode@fillfalse%
610 \tikz@mode@drawfalse%
611 \let\tikz@mode=\pgfutil@empty
612 \let\tikz@options=\pgfutil@empty
613 \tqftset{boundary upper style contents}
614 \tikz@mode
615 \tikz@options
616 \advance\tqft@xa by -\tqft@s
617 \advance\tqft@xa by \tqft@w
618 \ifnum\tqft@incoming>0
619 \foreach \tqft@k in {1,...,\tqft@incoming} {
620 \advance\tqft@xa by \tqft@k\tqft@s
621 \pgfpathmoveto{\pgfqpoint{\tqft@xa}{\tqft@h}}
622 \pgfpatharc{0}{\pgf@tqft@upper180}{\tqft@width and \tqft@depth}
623 \ifx\tikz@fig@name\pgfutil@empty
624 \else
625 {
626 \advance\tqft@xa by -\tqft@width
627 \pgftransformshift{\pgfqpoint{\tqft@xa}{\tqft@h}}
628 \tqft@within@nodetrue
629 \pgfsyssoftpath@getcurrentpath{\tqft@bdry@path}
630 \pgfsyssoftpath@setcurrentpath{\tqft@bdry@node@path}
631 \pgfnode{tqft boundary circle}{centre}{}{\tikz@fig@name\space incoming \tqft@k}{}
632 \pgfsyssoftpath@getcurrentpath{\tqft@bdry@node@path}
633 \pgfsyssoftpath@setcurrentpath{\tqft@bdry@path}
634 }
635 \fi
636 }
637 \fi
638 \ifnum\tqft@outgoing>0
639 \pgfmathsetlength{\tqft@xa}{\tqft@xa + (\tqft@outgoing + \tqft@offset + 1) * \tqft@separation}
640 \foreach \tqft@k in {1,...,\tqft@outgoing} {
641 \advance\tqft@xa by -\tqft@k\tqft@s
642 \pgfpathmoveto{\pgfqpoint{\tqft@xa}{-\tqft@h}}
643 \pgfpatharc{0}{\pgf@tqft@upper180}{\tqft@width and \tqft@depth}
644 \ifx\tikz@fig@name\pgfutil@empty
645 \else
646 {
647 \pgfmathtruncatemacro{\tqft@l}{\tqft@outgoing + 1 - \tqft@k}
648 \advance\tqft@xa by -\tqft@width
649 \pgftransformshift{\pgfqpoint{\tqft@xa}{-\tqft@h}}
650 \tqft@within@nodetrue
651 \pgfsyssoftpath@getcurrentpath{\tqft@bdry@path}
652 \pgfsyssoftpath@setcurrentpath{\tqft@bdry@node@path}
653 \pgfnode{tqft boundary circle}{centre}{}{\tikz@fig@name\space outgoing \tqft@l}{}
654 \pgfsyssoftpath@getcurrentpath{\tqft@bdry@node@path}
655 \pgfsyssoftpath@setcurrentpath{\tqft@bdry@path}
656 }
657 \fi
658 }
659 \fi
660 \edef\tikz@temp{\noexpand\pgfusepath{%
661 \iftikz@mode@fill fill,\fi%
662 \iftikz@mode@draw draw\fi%
663 }}%
664 \tikz@temp
665 }
666 }
667 }
668 \pgfdeclareshape{tqft boundary circle}{
669 \saveddimen{\tqft@height}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/cobordism height}}
670 \saveddimen{\tqft@separation}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/boundary separation}}
671 \saveddimen{\tqft@width}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/circle width}}
672 \saveddimen{\tqft@depth}{\pgf@x=\pgfkeysvalueof{/pgf/tqft/circle depth}}
673 \savedmacro{\tqft@transformation}{%
674 \iftqft@within@node
675 \let\tqft@transformation=\pgfutil@empty
676 \else
677 \pgfkeysgetvalue{/pgf/tqft/flow transformation}{\tqft@transformation}
678 \fi
679 }
680 \savedanchor{\tqft@centre}{%
681 \pgfpointorigin}
682 \savedanchor{\tqft@textsize}{%
683 \pgf@y=-.5\ht\pgfnodeparttextbox%
684 \pgf@x=-.5\wd\pgfnodeparttextbox%
685 }
686 \anchor{centre}{\tqft@centre}
687 \anchor{center}{\tqft@centre}
688 \anchor{text}{
689 \tqft@textsize
690 }
691 \anchor{next}{%
692 \tqft@process{\tqft@separation}{0pt}}%
693 \anchor{prior}{%
694 \tqft@process{-\tqft@separation}{0pt}}%
695 \anchor{above}{%
696 \tqft@process{0pt}{\tqft@height}}%
697 \anchor{below}{%
698 \tqft@process{0pt}{-\tqft@height}}%
699 \anchorborder{
700 \tqft@process{\the\pgf@x}{\the\pgf@y}
701 \edef\tqft@marshal{%
702 \noexpand\pgfpointborderellipse
703 {\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
704 {\noexpand\pgfqpoint{\tqft@width}{\tqft@depth}}
705 }%
706 \tqft@marshal
707 \tqft@process{\the\pgf@x}{\the\pgf@y}
708 }
709 \backgroundpath{
710 \let\tikz@transform=\pgfutil@empty
711 \expandafter\tikzset\expandafter{\tqft@transformation}
712 \tikz@transform
713 \pgfpathellipse{\pgfqpoint{0pt}{0pt}}{\pgfqpoint{\tqft@width}{0pt}}{\pgfqpoint{0pt}{\tqft@depth}}
714 }
715 \beforebackgroundpath{
716 \iftqft@within@node
717 \else
718 \tikz@mode@fillfalse%
719 \tikz@mode@drawfalse%
720 \let\tikz@mode=\pgfutil@empty
721 \let\tikz@options=\pgfutil@empty
722 {
723 \pgfsys@beginscope
724 \tqftset{boundary lower style contents}
725 \tikz@mode
726 \tikz@options
727 \pgfpathmoveto{\pgfqpoint{\tqft@width}{0pt}}
728 \pgfpatharc{0}{\pgf@tqft@lower180}{\tqft@width and \tqft@depth}
729 \edef\tikz@temp{\noexpand\pgfusepath{%
730 \iftikz@mode@fill fill,\fi%
731 \iftikz@mode@draw draw\fi%
732 }}%
733 \tikz@temp
734 \pgfsys@endscope
735 }
736 {
737 \pgfsys@beginscope
738 \tqftset{boundary upper style contents}
739 \tikz@mode
740 \tikz@options
741 \pgfpathmoveto{\pgfqpoint{\tqft@width}{0pt}}
742 \pgfpatharc{0}{\pgf@tqft@upper180}{\tqft@width and \tqft@depth}
743 \edef\tikz@temp{\noexpand\pgfusepath{%
744 \iftikz@mode@fill fill,\fi%
745 \iftikz@mode@draw draw\fi%
746 }}%
747 \tikz@temp
748 \pgfsys@endscope
749 }
750 \fi
751 }
752 }
753
754 %%
755 %% Copyright (C) 2011-2024 by Andrew Stacey <[email protected]>
756 %%
757 %% This work may be distributed and/or modified under the
758 %% conditions of the LaTeX Project Public License (LPPL), either
759 %% version 1.3c of this license or (at your option) any later
760 %% version. The latest version of this license is in the file:
761 %%
762 %% http://www.latex-project.org/lppl.txt
763 %%
764 %% This work is "maintained" (as per LPPL maintenance status) by
765 %% Andrew Stacey.
766 %%
767 %% This work consists of the files tqft_code.dtx,
768 %% tqft.tex,
769 %% and the derived files tqft_code.ins,
770 %% tqft_code.pdf,
771 %% tqft.pdf,
772 %% tqft.sty, and
773 %% tikzlibrarytqft.code.tex.
774 %%
775 %%
776 %% End of file `tqft.sty'.