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