Debian Codegraph @

texmf-dist/tex/generic/pgf/libraries/decorations/pgflibrarydecorations.pathreplacing.code.tex

raw
1 % Copyright 2018 by Mark Wibrow and Till Tantau
2 %
3 % This file may be distributed and/or modified
4 %
5 % 1. under the LaTeX Project Public License and/or
6 % 2. under the GNU Public License.
7 %
8 % See the file doc/generic/pgf/licenses/LICENSE for more details.
9
10 \usepgfmodule{decorations}%
11
12
13 %
14 % Path replacing decorations
15 %
16 % These decorations change the path by replacing it by another path.
17 % For instance, a line in the path might be replaced by small
18 % ticks or unconnected curves or crosses. Applying a chopping
19 % decoration to a path means that the path can no longer be used for
20 % filling in the original manner.
21 %
22
23
24
25 %
26 %
27 % Kind 1: Path chopping with open subpaths
28 %
29 %
30
31
32 % ticks decoration
33 %
34 % Parameters: \pgfdecorationsegmentlength, \pgfdecorationsegmentamplitude
35
36 \pgfdeclaredecoration{ticks}{ticks}
37 {%
38 \state{ticks}[width=+\pgfdecorationsegmentlength]
39 {
40 \pgfpathmoveto{\pgfqpoint{0pt}{\pgfdecorationsegmentamplitude}}
41 \pgfpathlineto{\pgfqpoint{0pt}{-\pgfdecorationsegmentamplitude}}
42 }%
43 \state{final}
44 {
45 \pgfpathmoveto{\pgfqpoint{0pt}{\pgfdecorationsegmentamplitude}}
46 \pgfpathlineto{\pgfqpoint{0pt}{-\pgfdecorationsegmentamplitude}}
47 \pgfpathmoveto{\pgfpointdecoratedpathlast}
48 }%
49 }%
50
51
52
53 % expanding waves decoration
54 %
55 % Parameters: \pgfdecorationsegmentangle, \pgfdecorationsegmentlength
56
57 \pgfdeclaredecoration{expanding waves}{initial}
58 {%
59 \state{initial}[width=+\pgfdecorationsegmentlength,next state=wave]
60 {}%
61
62 \state{wave}[switch if less than=+\pgfdecorationsegmentlength to last,
63 width=+\pgfdecorationsegmentlength]
64 {
65 \pgfpathmoveto{
66 \pgfpointadd
67 {\pgfqpoint{-\pgfdecoratedcompleteddistance}{0pt}}%
68 {\pgfpointpolar{\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}}}%
69 \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}%
70 }%
71 \state{last}[width=+0pt,next state=final]
72 {
73 \pgfpathmoveto{
74 \pgfpointadd
75 {\pgfqpoint{-\pgfdecoratedcompleteddistance}{0pt}}%
76 {\pgfpointpolar{\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}}}%
77 \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}%
78 }%
79 \state{final}
80 {
81 \pgfpathmoveto{\pgfpointdecoratedpathlast}
82 }%
83 }%
84
85
86
87 % waves decoration
88
89 \pgfdeclaredecoration{waves}{wave}
90 {%
91 \state{wave}[width=\pgfdecorationsegmentlength]
92 {
93 \pgftransformxshift{+\pgfdecorationsegmentlength}
94 \pgfpathmoveto{
95 \pgfpointadd
96 {\pgfqpoint{-\pgfkeysvalueof{/pgf/decoration/start radius}}{0pt}}%
97 {\pgfpointpolar{\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/start radius}}}}%
98 \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/start radius}}%
99 }%
100 \state{final}
101 {
102 \pgfpathmoveto{\pgfpointdecoratedpathlast}
103 }%
104 }%
105
106
107
108 % border decoration
109 %
110 % Parameters: \pgfdecorationsegmentlength, \pgfdecorationsegmentamplitude, \pgfdecorationsegmentangle
111
112 \pgfdeclaredecoration{border}{tick}
113 {%
114 \state{tick}[switch if less than=+\pgfdecorationsegmentlength to last,
115 width=+\pgfdecorationsegmentlength]
116 {
117 \pgfpathmoveto{\pgfpointorigin}
118 \pgfpathlineto{\pgfpointpolar{\pgfdecorationsegmentangle}{+\pgfdecorationsegmentamplitude}}
119 }%
120 \state{last}[width=+\pgfdecorationsegmentamplitude,next state=final]
121 {
122 \pgfpathmoveto{\pgfpointorigin}
123 \pgfpathlineto{\pgfpointpolar{\pgfdecorationsegmentangle}{+\pgfdecorationsegmentamplitude}}
124 }%
125 \state{final}
126 {
127 \pgfpathmoveto{\pgfpointdecoratedpathlast}
128 }%
129 }%
130
131
132
133
134
135
136 % brace decorations
137 %
138 % Parameters: \pgfdecorationsegmentamplitude
139
140 \pgfdeclaredecoration{brace}{brace}
141 {%
142 \state{brace}[width=+\pgfdecoratedremainingdistance,next state=final]
143 {
144 \pgf@yc=\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance
145 \ifdim2\pgfdecorationsegmentamplitude>\pgf@yc
146 \pgf@yc=0.5\pgf@yc
147 \else
148 \pgf@yc=\pgfdecorationsegmentamplitude
149 \fi
150 \pgf@xc=\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance
151 \advance\pgf@xc-\pgfdecoratedremainingdistance
152 \ifdim-2\pgfdecorationsegmentamplitude<\pgf@xc
153 \pgf@xc=-0.5\pgf@xc
154 \else
155 \pgf@xc=\pgfdecorationsegmentamplitude
156 \fi
157 \pgfpathmoveto{\pgfpointorigin}
158 \pgfpathcurveto
159 {\pgfqpoint{.15\pgf@yc}{.3\pgfdecorationsegmentamplitude}}
160 {\pgfqpoint{.5\pgf@yc}{.5\pgfdecorationsegmentamplitude}}
161 {\pgfqpoint{\pgf@yc}{.5\pgfdecorationsegmentamplitude}}
162 {
163 \pgftransformxshift{+\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance}
164 \pgfpathlineto{\pgfqpoint{-\pgf@yc}{.5\pgfdecorationsegmentamplitude}}
165 \pgfpathcurveto
166 {\pgfqpoint{-.5\pgf@yc}{.5\pgfdecorationsegmentamplitude}}
167 {\pgfqpoint{-.15\pgf@yc}{.7\pgfdecorationsegmentamplitude}}
168 {\pgfqpoint{0\pgf@yc}{1\pgfdecorationsegmentamplitude}}
169 \pgfpathcurveto
170 {\pgfqpoint{.15\pgf@xc}{.7\pgfdecorationsegmentamplitude}}
171 {\pgfqpoint{.5\pgf@xc}{.5\pgfdecorationsegmentamplitude}}
172 {\pgfqpoint{\pgf@xc}{.5\pgfdecorationsegmentamplitude}}
173 }
174 {
175 \pgftransformxshift{+\pgfdecoratedremainingdistance}
176 \pgfpathlineto{\pgfqpoint{-\pgf@xc}{.5\pgfdecorationsegmentamplitude}}
177 \pgfpathcurveto
178 {\pgfqpoint{-.5\pgf@xc}{.5\pgfdecorationsegmentamplitude}}
179 {\pgfqpoint{-.15\pgf@xc}{.3\pgfdecorationsegmentamplitude}}
180 {\pgfqpoint{0pt}{0pt}}
181 }
182 }%
183 \state{final}
184 {}%
185 }%
186
187
188
189
190 % show path construction decoration
191 %
192 \pgfdeclaredecoration{show path construction}{check for moveto}{%
193 \state{check for moveto}[width=0pt, next state=segment,
194 persistent precomputation={%
195 \begingroup%
196 \pgf@lib@decoraions@installinputsegmentpoints%
197 \ifx\pgfdecorationpreviousinputsegment\pgfdecorationinputsegmentmoveto%
198 \pgfdecoratedinputsegmentmovetocode%
199 \fi%
200 \endgroup%
201 }]{}%
202 \state{segment}[width=\pgfdecoratedinputsegmentremainingdistance, next state=check for moveto,
203 persistent precomputation={%
204 \begingroup%
205 \pgf@lib@decoraions@installinputsegmentpoints%
206 \csname pgfdecoratedinputsegment\pgfdecorationcurrentinputsegment code\endcsname%
207 \endgroup%
208 }]{}%
209 \state{final}{%
210 \egroup%
211 \begingroup%
212 \pgf@lib@decoraions@installinputsegmentpoints%
213 \csname pgfdecoratedinputsegment\pgfdecorationcurrentinputsegment code\endcsname%
214 \endgroup%
215 \bgroup%
216 }%
217 }%
218
219 \pgfkeys{
220 /pgf/decoration/.cd,
221 moveto code/.code=\def\pgfdecoratedinputsegmentmovetocode{#1},
222 lineto code/.code=\def\pgfdecoratedinputsegmentlinetocode{#1},
223 curveto code/.code=\def\pgfdecoratedinputsegmentcurvetocode{#1},
224 closepath code/.code=\def\pgfdecoratedinputsegmentclosepathcode{#1}
225 }%
226
227 \let\pgfdecoratedinputsegmentmovetocode\pgfutil@empty%
228 \let\pgfdecoratedinputsegmentlinetocode\pgfutil@empty%
229 \let\pgfdecoratedinputsegmentcurvetocode\pgfutil@empty%
230 \let\pgfdecoratedinputsegmentclosepathcode\pgfutil@empty%
231
232 \def\pgf@lib@decoraions@installinputsegmentpoints{%
233 \let\pgfpointdecoratedinputsegmentfirst\pgf@decorate@inputsegment@first%
234 \let\pgfpointdecoratedinputsegmentlast\pgf@decorate@inputsegment@last%
235 \let\pgfpointdecoratedinputsegmentsupporta\pgf@decorate@inputsegment@supporta%
236 \let\pgfpointdecoratedinputsegmentsupportb\pgf@decorate@inputsegment@supportb%
237 }%
238
239
240 \endinput