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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
% Copyright 2008 by Mark Wibrow
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.
\usepgfmodule{decorations}%
% Define the basic decoration stuff for tikz. Load more libraries to
% "actually use" decorations
\tikzset{decorate/.is if=tikz@decoratepath,
/pgf/decoration/name/.store in=\tikz@decoration@name,
/pgf/decoration/.unknown/.code=%
\pgfifdecoration{\pgfkeyscurrentname}{\edef\tikz@decoration@name{\pgfkeyscurrentname}}
{\pgfifmetadecoration{\pgfkeyscurrentname}{\edef\tikz@decoration@name{\pgfkeyscurrentname}}
{\pgfkeys{/errors/unknown
key={/pgf/decoration/\pgfkeyscurrentname}{#1}}}},%
/pgf/decoration/raise/.code={\def\tikz@dec@shift{\pgftransformyshift{#1}}\tikz@dec@trans},
/pgf/decoration/mirror/.code={%
\csname if#1\endcsname
\def\tikz@dec@mirror{\pgftransformyscale{-1}}%
\else%
\let\tikz@dec@mirror=\relax%
\fi%
\tikz@dec@trans%
},
/pgf/decoration/mirror/.default=true,
/pgf/decoration/transform/.code={%
{%
\pgftransformreset%
\def\tikz@transform{}%
\pgfkeysalso{/tikz/.cd, #1}%
\expandafter\gdef\expandafter\tikz@g@temptransform\expandafter{\tikz@transform}%
}%
\let\tikz@dec@user@transform=\tikz@g@temptransform%
\tikz@dec@trans%
},%
/pgf/decoration/pre/.initial=lineto,
/pgf/decoration/post/.initial=lineto,
/pgf/decoration/pre length/.initial=0pt,
/pgf/decoration/post length/.initial=0pt,
}%
\let\tikz@decoration@name=\tikz@nonetext
\def\tikz@dec@trans{\pgfsetdecorationsegmenttransformation{\tikz@dec@user@transform\tikz@dec@mirror\tikz@dec@shift}}%
\let\tikz@dec@user@transform=\relax
\let\tikz@dec@shift=\relax
\let\tikz@dec@mirror=\relax
\pgfdeclaremetadecoration{tikz@internal}{pre}{%
\state{pre}[width=\pgfkeysvalueof{/pgf/decoration/pre length}, next state=main]
{
\tikz@dec@trans
\decoration{\pgfkeysvalueof{/pgf/decoration/pre}}
}%
\state{main}[width=\pgfmetadecoratedremainingdistance-\pgfkeysvalueof{/pgf/decoration/post length}, next state=final]
{
\tikz@dec@trans
\decoration{\tikz@decoration@name}
}%
\state{final}
{
\tikz@dec@trans
\decoration{\pgfkeysvalueof{/pgf/decoration/post}}
}%
}%
\newif\iftikz@metadecoration
\def\tikz@lib@dec@addtomacro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}%
\def\tikz@lib@decoration[#1]{%
\begingroup%
% Just to be on the save side...
%
% Now, let's parse the options:
\tikzset{#1}%
%
\ifx\tikz@decoration@name\tikz@nonetext%
% Ok, let's forget about this decoration stuff...
\else
\expandafter\tikz@lib@do@dec%
\fi%
% Now, we expect a brace.
\pgfutil@ifnextchar\bgroup{%
\begingroup%
\tikz@auto@end@pathfalse%
\aftergroup\tikz@enddecoration%
\afterassignment\tikz@scan@next@command%
\let\tikz@lib@next% gobble \bgroup%
}%
{%
\tikzerror{A decoration must begin with a brace}%
\tikz@enddecoration%
}%
}%
\def\tikz@lib@do@dec{%
% Ok, now what?
\pgfifmetadecoration{\tikz@decoration@name}%
{\expandafter\pgfmetadecoration\expandafter{\tikz@decoration@name}}%
{%
\pgfifdecoration{\tikz@decoration@name}%
{\tikz@lib@dec@startdecoration}%
{\tikzerror{Unknown (meta-)decoration '\tikz@decoration@name'. Perhaps you
misspelled it?}}%
}%
\ifx\pgfdecorateexistingpath\pgfutil@empty%
\pgfpathmoveto{\pgfqpoint{\the\tikz@lastxsaved}{\the\tikz@lastysaved}}%
\fi%
}%
\newbox\tikz@lib@dec@box
\def\tikz@enddecoration{%
\global\setbox\tikz@lib@dec@box=\box\tikz@tempbox%
\ifx\tikz@decoration@name\tikz@nonetext%
% ignore this.
\else
% Ok, now what?
\iftikz@metadecoration%
\endpgfmetadecoration%
\else%
\tikz@lib@dec@stopdecoration%
\fi%
\fi
\endgroup%
\setbox\tikz@tempbox=\box\tikz@lib@dec@box%
}%
\def\tikz@lib@dec@decorate@path{%
\ifx\tikz@decoration@name\tikz@nonetext%
\else%
\pgfgetpath\tikz@lib@dec@currentpath%
\pgfsetpath\pgfutil@empty%
\pgfifmetadecoration{\tikz@decoration@name}
{
\expandafter\pgfmetadecoration\expandafter{\tikz@decoration@name}%
\pgfsetpath\tikz@lib@dec@currentpath%
\endpgfmetadecoration%
}
{
\pgfifdecoration{\tikz@decoration@name}
{
\tikz@lib@dec@startdecoration%
\pgfsetpath\tikz@lib@dec@currentpath%
\tikz@lib@dec@stopdecoration%
}
{
\tikzerror{Unknown (meta-)decoration '\tikz@decoration@name'. Perhaps
you misspelled it?}
}
}
\fi%
}%
\def\tikz@lib@dec@zpttext{0pt}%
\newif\iftikz@lib@dec@temp
\def\tikz@lib@dec@startdecoration{%
\pgfkeysgetvalue{/pgf/decoration/pre length}{\tikz@lib@pre}%
\pgfkeysgetvalue{/pgf/decoration/post length}{\tikz@lib@post}%
\tikz@lib@dec@tempfalse%
\ifx\tikz@lib@pre\tikz@lib@dec@zpttext%
\ifx\tikz@lib@post\tikz@lib@dec@zpttext%
\else%
\tikz@lib@dec@temptrue%
\fi%
\else%
\tikz@lib@dec@temptrue%
\fi%
\iftikz@lib@dec@temp%
\pgfmetadecoration{tikz@internal}%
\else%
\expandafter\pgfdecoration\expandafter{\expandafter{\tikz@decoration@name}{\pgfdecoratedpathlength}{}{}}%
\fi%
}%
\def\tikz@lib@dec@stopdecoration{%
\iftikz@lib@dec@temp%
\endpgfmetadecoration%
\else%
\endpgfdecoration%
\fi%
}%
\endinput
|