~tex-sx/tex-sx/development

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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
% \iffalse meta-comment -*-mode:Latex;tex-command:"latex *;dvips -D600 pst-blur -o"-*-
%<*internal>
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
Copyright 2012 Martin Giese, martingi@ifi.uio.no

This file is under the LaTeX Project Public License 
See CTAN archives in directory macros/latex/base/lppl.txt.

DESCRIPTION:
  `pgf-blur' adds blurred/faded/fuzzy shadows to TikZ/PGF

\endpreamble
\generate{\file{tikzlibraryshadows.blur.code.tex}{\from{pgf-blur.dtx}{texfile}}}
\Msg{************************************************************}
\Msg{ }
\Msg{  To finish the installation you have to move the file}
\Msg{  `tikzlibraryshadows.blur.code.tex' into a directory}
\Msg{  searched by TeX.}
\Msg{ }
\Msg{  To type-set the documentation, including instructions,}
\Msg{  run the file `pgf-blur.dtx' through LaTeX.}
\Msg{ }
\Msg{***********************************************************}
%</install>
%<install>\endbatchfile
%<*internal>
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\documentclass{ltxdoc}
\usepackage{tikz}
\usepackage{textcomp}
\usepackage{url}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\AtBeginDocument{
%  \OnlyDescription % comment out for implementation details
  \EnableCrossrefs
  \RecordChanges
  \CodelineIndex}
\AtEndDocument{
  \PrintChanges
  \PrintIndex}
\MakeShortVerb{\|}
\newcommand\file[1]{\texttt{#1}}
\begin{document}
\DocInput{pgf-blur.dtx}
\end{document}
%</driver>
%\fi
%
% \CheckSum{310}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v1.00}{2012/05/06}{First public release. (mg)}
%
% \DoNotIndex{\!,\",\#,\$,\%,\&,\',\(,\+,\*,\,,\-,\.,\/,\:,\;,\<,\=,\>,\?}
% \setcounter{IndexColumns}{2}
%
% \title{\textsf{pgf-blur} package \\ version \fileversion}
% \author{Martin Giese\thanks{\protect\url{martingi@ifi.uio.no}}}
% \date{\filedate}
% \maketitle
%
%\def\tikzname{Ti\emph{k}Z}
%
%
%\begin{center}
%  \small \textbf{Acknowledgement}\\ This package evolved from a discussion
%  on \url{http://tex.stackexchange.com/}.  In particular, the author received 
%  invaluable help from Andrew Stacey.
%\end{center}
%
%\section{Introduction}
% The ability to paint shadows on arbitrary shapes is a standard 
% feature of TikZ/PGF.  However, these shadows are usually `sharp':
%
%\newcommand\examplepath{
%  (0,0) -- (0,1) -- (1.5,1) -- (1,0.5) [rounded corners=2mm] -- (1,0) [sharp corners]-- cycle
%  (0.5,0.5) circle (0.3)
%  }
%
%\begin{center}
% \begin{tikzpicture}
%   \filldraw[drop shadow,draw=black,fill=white] \examplepath ;
%    \node[starburst,very thick,rounded corners=2pt,fill=white,draw=red,
%          drop shadow] at (5,0.5) 
%         {\sffamily\bfseries SPLAT!};
% \end{tikzpicture}
%\end{center}
%
% Such shadows are often optically too intrusive.  A more pleasing effect
% is achieved if the edges of the shadow are `blurred,' i.e., getting
% gradually lighter and more transparent toward the outside.
% This effect can be achieved in TikZ/PGF with the |circular drop shadow|
% key, but that works only with ellipses and circles.
%
% The |pgf-blur| package provides blurred shadows that can be
% added to any closed path, including node borders:
%
%\begin{center}
% \begin{tikzpicture}
%   \filldraw[blur shadow={shadow blur steps=8,shadow blur extra rounding},draw=black,fill=white] \examplepath ;
%    \node[starburst,very thick,rounded corners=2pt,fill=white,draw=red,
%         blur shadow={shadow blur steps=8,shadow blur extra rounding}] at (5,0.5) 
%         {\sffamily\bfseries SPLAT!};
% \end{tikzpicture}
%\end{center}
%
% \medskip
%
% The new TikZ options provided by the package
% are described in section 2 of this document.  Section 3, if present, documents the 
% implementation consisting of a generic \TeX\ file.  
%
%\section{Package Usage}
%
% To use the package, the document needs to say |\usepackage{tikz}| and
% \begin{verbatim}
%  \usetikzlibrary{shadows.blur}
% \end{verbatim}
% in the preamble.
%
% \DescribeMacro{blur shadow}
% \noindent A blurred shadow is added to a path or node by adding the option
% |blur shadow|, e.g.
%\begin{verbatim}
%  \begin{tikzpicture}
%    \filldraw[fill=white, draw=black, blur shadow] (0,0) circle (1);
%    \node[fill=white, draw=black, blur shadow] at (4,0.5) {\Large Node};
%  \end{tikzpicture}
%\end{verbatim}
% which gives
%\begin{center}
%  \begin{tikzpicture}
%    \filldraw[fill=white, draw=black, blur shadow] (0,0) circle (0.5);
%    \node[fill=white, draw=black, blur shadow] at (2,0) {\Large Node};
%  \end{tikzpicture}
%\end{center}
% Note that this usually makes sense only with closed paths that are filled
% (otherwise the shadow is visible through the path, and one wonders 
% what is throwing the shadow) and often looks best if used with 
% a drawn outline.
% 
% The appearance of the shadow can be fine-tuned by giving arguments
% to the |blur shadow| options.  These options do not have any effect
% if given outside of the argument of either |blur shadow| or |every shadow| 
% (described later)
%
% \DescribeMacro{shadow xshift}
% \DescribeMacro{shadow yshift}
% \DescribeMacro{shadow scale}
% \noindent The shadow is based on a shifted, and possibly scaled copy of the original path.
% These options are described in the \tikzname/PGF user manual, and they work in
% the same way for blurred shadows.  See also Fig.~\ref{fig:geometry}.  The default 
% values are 3ex for |shadow xshift|, \textminus3ex for |shadow yshift|, and
% 1 for |shadow scale|.
%
%\begin{figure}
%\begin{center}
%  \begin{tikzpicture}
%\begin{scope}
%  \clip (0,1) rectangle (8,5);
%
%  \filldraw[fill=white, draw=black, ultra thick,
%           blur shadow={
%           shadow xshift=2cm,shadow yshift=-1cm,
%           shadow blur radius=0.75cm, shadow blur steps=10}] (-4,3) rectangle (4,9);
%  \draw[xshift=2cm,yshift=-1cm,thin,dotted,red] 
%      (4,3) circle (0.75)
%      (-4,3) rectangle (4,9)
%      (-4.75,3.75) rectangle (3.25,9.75)
%      [rounded corners=0.75cm] (-3.25,2.25) rectangle (4.75,8.25);
%\end{scope}
%      
%  \draw[-stealth, thin] (4,3) -- (6,2)
%        node[pos=0.6,left=0.7em] {\footnotesize (|shadow xshift|,\,|shadow yshift|)};
%
%  \draw[stealth-stealth, thin] (6,2) -- + (-60:0.75)
%        node[pos=0.4,right=0.4em] {\footnotesize |shadow blur radius|};
%  \end{tikzpicture}
%\end{center}
%  \caption{Shadow geometry}
%  \label{fig:geometry}
%\end{figure}
%
% Here is an example for the usage of these options:
%\begin{verbatim}
%  \begin{tikzpicture}
%     \filldraw[fill=white, draw=black,
%               blur shadow={shadow xshift=1ex,
%                            shadow yshift=1ex,
%                            shadow scale=1.2}] 
%        (0,0) circle (0.5);
%  \end{tikzpicture}
%\end{verbatim}
% Which gives:
%\begin{center}
%  \begin{tikzpicture}
%     \filldraw[fill=white, draw=black,
%               blur shadow={shadow xshift=1ex,
%                            shadow yshift=1ex,
%                            shadow scale=1.2}] 
%        (0,0) circle (0.5);
%  \end{tikzpicture}
%\end{center}
%
% \DescribeMacro{shadow blur radius}
% \noindent Fig.~\ref{fig:geometry} shows how the blur shadow spreads out 
% the boundary of the path over a circular region.  The intent is
% to mimic the effect of a circular light source over the shape. 
% the radius of the ``blurring'' can be set with the 
% |shadow blur radius| option, which has a default value of 0.4ex.
%
% Here is an example of a drastically enlarged blur radius:
%\begin{verbatim}
%  \begin{tikzpicture}
%     \filldraw[fill=white, draw=black,
%               blur shadow={shadow blur radius=1.5ex}]
%        (0,0) circle (0.5);
%  \end{tikzpicture}
%\end{verbatim}
% Which gives:
%\begin{center}
%  \begin{tikzpicture}
%     \filldraw[fill=white, draw=black,
%               blur shadow={shadow blur radius=1.5ex}]
%        (0,0) circle (0.5);
%  \end{tikzpicture}
%\end{center}
%
% \DescribeMacro{shadow opacity}
% \noindent Shadows are transparent.  They are always black since a shadow is the
% absence of light.  The opacity of the interior of the shadow, i.e.~the
% darkest region can be controlled with the |shadow opacity| option.  It
% is given as a percentage, i.e.~a number between 0 and 100.  The default
% is 40.
%
% Here are examples of lighter and darker shadows:
%\begin{verbatim}
%  \begin{tikzpicture}
%     \draw[help lines,step=0.5] (-1,-1) grid (3,1);
%     \filldraw[fill=white, draw=black,
%               blur shadow={shadow opacity=20}]
%        (0,0) circle (0.5);
%     \filldraw[fill=white, draw=black,
%               blur shadow={shadow opacity=60}]
%        (2,0) circle (0.5);
%  \end{tikzpicture}
%\end{verbatim}
% Which gives:
%\begin{center}
%  \begin{tikzpicture}
%     \draw[help lines,step=0.5] (-1,-1) grid (3,1);
%     \filldraw[fill=white, draw=black,
%               blur shadow={shadow opacity=20}]
%        (0,0) circle (0.5);
%     \filldraw[fill=white, draw=black,
%               blur shadow={shadow opacity=60}]
%        (2,0) circle (0.5);
%  \end{tikzpicture}
%\end{center}
%
% \DescribeMacro{shadow blur steps}
% \noindent Looking closely at the shadows,
% one sees that the transition of opacity is actually not smooth, but
% proceeds in a finite number of discrete steps.  Specifically, there is 
% a number $n$, such that the (shifted and scaled) original path fades 
% outward to  complete transparency in $n$ steps and within the selected 
% |shadow blur radius|, and inward to the maximum opacity of the shadow 
% within also within $n$ steps and the |shadow blur radius|.  This number
% of steps $n$ can be selected using the |shadow blur steps| option.
% It defaults to 3, which is enough e.g.~for inconspicuous shadows in 
% presentations that nobody examines with a magnifying glass.
% The examples in the Introduction use 8, under the assumption that readers
% will have a close look.  Fig.~\ref{fig:geometry} uses 10 because the
% blur radius is so large.
%
% A large number of steps will slow down both the \TeX\ processing and the 
% PDF rendering, usually with very little visible impact.
%
% \StopEventually{}
%
% \section{Implementation}
%
% We start by storing the file version and data, and making sure |@| is a letter,
% but saving its previous catcode.
%    \begin{macrocode}
%<*texfile>
\def\fileversion{1.0}
\def\filedate{2012/05/06}
\message{ v\fileversion, \filedate}
\edef\TheAtCode{\the\catcode`\@}
%    \end{macrocode}
% We import the original shadow code for the offset and scale parameters.
%    \begin{macrocode}
\usetikzlibrary{shadows}
\usetikzlibrary{calc}
%    \end{macrocode}
% Next we define the various \tikzname\ options, with their default values.
% The options |shadow xshift|, |shadow yshift|, |shadow scale| are imported
% from the standard \tikzname\ shadow library, so we don't need to do
% anything for them.
% Note how the default value of |shadow blur extra rounding| is by default
% set to the blur radius.  This works because the value of this key is 
% evaluated before it is used.  All other options just store values
% in a couple of macros.
%    \begin{macrocode}
\tikzset{
  /tikz/shadow blur radius/.store in=\pgfbs@radius,
  /tikz/shadow blur radius=.4ex,
  /tikz/shadow blur extra rounding/.store in=\pgfbs@extra@rounding,
  /tikz/shadow blur extra rounding=\pgfutil@empty,
  /tikz/shadow blur extra rounding/.default=\pgfbs@radius,
  /tikz/shadow blur steps/.store in=\pgfbs@steps,
  /tikz/shadow blur steps=3,
  /tikz/shadow opacity/.store in=\pgfbs@opacity,
  /tikz/shadow opacity=40,
%    \end{macrocode}
% The user level option |blur shadow| sets the 
% |shadow xshift|, |shadow yshift|, |shadow scale| options to
% more useful defaults than the ones inherited from the shadows library.
% It includes any options set in the |every shadow| style, and the
% argument to |blur shadow|.  Rendering the shadow is declared as a
% |.preaction| on the path.  \tikzname\ will take care of saving the
% path for us.
%    \begin{macrocode}
  /tikz/blur shadow/.style={
    shadow scale=1,
    shadow xshift=.5ex,
    shadow yshift=-.5ex,
    preaction=render blur shadow,
    every shadow,
    #1,
  },
%    \end{macrocode}
% The following does the actual shadow rendering.  After some preliminary
% computation of dimensions, shifting and scaling is done using a
% canvas transform.  The actual blurring effect is done using a special fading.
% The shadow is painted by filling a large black rectangle using the 
% constructed fading.
%    \begin{macrocode}
  /tikz/render blur shadow/.code={
    \pgfbs@savebb
    \pgfsyssoftpath@getcurrentpath{\pgfbs@input@path}%
    \pgfbs@compute@shadow@bbox
    \pgfbs@apply@extra@rounding{\pgfbs@input@path}{\pgfbs@fadepath}%
    \pgfbs@apply@canvas@transform
    \colorlet{pstb@shadow@color}{white!\pgfbs@opacity!black}%
    \pgfdeclarefading{shadowfading}{\pgfbs@paint@fading}%
    \pgfsetfillcolor{black}%
    \pgfsetfading{shadowfading}%
       {\pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}}%
    \pgfbs@usebbox{fill}%
    \pgfbs@restorebb
  },
}
%    \end{macrocode}
%    \begin{macrocode}
\def\pgfbs@savebb{%
  \edef\pgfbs@restorebb{%
    \global\pgf@picminx=\the\pgf@picminx\relax
    \global\pgf@picmaxx=\the\pgf@picmaxx\relax
    \global\pgf@picminy=\the\pgf@picminy\relax
    \global\pgf@picmaxy=\the\pgf@picmaxy\relax
  }%
}
\def\restorebb{}%
%    \end{macrocode}
%    \begin{macrocode}
\def\pgfbs@apply@extra@rounding#1#2{
  \expandafter\ifx\pgfbs@extra@rounding\pgfutil@empty%
    \pgfprocessround{#1}{#2}%
  \else%
    \pgfmathsetmacro\pgfbs@exrd@val{\pgfbs@extra@rounding}%
    \pgfbs@roundpath{#1}{\pgfbs@exrd@val pt}%
    \pgfsyssoftpath@getcurrentpath{\pgfbs@extraroundedpath}%
    \pgfprocessround{\pgfbs@extraroundedpath}{#2}%
  \fi%
}
%    \end{macrocode}
% \begin{macro}{\pgfbs@roundpath}
% |\pgfbs@roundpath{#1}{#2}| rounds every potential corner in path |#1| 
% with an inset of at least |#2|.  I.e.~any potential corners are rounded.
% Corners that are already rounded in |#1| are either left intact if
% their insets are $\geq$|#2|, or the insets are increased to |#2|.
% Any rectangle tokens are resolved into moveto/lineto/closepath with rounding.
% The result is appended to PGF's ``current path''
%    \begin{macrocode}
\def\pgfbs@roundpath#1#2{%
  {%
    \def\pgfbs@rp@skipround{\let\pgfbs@rp@possibleround\pgfbs@rp@insertround}%
    \def\pgfbs@rp@insertround{\pgfsyssoftpath@specialround{#2}{#2}}%
    \let\pgfbs@rp@possibleround\pgfbs@rp@insertround%
    %
    \def\pgfsyssoftpath@movetotoken##1##2{\pgfsyssoftpath@moveto{##1}{##2}}%
    \def\pgfsyssoftpath@linetotoken##1##2{%
      \pgfbs@rp@possibleround\pgfsyssoftpath@lineto{##1}{##2}}%
    \def\pgfsyssoftpath@rectcornertoken##1##2##3##4##5{%
      \pgf@xa=##1\relax%
      \advance\pgf@xa by##4%
      \pgf@ya=##2\relax%
      \advance\pgf@ya by##5%
      \pgfsyssoftpath@moveto{##1}{##2}%
      \pgfbs@rp@possibleround%
      \pgfsyssoftpath@lineto{\the\pgf@xa}{##2}%
      \pgfbs@rp@possibleround%
      \pgfsyssoftpath@lineto{\the\pgf@xa}{\the\pgf@ya}%
      \pgfbs@rp@possibleround%
      \pgfsyssoftpath@lineto{##1}{\the\pgf@ya}%
      \pgfbs@rp@possibleround%
      \pgfsyssoftpath@closepath}%
    \def\pgfsyssoftpath@curvetosupportatoken##1##2##3##4##5##6##7##8{%
      \pgfbs@rp@possibleround%
      \pgfsyssoftpath@curveto{##1}{##2}{##4}{##5}{##7}{##8}}%
    \def\pgfsyssoftpath@closepathtoken##1##2{%
      \pgfbs@rp@possibleround\pgfsyssoftpath@closepath}%
    \def\pgfsyssoftpath@specialroundtoken##1##2{%
      \pgfmathsetmacro\pgfbs@rp@ra{max(##1,#2)}%
      \pgfmathsetmacro\pgfbs@rp@rb{max(##2,#2)}%
      \pgfsyssoftpath@specialround{\pgfbs@rp@ra pt}{\pgfbs@rp@rb pt}%
      \let\pgfbs@rp@possibleround\pgfbs@rp@skipround%
    }
    #1%
  }
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\def\pgfbs@compute@shadow@bbox{%
  \edef\pgfbs@minx{\the\pgf@pathminx}%
  \edef\pgfbs@miny{\the\pgf@pathminy}%
  \edef\pgfbs@maxx{\the\pgf@pathmaxx}%
  \edef\pgfbs@maxy{\the\pgf@pathmaxy}%
  \pgfmathsetmacro\pgfbs@midx{0.5*(\pgfbs@minx + \pgfbs@maxx)}%
  \pgfmathsetmacro\pgfbs@midy{0.5*(\pgfbs@miny + \pgfbs@maxy)}%
  \pgfmathsetmacro\pgfbs@minx{\pgfbs@minx - \pgfbs@radius}%
  \pgfmathsetmacro\pgfbs@miny{\pgfbs@miny - \pgfbs@radius}%
  \pgfmathsetmacro\pgfbs@maxx{\pgfbs@maxx + \pgfbs@radius}%
  \pgfmathsetmacro\pgfbs@maxy{\pgfbs@maxy + \pgfbs@radius}%
  \pgfmathsetmacro\pgfbs@wd{\pgfbs@maxx - \pgfbs@minx}%
  \pgfmathsetmacro\pgfbs@ht{\pgfbs@maxy - \pgfbs@miny}%
  \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
  \pgfsyssoftpath@rect{\pgfbs@minx pt}{\pgfbs@miny pt}%
                      {\pgfbs@wd pt}{\pgfbs@ht pt}%
  \pgfsyssoftpath@getcurrentpath{\pgfbs@shadow@bbox}%
  \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\pgfbs@set@fading@pic@bbox{
  \global\pgf@picminx=\pgfbs@minx pt\relax
  \global\pgf@picminy=\pgfbs@miny pt\relax
  \global\pgf@picmaxx=\pgfbs@maxx pt\relax
  \global\pgf@picmaxy=\pgfbs@maxy pt\relax
}
%    \end{macrocode}
%    \begin{macrocode}
\def\pgfbs@usefadepath#1{%
  \pgfsyssoftpath@setcurrentpath{\pgfbs@fadepath}%
  \pgfsyssoftpath@flushcurrentpath%
  \pgfusepath{#1}%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\pgfbs@usebbox#1{%
  \pgfsyssoftpath@setcurrentpath{\pgfbs@shadow@bbox}%
  \pgfsyssoftpath@flushcurrentpath%
  \pgfusepath{#1}%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\pgfbs@apply@canvas@transform{
  \pgflowlevel{
    \pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}
    \pgftransformscale{\pgfkeysvalueof{/tikz/shadow scale}}
    \pgftransformshift{\pgfpoint%
      {\pgfkeysvalueof{/tikz/shadow xshift}-\pgfbs@midx}
      {\pgfkeysvalueof{/tikz/shadow yshift}-\pgfbs@midy}
    }
  }
}
%    \end{macrocode}
%    \begin{macrocode}
\def\pgfbs@paint@fading{
  \pgfpicture
    % fix bounding box.  Using softpaths doesn't update bbox registers.
    \pgfbs@set@fading@pic@bbox
    % draw the outer part of the fading, 
    % starting with lightest, outermost line
    \pgfsetroundjoin
    \pgfmathsetmacro\pgfbs@max@i{\pgfbs@steps - 1}
    \foreach \pgfbs@i in {0,...,\pgfbs@max@i} {
      \pgfmathsetmacro\pgfbs@wth{2 * \pgfbs@radius * (1 - \pgfbs@i/\pgfbs@steps)}
      \pgfmathsetmacro\pgfbs@op{100 - (25/\pgfbs@steps) * (2*\pgfbs@i + 1)}
      \pgfsetlinewidth{\pgfbs@wth pt}
      \pgfsetstrokecolor{black!\pgfbs@op!pstb@shadow@color}
      \pgfbs@usefadepath{stroke}
    }
    % clip to inside of path
    \pgfbs@usefadepath{clip}
    % fill inside with final darkest shadow color
    \pgfsetfillcolor{pstb@shadow@color}
    \pgfbs@usebbox{fill}
    % draw the inner part of the fading,
    % starting with the darkest, innermost line
    \foreach \pgfbs@i in {0,...,\pgfbs@max@i} {
      \pgfmathsetmacro\pgfbs@wth{2 * \pgfbs@radius * (1 - \pgfbs@i/\pgfbs@steps)}
      \pgfmathsetmacro\pgfbs@op{(25/\pgfbs@steps) * (2*\pgfbs@i + 1)}
      \pgfsetlinewidth{\pgfbs@wth pt}
      \pgfsetstrokecolor{black!\pgfbs@op!pstb@shadow@color}
      \pgfbs@usefadepath{stroke}
    }
  \endpgfpicture
}
%    \end{macrocode}
%    \begin{macrocode}
\catcode`\@=11
\catcode`\@=\TheAtCode\relax
%</texfile>
%    \end{macrocode}
%
% \Finale
%