summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-ext/tikzlibraryext.transformations.mirror.code.tex
blob: 026b39ab2f2e0d67bdc4075c0bdb9ae2c4a97d08 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
% Copyright 2022 by Qrrbrbirlbel
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%
\usepgflibrary{ext.transformations.mirror}
\tikzset{
  mirror/.code={%
    \pgfutil@in@{--}{#1}%
    \ifpgfutil@in@
      \tikzext@trans@mirror#1\tikz@stop
    \else
      \tikz@addtransform{\tikz@scan@one@point\pgfqtransformmirror#1\relax}%
    \fi},
  ymirror/.code={\pgfutil@ifnextchar(\tikzext@trans@ymirror@coordinate\tikzext@trans@ymirror@simple#1\tikz@stop},
  xmirror/.code={\pgfutil@ifnextchar(\tikzext@trans@xmirror@coordinate\tikzext@trans@xmirror@simple#1\tikz@stop},
  mirror x/.code={%
    \pgfextract@process\tikz@temp{\tikz@scan@one@point\pgfutil@firstofone#1\relax}%
    \edef\tikz@marshal{%
      \noexpand\tikz@addtransform{%
        \noexpand\pgftransformmirror
          {\expandafter\noexpand\tikz@temp}
          {\noexpand\pgfpointadd{\expandafter\noexpand\tikz@temp}
                                {\noexpand\pgfqpointxy{0}{1}}}}}%
    \tikz@marshal
  },
  mirror y/.code={%
    \pgfextract@process\tikz@temp{\tikz@scan@one@point\pgfutil@firstofone#1\relax}%
    \edef\tikz@marshal{%
    \noexpand\tikz@addtransform{%
      \noexpand\pgftransformmirror
        {\expandafter\noexpand\tikz@temp}
        {\noexpand\pgfpointadd{\expandafter\noexpand\tikz@temp}
                              {\noexpand\pgfqpointxy{1}{0}}}}}%
    \tikz@marshal
  },
  mirror/.value required,
  ymirror/.default=+0pt,
  xmirror/.default=+0pt,
  mirror x/.default={(0,0)},
  mirror y/.default={(0,0)}%
}
\def\tikzext@trans@mirror#1--#2\tikz@stop{%
  \tikz@addtransform{%
    \pgftransformmirror{\tikz@scan@one@point\pgfutil@firstofone#1\relax}
                       {\tikz@scan@one@point\pgfutil@firstofone#2\relax}}}
\def\tikzext@trans@xmirror@simple#1\tikz@stop{\tikz@addtransform{\pgftransformxmirror{#1}}}
\def\tikzext@trans@ymirror@simple#1\tikz@stop{\tikz@addtransform{\pgftransformymirror{#1}}}
\def\tikzext@trans@xmirror@coordinate#1\tikz@stop{%
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \edef\tikz@marshal{%
    \noexpand\tikz@addtransform{%
      \noexpand\pgftransformxmirror{+\the\pgf@x}%
    }%
  }%
  \tikz@marshal
}
\def\tikzext@trans@ymirror@coordinate#1\tikz@stop{%
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \edef\tikz@marshal{%
    \noexpand\tikz@addtransform{%
      \noexpand\pgftransformymirror{+\the\pgf@y}%
    }%
  }%
  \tikz@marshal
}

\tikzset{
  Mirror/.code={%
    \pgfutil@in@{--}{#1}%
    \ifpgfutil@in@
      \tikzext@trans@Mirror#1\tikz@stop
    \else
      \tikz@addtransform{\tikz@scan@one@point\pgfqtransformMirror#1\relax}%
    \fi},
  yMirror/.code={\pgfutil@ifnextchar(\tikzext@trans@yMirror@coordinate\tikzext@trans@yMirror@simple#1\tikz@stop},
  xMirror/.code={\pgfutil@ifnextchar(\tikzext@trans@xMirror@coordinate\tikzext@trans@xMirror@simple#1\tikz@stop},
  Mirror x/.code={%
    \pgfextract@process\tikz@temp{\tikz@scan@one@point\pgfutil@firstofone#1\relax}%
    \edef\tikz@marshal{%
      \noexpand\tikz@addtransform{%
        \noexpand\pgftransformMirror
          {\expandafter\noexpand\tikz@temp}
          {\noexpand\pgfpointadd{\expandafter\noexpand\tikz@temp}
                                {\noexpand\pgfqpointxy{0}{1}}}}}%
    \tikz@marshal
  },
  Mirror y/.code={%
    \pgfextract@process\tikz@temp{\tikz@scan@one@point\pgfutil@firstofone#1\relax}%
    \edef\tikz@marshal{%
    \noexpand\tikz@addtransform{%
      \noexpand\pgftransformMirror
        {\expandafter\noexpand\tikz@temp}
        {\noexpand\pgfpointadd{\expandafter\noexpand\tikz@temp}
                              {\noexpand\pgfqpointxy{1}{0}}}}}%
    \tikz@marshal
  },
  Mirror/.value required,
  yMirror/.default=+0pt,
  xMirror/.default=+0pt,
  Mirror x/.default={(0,0)},
  Mirror y/.default={(0,0)}%
}
\def\tikzext@trans@Mirror#1--#2\tikz@stop{%
  \tikz@addtransform{%
    \pgftransformMirror{\tikz@scan@one@point\pgfutil@firstofone#1\relax}
                       {\tikz@scan@one@point\pgfutil@firstofone#2\relax}}}
\def\tikzext@trans@xMirror@simple#1\tikz@stop{\tikz@addtransform{\pgftransformxMirror{#1}}}
\def\tikzext@trans@yMirror@simple#1\tikz@stop{\tikz@addtransform{\pgftransformyMirror{#1}}}
\def\tikzext@trans@xMirror@coordinate#1\tikz@stop{%
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \edef\tikz@marshal{%
    \noexpand\tikz@addtransform{%
      \noexpand\pgftransformxMirror{+\the\pgf@x}%
    }%
  }%
  \tikz@marshal
}
\def\tikzext@trans@yMirror@coordinate#1\tikz@stop{%
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \edef\tikz@marshal{%
    \noexpand\tikz@addtransform{%
      \noexpand\pgftransformyMirror{+\the\pgf@y}%
    }%
  }%
  \tikz@marshal
}
\endinput