summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-nfold/tikzlibrarynfold.code.tex
blob: 799fa6b4d9719b5d543c494fa76341e45314907f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
%% tikzlibrarynfold.code.tex
%% Copyright 2023 Jonathan Schulz
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008-05-04 or later.
%
% This work has the LPPL maintenance status 'maintained'.
%
% The Current Maintainer of this work is Jonathan Schulz.
%
% This work consists of the files
% 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.
%
%
% A commented version of this file can be found on https://github.com/jonschz/tikz-nfold .
%


\usepgflibrary{nfold}
\usetikzlibrary{arrows.meta}

\tikzset{
  nfold/.code={
    \edef\pgf@tmp{\noexpand\pgfkeys{/pgf/nfold=#1}}
    \expandafter\expandafter\expandafter\def%
      \expandafter\expandafter\expandafter\tikz@double@setup%
      \expandafter\expandafter\expandafter{\expandafter\tikz@double@setup\pgf@tmp}
  },
  nfold/.default=2,
  scaling nfold/.code={%
    \pgfscope%
      \tikz@double@setup
      \pgf@nfold@compute@widths@from@double
      \pgf@y=2\pgf@y
      \c@pgf@counta=#1
      \advance\c@pgf@counta by -1\relax
      \global\pgf@y=\c@pgf@counta\pgf@y
    \endpgfscope
    \tikzset{
      double distance between line centers=\pgf@y,
      nfold=#1
    }
  },
  scaling nfold/.default=2,
  commutative diagrams/scaling nfold/.code={
    \pgfscope%
      \tikz@double@setup
      \pgf@nfold@compute@widths@from@double
      \c@pgf@counta=#1
      \advance\c@pgf@counta by -1\relax
      \pgf@ya=\c@pgf@counta\pgf@y
      \advance\c@pgf@counta by -1\relax
      \pgf@xa=\c@pgf@counta\pgf@y
      \advance\pgf@xa by .5\pgf@x
      \global\pgf@x=\pgf@xa
      \global\pgf@y=2\pgf@ya
    \endpgfscope
    \tikzset{
      commutative diagrams/every label/.append style/.expanded={outer sep=\the\pgf@x},
      double distance between line centers=\pgf@y,
      nfold=#1
    }
  },
  commutative diagrams/scaling nfold/.default=2
}

\endinput