Debian Codegraph @

doc/etc/tikzlibraryshadows.blur.code.tex

raw
1 %%
2 %% This is file `tikzlibraryshadows.blur.code.tex',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% pgf-blur.dtx (with options: `texfile')
8 %% Copyright 2012 Martin Giese, [email protected]
9 %%
10 %% This file is under the LaTeX Project Public License
11 %% See CTAN archives in directory macros/latex/base/lppl.txt.
12 %%
13 %% DESCRIPTION:
14 %% `pgf-blur' adds blurred/faded/fuzzy shadows to TikZ/PGF
15 %%
16
17
18 \def\fileversion{1.01}
19 \def\filedate{2012/04/24}
20 \message{ v\fileversion, \filedate}
21 \usetikzlibrary{shadows}
22 \usetikzlibrary{calc}
23 \newif\ifpgfbs@invert@fading
24 \newcount\pgfbs@fading@count
25 \pgfbs@fading@count=0\relax
26 \tikzset{
27 /tikz/shadow blur radius/.store in=\pgfbs@radius,
28 /tikz/shadow blur radius=.4ex,
29 /tikz/shadow blur extra rounding/.store in=\pgfbs@extra@rounding,
30 /tikz/shadow blur extra rounding=\pgfutil@empty,
31 /tikz/shadow blur extra rounding/.default=\pgfbs@radius,
32 /tikz/shadow blur steps/.store in=\pgfbs@steps,
33 /tikz/shadow blur steps=4,
34 /tikz/shadow blur invert/.is if=pgfbs@invert@fading,
35 /tikz/shadow opacity/.store in=\pgfbs@opacity,
36 /tikz/shadow opacity=40,
37 /tikz/blur shadow/.style={
38 shadow scale=1,
39 shadow xshift=.5ex,
40 shadow yshift=-.5ex,
41 preaction=render blur shadow,
42 every shadow,
43 #1,
44 },
45 /tikz/render blur shadow/.code={
46 \pgfbs@savebb
47 \global\advance\pgfbs@fading@count by 1\relax
48 \pgfsyssoftpath@getcurrentpath{\pgfbs@input@path}%
49 \pgfbs@compute@shadow@bbox
50 \pgfbs@process@rounding{\pgfbs@input@path}{\pgfbs@fadepath}%
51 \pgfbs@apply@canvas@transform
52 \colorlet{pstb@shadow@color}{white!\pgfbs@opacity!black}%
53 \ifpgfbs@invert@fading
54 \pgfdeclarefading{shadowfading-\the\pgfbs@fading@count}{\pgfbs@paint@invert@fading}%
55 \else
56 \pgfdeclarefading{shadowfading-\the\pgfbs@fading@count}{\pgfbs@paint@fading}%
57 \fi
58 \pgfsetfillcolor{black}%
59 \pgfsetfading{shadowfading-\the\pgfbs@fading@count}%
60 {\pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}}%
61 \pgfbs@usebbox{fill}%
62 \pgfbs@restorebb
63 },
64 }
65 \def\pgfbs@savebb{%
66 \edef\pgfbs@restorebb{%
67 \global\pgf@picminx=\the\pgf@picminx\relax
68 \global\pgf@picmaxx=\the\pgf@picmaxx\relax
69 \global\pgf@picminy=\the\pgf@picminy\relax
70 \global\pgf@picmaxy=\the\pgf@picmaxy\relax
71 }%
72 }
73 \def\restorebb{}%
74 \def\pgfbs@process@rounding#1#2{
75 \expandafter\ifx\pgfbs@extra@rounding\pgfutil@empty%
76 \pgfprocessround{#1}{#2}%
77 \else%
78 \pgfmathsetmacro\pgfbs@exrd@val{\pgfbs@extra@rounding}%
79 \pgfbs@roundpath{#1}{\pgfbs@exrd@val pt}%
80 \pgfsyssoftpath@getcurrentpath{\pgfbs@extraroundedpath}%
81 \pgfprocessround{\pgfbs@extraroundedpath}{#2}%
82 \fi%
83 }
84 \def\pgfbs@roundpath#1#2{%
85 {%
86 \def\pgfbs@rp@skipround{%
87 \let\pgfbs@rp@possibleround\pgfbs@rp@insertround}%
88 \def\pgfbs@rp@insertround{\pgfsyssoftpath@specialround{#2}{#2}}%
89 \let\pgfbs@rp@possibleround\pgfbs@rp@insertround%
90 %
91 \def\pgfsyssoftpath@movetotoken##1##2{%
92 \pgfsyssoftpath@moveto{##1}{##2}}%
93 \def\pgfsyssoftpath@linetotoken##1##2{%
94 \pgfbs@rp@possibleround\pgfsyssoftpath@lineto{##1}{##2}}%
95 \def\pgfsyssoftpath@rectcornertoken##1##2##3##4##5{%
96 \pgf@xa=##1\relax%
97 \advance\pgf@xa by##4%
98 \pgf@ya=##2\relax%
99 \advance\pgf@ya by##5%
100 \pgfsyssoftpath@moveto{##1}{##2}%
101 \pgfbs@rp@possibleround%
102 \pgfsyssoftpath@lineto{\the\pgf@xa}{##2}%
103 \pgfbs@rp@possibleround%
104 \pgfsyssoftpath@lineto{\the\pgf@xa}{\the\pgf@ya}%
105 \pgfbs@rp@possibleround%
106 \pgfsyssoftpath@lineto{##1}{\the\pgf@ya}%
107 \pgfbs@rp@possibleround%
108 \pgfsyssoftpath@closepath}%
109 \def\pgfsyssoftpath@curvetosupportatoken%
110 ##1##2##3##4##5##6##7##8{%
111 \pgfbs@rp@possibleround%
112 \pgfsyssoftpath@curveto{##1}{##2}{##4}{##5}{##7}{##8}}%
113 \def\pgfsyssoftpath@closepathtoken##1##2{%
114 \pgfbs@rp@possibleround\pgfsyssoftpath@closepath}%
115 \def\pgfsyssoftpath@specialroundtoken##1##2{%
116 \pgfmathsetmacro\pgfbs@rp@ra{max(##1,#2)}%
117 \pgfmathsetmacro\pgfbs@rp@rb{max(##2,#2)}%
118 \pgfsyssoftpath@specialround%
119 {\pgfbs@rp@ra pt}{\pgfbs@rp@rb pt}%
120 \let\pgfbs@rp@possibleround\pgfbs@rp@skipround%
121 }
122 #1%
123 }
124 }
125 \def\pgfbs@compute@shadow@bbox{%
126 \edef\pgfbs@minx{\the\pgf@pathminx}%
127 \edef\pgfbs@miny{\the\pgf@pathminy}%
128 \edef\pgfbs@maxx{\the\pgf@pathmaxx}%
129 \edef\pgfbs@maxy{\the\pgf@pathmaxy}%
130 \pgfmathsetmacro\pgfbs@midx{0.5*(\pgfbs@minx + \pgfbs@maxx)}%
131 \pgfmathsetmacro\pgfbs@midy{0.5*(\pgfbs@miny + \pgfbs@maxy)}%
132 \pgfmathsetmacro\pgfbs@minx{\pgfbs@minx - 2*\pgfbs@radius}%
133 \pgfmathsetmacro\pgfbs@miny{\pgfbs@miny - 2*\pgfbs@radius}%
134 \pgfmathsetmacro\pgfbs@maxx{\pgfbs@maxx + 2*\pgfbs@radius}%
135 \pgfmathsetmacro\pgfbs@maxy{\pgfbs@maxy + 2*\pgfbs@radius}%
136 \pgfmathsetmacro\pgfbs@wd{\pgfbs@maxx - \pgfbs@minx}%
137 \pgfmathsetmacro\pgfbs@ht{\pgfbs@maxy - \pgfbs@miny}%
138 \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
139 \pgfsyssoftpath@rect{\pgfbs@minx pt}{\pgfbs@miny pt}%
140 {\pgfbs@wd pt}{\pgfbs@ht pt}%
141 \pgfsyssoftpath@getcurrentpath{\pgfbs@shadow@bbox}%
142 \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
143 }
144
145 \def\pgfbs@set@fading@pic@bbox{
146 \global\pgf@picminx=\pgfbs@minx pt\relax
147 \global\pgf@picminy=\pgfbs@miny pt\relax
148 \global\pgf@picmaxx=\pgfbs@maxx pt\relax
149 \global\pgf@picmaxy=\pgfbs@maxy pt\relax
150 }
151 \def\pgfbs@usefadepath#1{%
152 \pgfsyssoftpath@setcurrentpath{\pgfbs@fadepath}%
153 \pgfsyssoftpath@flushcurrentpath%
154 \pgfusepath{#1}%
155 }
156 \def\pgfbs@usebbox#1{%
157 \pgfsyssoftpath@setcurrentpath{\pgfbs@shadow@bbox}%
158 \pgfsyssoftpath@flushcurrentpath%
159 \pgfusepath{#1}%
160 }
161 \def\pgfbs@usefadeandbbox#1{%
162 \let\pgfbs@temppath\pgfbs@fadepath
163 \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgfbs@temppath\expandafter\expandafter\expandafter{\expandafter\pgfbs@temppath\pgfbs@shadow@bbox}%
164 \pgfsyssoftpath@setcurrentpath{\pgfbs@temppath}%
165 \pgfsyssoftpath@flushcurrentpath%
166 \pgfusepath{#1}%
167 }
168 \def\pgfbs@apply@canvas@transform{
169 \pgflowlevel{
170 \pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}
171 \pgftransformscale{\pgfkeysvalueof{/tikz/shadow scale}}
172 \pgftransformshift{\pgfpoint%
173 {\pgfkeysvalueof{/tikz/shadow xshift}-\pgfbs@midx}
174 {\pgfkeysvalueof{/tikz/shadow yshift}-\pgfbs@midy}
175 }
176 }
177 }
178 \def\pgfbs@paint@fading{
179 \pgfpicture
180 \pgfsetbaseline{\pgf@picminy}%
181 % fix bounding box.
182 \pgfbs@set@fading@pic@bbox
183 % compute increments for line width and opacity
184 \pgfmathsetmacro\pgfbs@op@step{50/\pgfbs@steps}
185 \pgfmathsetmacro\pgfbs@wth@step{4*\pgfbs@radius/(2*\pgfbs@steps-1)}
186 % draw the outer part of the fading,
187 % starting with lightest, outermost line
188 \pgfsetroundjoin
189 \pgfmathsetmacro\pgfbs@max@i{\pgfbs@steps-2}
190 \pgfmathsetmacro\pgfbs@wth{2*\pgfbs@radius}
191 \pgfmathsetmacro\pgfbs@op{100-0.5*\pgfbs@op@step}
192 \foreach \pgfbs@i in {0,...,\pgfbs@max@i} {
193 \pgfsetlinewidth{\pgfbs@wth pt}
194 \pgfsetstrokecolor{black!\pgfbs@op!pstb@shadow@color}
195 \pgfbs@usefadepath{stroke}
196 \pgfmathsetmacro\pgfbs@wth{\pgfbs@wth-\pgfbs@wth@step}
197 \global\let\pgfbs@wth=\pgfbs@wth
198 \pgfmathsetmacro\pgfbs@op{\pgfbs@op-\pgfbs@op@step}
199 \global\let\pgfbs@op=\pgfbs@op
200 }
201 % clip to inside of path
202 \scope
203 \pgfbs@usefadepath{clip}
204 % fill inside with final darkest shadow color
205 \pgfsetfillcolor{pstb@shadow@color}
206 \pgfbs@usebbox{fill}
207 % draw the inner part of the fading,
208 % starting with the darkest, innermost line
209 \pgfmathsetmacro\pgfbs@wth{2*\pgfbs@radius}
210 \pgfmathsetmacro\pgfbs@op{0.5*\pgfbs@op@step}
211 \foreach \pgfbs@i in {0,...,\pgfbs@max@i} {
212 \pgfsetlinewidth{\pgfbs@wth pt}
213 \pgfsetstrokecolor{black!\pgfbs@op!pstb@shadow@color}
214 \pgfbs@usefadepath{stroke}
215 \pgfmathsetmacro\pgfbs@wth{\pgfbs@wth-\pgfbs@wth@step}
216 \global\let\pgfbs@wth=\pgfbs@wth
217 \pgfmathsetmacro\pgfbs@op{\pgfbs@op+\pgfbs@op@step}
218 \global\let\pgfbs@op=\pgfbs@op
219 }
220 \endscope
221 % a final stroke to hide clip/antialiasing artifcats
222 \pgfsetstrokecolor{black!50!pstb@shadow@color}
223 \pgfsetlinewidth{0.5*\pgfbs@wth@step}
224 \pgfbs@usefadepath{stroke}
225 \endpgfpicture
226 }
227 \def\pgfbs@paint@invert@fading{
228 \pgfpicture
229 \pgfsetbaseline{\pgf@picminy}%
230 % fix bounding box.
231 \pgfbs@set@fading@pic@bbox
232 % compute increments for line width and opacity
233 \pgfmathsetmacro\pgfbs@op@step{50/\pgfbs@steps}
234 \pgfmathsetmacro\pgfbs@wth@step{4*\pgfbs@radius/(2*\pgfbs@steps-1)}
235 % draw the outer part of the fading,
236 % starting with lightest, outermost line
237 \pgfsetroundjoin
238 \pgfmathsetmacro\pgfbs@max@i{\pgfbs@steps-2}
239 \pgfmathsetmacro\pgfbs@wth{2*\pgfbs@radius}
240 \pgfmathsetmacro\pgfbs@op{0.5*\pgfbs@op@step}
241 \foreach \pgfbs@i in {0,...,\pgfbs@max@i} {
242 \pgfsetlinewidth{\pgfbs@wth pt}
243 \pgfsetstrokecolor{black!\pgfbs@op!pstb@shadow@color}
244 \pgfbs@usefadepath{stroke}
245 \pgfmathsetmacro\pgfbs@wth{\pgfbs@wth-\pgfbs@wth@step}
246 \global\let\pgfbs@wth=\pgfbs@wth
247 \pgfmathsetmacro\pgfbs@op{\pgfbs@op+\pgfbs@op@step}
248 \global\let\pgfbs@op=\pgfbs@op
249 }
250 % clip to inside of path
251 \scope
252 \pgfseteorule
253 \pgfbs@usefadeandbbox{clip}
254 % fill inside with final darkest shadow color
255 \pgfsetfillcolor{pstb@shadow@color}
256 \pgfbs@usebbox{fill}
257 \endscope
258 \scope
259 \pgfbs@usefadepath{clip}
260 % draw the inner part of the fading,
261 % starting with the darkest, innermost line
262 \pgfmathsetmacro\pgfbs@wth{2*\pgfbs@radius}
263 \pgfmathsetmacro\pgfbs@op{100-0.5*\pgfbs@op@step}
264 \foreach \pgfbs@i in {0,...,\pgfbs@max@i} {
265 \pgfsetlinewidth{\pgfbs@wth pt}
266 \pgfsetstrokecolor{black!\pgfbs@op!pstb@shadow@color}
267 \pgfbs@usefadepath{stroke}
268 \pgfmathsetmacro\pgfbs@wth{\pgfbs@wth-\pgfbs@wth@step}
269 \global\let\pgfbs@wth=\pgfbs@wth
270 \pgfmathsetmacro\pgfbs@op{\pgfbs@op-\pgfbs@op@step}
271 \global\let\pgfbs@op=\pgfbs@op
272 }
273 \endscope
274 % a final stroke to hide clip/antialiasing artifcats
275 \pgfsetstrokecolor{black!50!pstb@shadow@color}
276 \pgfsetlinewidth{0.5*\pgfbs@wth@step}
277 \pgfbs@usefadepath{stroke}
278 \endpgfpicture
279 }
280 \endinput
281 %%
282 %% End of file `tikzlibraryshadows.blur.code.tex'.