Debian Codegraph @

texmf-dist/tex/latex/tikz-nfold/pgflibrarynfold.code.tex

raw
1 %% pgflibrarynfold.code.tex
2 %% Copyright 2023 Jonathan Schulz
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3c
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3c or later is part of all distributions of LaTeX
10 % version 2008-05-04 or later.
11 %
12 % This work has the LPPL maintenance status 'maintained'.
13 %
14 % The Current Maintainer of this work is Jonathan Schulz.
15 %
16 % This work consists of the files
17 % pgflibrarybezieroffset.code.tex, pgflibrarynfold.code.tex, pgflibraryoffsetpath.code.tex, tikz-nfold-doc.tex, tikzlibrarynfold.code.tex, tikz-nfold-doc.tex, and tikz-nfold-doc.pdf.
18 %
19 %
20 % A commented version of this file can be found on https://github.com/jonschz/tikz-nfold .
21 %
22
23
24 \usepgflibrary{offsetpath}
25
26
27 \newcount\pgf@nfold@index
28 \def\pgf@nfold@run@loop{%
29 \pgf@nfold@index=\pgf@nfold@order%
30 \pgf@nfold@run@loop@%
31 }
32
33 \def\pgf@nfold@run@loop@{%
34 \pgf@nfold@loop@inner%
35 \advance\pgf@nfold@index by -1\relax
36 \ifnum\pgf@nfold@index>0\relax%
37 \pgf@nfold@run@loop@%
38 \fi%
39 }
40
41 \def\pgf@nfold@loop@inner{%
42 \pgfmathsetmacro{\pgf@nfold@shift@fraction}%
43 {-1+2*(\pgf@nfold@index-1)/(\pgf@nfold@order-1)}%
44 \pgfmathsetmacro{\pgf@nfold@shiftamount}{\pgf@nfold@hwidth*\pgf@nfold@shift@fraction}
45 \pgftransformreset%
46 \parsedpath%
47 \pgfsyssoftpath@flushcurrentpath%
48 \pgf@up@action%
49 }
50
51 \def\pgf@nfold@compute@widths@from@double{
52 \pgf@x=\pgflinewidth\relax%
53 \pgf@y=\pgf@x\relax%
54 \advance\pgf@x-\pgfinnerlinewidth\relax%
55 \advance\pgf@y+\pgfinnerlinewidth\relax%
56 \pgf@x=.5\pgf@x\relax%
57 \pgf@y=.25\pgf@y\relax%
58 }
59
60 \def\pgf@nfold@render@cached@softpath{%
61 \pgfscope%
62 \pgf@nfold@compute@widths@from@double%
63 \pgfsetlinewidth\pgf@x%
64 \edef\pgf@nfold@hwidth{\the\pgf@y}%
65 \pgfprocessround{\pgf@nfold@cachedpath}{\pgf@nfold@cachedpath}%
66 \pgf@nfold@parsearrows%
67 \pgf@nfold@parsesoftpath{\pgf@nfold@cachedpath}{\parsedpath}%
68 \pgf@nfold@run@loop%
69 \endpgfscope%
70 }
71
72
73 \pgfkeys{
74 /pgf/nfold/.code={%
75 \pgf@nfold@order=#1\relax%
76 \ifnum\pgf@nfold@order<1\relax%
77 \pgfutil@packageerror{tikz-nfold}{The key /pgf/nfold must take a value of at least 1, got \the\pgf@nfold@order}{}%
78 \fi%
79 \ifnum\pgf@nfold@order>\pgf@nfold@intersec@numcached\relax
80 \ifdefined\pgfintersectionofpaths\else
81 \pgf@nfold@intersectionsnotloadedtrue
82 \fi
83 \fi
84 },
85 /pgf/nfold/.default=2
86 }
87
88 \endinput