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
|
%\iffalse -*-mode:Latex;tex-command:"latex *;dvips -D600 pst-blur -o"-*- \fi
%\iffalse
%% $Id: pst-blur.dtx,v 2.0 2005/09/08 09:48:33 giese Exp $
%%
%% Copyright 1998-2007 Martin Giese, mgiese@risc.uni-linz.ac.at
%% Herbert Voss, voss@pstricks.de
%%
%% This file is under the LaTeX Project Public License
%% See CTAN archives in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%% `pst-blur' is a PSTricks package for blurred shadows
%%
%
%\fi
%\iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\documentclass{ltxdoc}
\usepackage{pst-node}
\usepackage{pst-text}
\usepackage{pst-blur}
\usepackage{url}
\AtBeginDocument{
% \OnlyDescription % comment out for implementation details
\EnableCrossrefs
\RecordChanges
\CodelineIndex}
\AtEndDocument{
\PrintChanges
\PrintIndex}
\hbadness=7000 % Over and under full box warnings
\hfuzz=3pt
\MakeShortVerb{\|}
\newcommand\file[1]{\texttt{#1}}
\begin{document}
\DocInput{pst-blur.dtx}
\end{document}
%</driver>
%\fi
%
% \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 \~}
% \CheckSum{152}
%
%
% \changes{v2.00}{2005/09/08}{%
% using the extended pst-xkey instead of the old pst-key package;
% creating a dtx file;
% new \LaTeX\ wrapper file (hv)}
% \changes{v1.80}{2001/02/16}{First public release. (mg)}
%
% \DoNotIndex{\!,\",\#,\$,\%,\&,\',\(,\+,\*,\,,\-,\.,\/,\:,\;,\<,\=,\>,\?}
% \DoNotIndex{\@,\@B,\@K,\@cTq,\@f,\@fPl,\@ifnextchar,\@nameuse,\@oVk}
% \DoNotIndex{\[,\\,\],\^,\_,\ }
% \DoNotIndex{\^,\\^,\\\^,$\^$,$\\^$,$\\^$}
% \DoNotIndex{\0,\2,\4,\5,\6,\7,\8,}
% \DoNotIndex{\A,\a}
% \DoNotIndex{\B,\b,\Bc,\begin,\Bq,\Bqc}
% \DoNotIndex{\C,\c,\catcode,\cJA,\CodelineIndex,\csname}
% \DoNotIndex{\D,\def,\define@key,\Df,\divide,\DocInput,\documentclass,\pst@addfams}
% \DoNotIndex{\eCN,\edef,\else,\eHd,\eMcj,\EnableCrossrefs,\end,\endcsname}
% \DoNotIndex{\endCenterExample,\endExample,\endinput,\endpsclip}
% \DoNotIndex{\PrintIndex,\PrintChanges,\ProvidesFile}
% \DoNotIndex{\endpspicture,\endSideBySideExample,\Example}
% \DoNotIndex{\F,\f,\FdUrr,\fi,\filedate,\fileversion,\FV@Environment}
% \DoNotIndex{\FV@UseKeyValues,\FV@XRightMargin,\FVB@Example,\fvset}
% \DoNotIndex{\G,\g,\GetFileInfo,\gr,\GradientLoaded,\gsFKrbK@o,\gsj,\gsOX}
% \DoNotIndex{\hbadness,\hfuzz,\HLEmphasize,\HLMacro,\HLMacro@i}
% \DoNotIndex{\HLReverse,\HLReverse@i,\hqcu,\HqY}
% \DoNotIndex{\I,\i,\ifx,\input,\Ir,\IU}
% \DoNotIndex{\j,\jl,\JT,\JVodH}
% \DoNotIndex{\K,\k,\kfSlL}
% \DoNotIndex{\L,\let}
% \DoNotIndex{\message,\mHNa,\mIU}
% \DoNotIndex{\N,\nB,\newcmykcolor,\newdimen,\newif,\nW}
% \DoNotIndex{\O,\oCDJDo,\ocQhVI,\OnlyDescription,\oRKJ}
% \DoNotIndex{\P,\p,\ProvidesPackage,\psframe,\pslinewidth,\psset}
% \DoNotIndex{\PstAtCode,\PSTricksLoaded}
% \DoNotIndex{\q,\Qr,\qssRXq,\qu,\qXjFQp,\qYL}
% \DoNotIndex{\R,\r,\RecordChanges,\relax,\RlaYI,\rN,\Rp,\rp,\RPDXNn,\rput}
% \DoNotIndex{\S,\scalebox,\SgY,\SideBySide@Example,\SideBySideExample}
% \DoNotIndex{\SgY,\sk,\Sp,\space,\sZb}
% \DoNotIndex{\T,\the,\tw@}
% \DoNotIndex{\u,\UiSWGEf@,\uJi,\usepackage,\uVQdMM,\UYj}
% \DoNotIndex{\VerbatimEnvironment,\VerbatimInput,\VrC@}
% \DoNotIndex{\WhZ,\WjKCYb,\WNs}
% \DoNotIndex{\XkN,\XW}
% \DoNotIndex{\Z,\ZCM,\Ze}
% \DoNotIndex{\addtocounter,\advance,\alph,\arabic,\AtBeginDocument,\AtEndDocument}
% \DoNotIndex{\AtEndOfPackage,\begingroup,\bfseries,\bgroup,\box,\csname}
% \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\expandafter,\fi}
% \DoNotIndex{\TeX,\z@,\p@,\@one,\xdef,\thr@@,\string,\sixt@@n,\reset,\or,\multiply,\repeat,\RequirePackage}
% \DoNotIndex{\@cclvi,\@ne,\@ehpa,\@nil,\copy,\dp,\global,\hbox,\hss,\ht,\ifodd,\ifdim,\ifcase,\kern}
% \DoNotIndex{\chardef,\loop,\leavevmode,\ifnum,\lower,\next,\wd,\setbox}
% \setcounter{IndexColumns}{2}
%
% \title{\textsf{pst-blur} package \\ version \fileversion}
% \author{Martin Giese\thanks{\protect\url{Martin.Giese@oeaw.ac.at}}}
% \date{\filedate}
% \maketitle
%
%\section{Introduction}
% The ability to paint shadows on arbitrary shapes is a standard
% feature of PSTricks. However, these shadows are always `hard':\\
%{\psset{unit=0.6cm,linewidth=0.5pt}
% \begin{pspicture}(-5,0)(10,4)
% \psset{shadow=true,shadowcolor=gray,shadowsize=0.15cm}
% \psframe(1,1)(3,3)
% \pscircle(6,2){1}
% \rput(9,2){\pscharpath{\fontfamily{ptm}\fontsize{40}{40}\selectfont A}}
% \end{pspicture}
%}\\
% The |pst-blur| package provides blurred shadows
% for closed shapes drawn with PSTricks:\\
%{\psset{unit=0.6cm,linewidth=0.5pt,blur=true,blurradius=0.07cm}
% \begin{pspicture}(-5,0)(10,4)
% \psset{shadow=true,shadowcolor=gray,shadowsize=0.15cm}
% \psframe(1,1)(3,3)
% \pscircle(6,2){1}
% \rput(9,2){\pscharpath{\fontfamily{ptm}\fontsize{40}{40}\selectfont A}}
% \end{pspicture}
%}\\
% It also provides a new
% box command |\psblurbox|, which is similar to |\psshadowbox|,
% but gives the box a blurred shadow.
% \medskip
%
%The new graphics parameters and macros 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 and a PostScript
%header for the |dvi|-to-PostScript converter. You can get section 3
%by calling \LaTeX\ as follows on most relevant systems:
%\begin{verbatim}
%latex '\AtBeginDocument{\AlsoImplementation}\input{pst-blur.dtx}'
%\end{verbatim}
%
%\section{Package Usage}
% To use |pst-blur|, you have to say
% \begin{verbatim}
% \usepackage{pst-blur}
% \end{verbatim}
% in the document prologue for \LaTeX, and
% \begin{verbatim}
% \input pst-blur.tex
% \end{verbatim}
% in ``plain'' \TeX.
%
% \DescribeMacro{blur}
% To paint shapes with blurred shadows,
% set the graphics parameters |shadow| and |blur| to |true|, eg
% \pscircle[shadow=true,blur=true](8,-0.5){0.5}
% \begin{verbatim}
% \psset{unit=1cm}
% \pscircle[shadow=true,blur=true](0,0){0.5}
% \end{verbatim}
% \psset{unit=1cm}
% for a circle with a blurred shadow.
% The parameter |blur| has no influence if |shadow| is |false|.
% \medskip
%
% \DescribeMacro{shadowsize}
% \DescribeMacro{shadowangle}
% \DescribeMacro{blurradius}
% The rendering of blurred shadows is controlled by a number of
% additional graphics parameters. The offset of the shadow is controlled
% by the parameters |shadowsize| and |shadowangle|, which are the same
% as for ordinary shadows.\footnote{In particular, |shadowangle| has
% to be negative for the usual placement of shadows below and to the
% right of shapes.} The size of the blurring effect is
% controlled by the parameter |blurradius|, see Fig~\ref{fig:params}.
% The default value for |blurradius| is 1.5pt, which fits nicely with
% the default |shadowsize| of 3pt.
% \medskip
%
% \begin{figure}\caption{Parameters for blurred shadows}
% \label{fig:params}
% \vskip1cm
% \qquad\qquad\begin{pspicture*}(0,0)(10,6)
% \psframe[linewidth=4pt,fillcolor=lightgray,fillstyle=crosshatch,
% shadow=true,blur=true,shadowsize=2cm,shadowangle=-35,
% blurradius=1cm,shadowcolor=lightgray](-5,3)(5,10)
% \pnode(5,3){A}
% \pnode(5.3,2.9){A1}
% \pnode(6.64,1.85){B}
% \pnode(7.51,2.35){C}
% \pscircle(6.64,1.85){1}
% \ncline{|-|}{A}{B}
% \bput(0.2){|shadowsize|}
% \ncline{->}{B}{C}
% \bput(1.5){|blurradius|}
% \psline(5,3)(6,3)
% \psarcn{->}(5,3){0.5}{0}{-35}
% \rput(7,3.7){\rnode{D}{$-|shadowangle|$}}
% \nccurve[linewidth=0.5pt,angleA=-90,angleB=70]{->}{D}{A1}
% \rput[l](6,5.6){|shadowcolor|}
% \rput[l](8,5){|blurbg|}
% {\psset{linestyle=dotted}
% \psline(0,0.85)(6.64,0.85)
% \psline(7.64,1.85)(7.64,6)
% \psset{linestyle=dashed}
% \psline(0,2.85)(5.64,2.85)
% \psline(5.64,2.85)(5.64,6)}
% {\psset{linewidth=0.5pt}
% \psline{*-}(5.64,5.3)(6,5.4)
% \psline{*-}(7.64,4.75)(8,4.85)
% \ncline{F}{F1}
% }
% \end{pspicture*}
% \end{figure}
%
% \DescribeMacro{shadowcolor}
% \DescribeMacro{blurbg}
% The inner, usually darkest part of the shadow is painted in the
% colour defined by |shadowcolor|. In the range defined by |blurradius|,
% the colour gradually fades to the background colour set by |blurbg|.
% The default value for |blurbg| is white. You should change this parameter
% when you want to paint shapes over a coloured background, ie\\
% \begin{minipage}{\textwidth}
% \begin{verbatim}
% \psframe[fillstyle=solid,fillcolor=yellow](-.7,-.7)(.7,.7)
% \pscircle[shadow=true,blur=true,blurbg=yellow](0,0){0.4}
% \end{verbatim}
% \rput(11.7,1.4){
% \psframe[fillstyle=solid,fillcolor=yellow](-.7,-.7)(.7,.7)
% \pscircle[shadow=true,blur=true,blurbg=yellow](0,0){0.4}}
% \end{minipage}
%
% \DescribeMacro{blursteps}
% The number of distinct colour steps painted between |shadowcolor|
% and |blurbg| is controlled by the parameter |blursteps|. The default
% value for |blursteps| is 20, which is usually more than sufficient.
% Note, that higher values for |blursteps| result in proportionally slower
% rendering. This can be very tiresome with complex shapes.
% \medskip
%
% \DescribeMacro{\psblurbox}
% Using a
% \psframebox[shadow=true,blur=true,blurradius=2.5pt,shadowcolor=gray]%
% {|\ttfamily\symbol{92}psframebox|}
% with a blurred
% shadow in the middle of some text produces poor results, because \TeX\
% does not know about the extra space taken by the shadow. For normal
% shadows, this problem is solved by the |\psshadowbox| macro, which
% adds the extra space around the box for the shadow. For blurred shadows,
% this is not sufficient: an extra |\blurradius| has to be added. This
% is done by the macro \psblurbox{\ttfamily\symbol{92}psblurbox}, which is otherwise
% identical to |\psshadowbox|. Note, that |\psblurbox| shares a
% deficiency of |\psshadowbox|: It only works correctly
% with $|shadowangle|=-45$, because \TeX\ does not provide trigonometric
% operations.
%
% \StopEventually{}
%
% \section{The Code}
%
% \subsection{The \file{pst-blur.sty} file}
% The \file{pst-blur.sty} file is very simple. It just loads
% the generic \file{pst-blur.tex} file.
% \begin{macrocode}
%<*stylefile>
\RequirePackage{pstricks}
\ProvidesPackage{pst-blur}[2005/09/08 package wrapper for
pst-blur.tex (hv)]
\input{pst-blur.tex}
\ProvidesFile{pst-blur.tex}
[\filedate\space v\fileversion\space `PST-blur' (hv)]
%</stylefile>
% \end{macrocode}
%
% \subsection{The \file{pst-blur.tex} file}
% \file{pst-blur.tex} contains the \TeX-side of things. We begin
% by identifying ourselves and setting things up, the same as in
% other PSTricks packages.
% \begin{macrocode}
%<*texfile>
\csname PstBlurLoaded\endcsname
\let\PstBlurLoaded\endinput
\ifx\PSTricksLoaded\endinput\else
\def\next{\input pstricks.tex }\expandafter\next
\fi
% \end{macrocode}
% \verb+pst-blur+ uses the extended version of the keyvalue interface.
% \begin{macrocode}
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi
% \end{macrocode}
%%
% \begin{macrocode}
\def\fileversion{2.0}
\def\filedate{2005/09/08}
\message{ v\fileversion, \filedate}
\edef\TheAtCode{\the\catcode`\@}
\catcode`\@=11
% \end{macrocode}
% Add the package name to the list of family names of the keyvalue list.
% \begin{macrocode}
\pst@addfams{pst-blur}
\pstheader{pst-blur.pro}
% \end{macrocode}
%
% \subsubsection{New graphics parameters}
% \begin{macro}{blur}
% \begin{macro}{blurradius}
% \begin{macro}{blursteps}
% \begin{macro}{blurbg}
% The definitions of the new graphics parameters follow the definitions
% for parameters of the same types found in |pstricks.tex|.
% \begin{macrocode}
\newif\ifpsblur
\define@key[psset]{pst-blur}{blur}[true]{\@nameuse{psblur#1}\pst@setrepeatarrowsflag}
\psset{blur=false}
%%
\define@key[psset]{pst-blur}{blurradius}{\pst@getlength{#1}\psx@blurradius}
\psset{blurradius=1.5pt}
%%
\define@key[psset]{pst-blur}{blursteps}{\pst@getint{#1}\psx@blursteps}
\psset{blursteps=20}
%%
\define@key[psset]{pst-blur}{blurbg}{\pst@getcolor{#1}\psx@blurbg}
\psset{blurbg=white}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Hooking into the PSTricks shadow macros}
% \begin{macro}{\pst@closedshadow}
% The macro |\pst@closedshadow| is usually called internally by
% PSTricks to paint a shadow in the shape of the current path.
% This macro has been renamed |\pst@sharpclosedshadow|. The
% new |\pst@closedshadow| jumps to either of |\pst@sharpclosedshadow|
% or |\pst@blurclosedshadow|, depending on |\ifpsblur|, which is
% directly related to the graphics parameter |blur|.
% \begin{macrocode}
\def\pst@closedshadow{%
\ifpsblur\pst@blurclosedshadow\else\pst@sharpclosedshadow\fi
}
\def\pst@sharpclosedshadow{%
\addto@pscode{%
gsave
\psk@shadowsize \psk@shadowangle \tx@PtoC
\tx@Shadow
\pst@usecolor\psshadowcolor
gsave fill grestore
stroke
grestore
gsave
\pst@usecolor\psfillcolor
gsave fill grestore
stroke
grestore}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\pst@blurclosedshadow}
% The PostScript code for blurred shadows is produced by the following
% macro. It pushes the diverse parameters (|\tx@PtoC| does polar to
% cartesian coordinate transformation for the shadow offset) and calls
% |BlurShadow|. Afterwards, it fills and strokes the current path,
% same as the original |\pst@closedshadow|.
% \begin{macrocode}
\def\pst@blurclosedshadow{%
\addto@pscode{%
gsave
gsave \pst@usecolor\psshadowcolor currentrgbcolor grestore
gsave \pst@usecolor\psx@blurbg currentrgbcolor grestore
\psx@blurradius\space
\psx@blursteps\space
\psk@shadowsize \psk@shadowangle \tx@PtoC
tx@PstBlurDict begin BlurShadow end
grestore
gsave
\pst@usecolor\psfillcolor
gsave fill grestore
stroke
grestore}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\pst@blurclosedshadow}
% This one looks very impressing. In fact, it is a verbatim copy
% of |\psshadowbox|, with only the line
% |\advance\pst@dimh\psx@blurradius\p@| added!
% \begin{macrocode}
\def\psblurbox{%
\def\pst@par{}\pst@object{psblurbox}}
\def\psblurbox@i{\pst@makebox\psblurbox@ii}
\def\psblurbox@ii{%
\begingroup
\pst@useboxpar
\psblurtrue
\psshadowtrue
\psboxseptrue
\setbox\pst@hbox=\hbox{\psframebox@ii}%
\pst@dimh=\psk@shadowsize\p@
\pst@dimh=.7071\pst@dimh
\advance\pst@dimh\psx@blurradius\p@
\pst@dimg=\dp\pst@hbox
\advance\pst@dimg\pst@dimh
\dp\pst@hbox=\pst@dimg
\pst@dimg=\wd\pst@hbox
\advance\pst@dimg\pst@dimh
\wd\pst@hbox=\pst@dimg
\leavevmode
\box\pst@hbox
\endgroup}
%%
\catcode`\@=\TheAtCode\relax
%</texfile>
% \end{macrocode}
% \end{macro}
%
% \subsection{The \file{pst-blur.pro} file}
% The file \file{pst-blur.pro} contains PostScript definitions
% to be included in the PostScript output by the
% |dvi|-to-PostScript converter, eg |dvips|.
% This is all rather similar to
% \file{pst-slpe.pro}, and I just don't feel like explaining it,
% so you'll have to work through it yourself, if you want to
% know what happens. The trick is basically to draw the outline
% repeatedly with varying line widths. The procedure |Shadow|
% called in |BlurShadow| is defined in \file{pstricks.pro} and
% translates the current path based on an $x$- and $y$-displacement
% taken from the stack.
% \begin{macrocode}
%<*prolog>
/tx@PstBlurDict 60 dict def
tx@PstBlurDict begin
/Iterate {
/SegLines ED
/ThisB ED /ThisG ED /ThisR ED
/NextB ED /NextG ED /NextR ED
/W 2.0 BlurRadius mul def
/WDec W SegLines div def
/RInc NextR ThisR sub SegLines div def
/GInc NextG ThisG sub SegLines div def
/BInc NextB ThisB sub SegLines div def
/R ThisR def
/G ThisG def
/B ThisB def
SegLines {
R G B
sqrt 3 1 roll sqrt 3 1 roll sqrt 3 1 roll
setrgbcolor
gsave W setlinewidth
stroke grestore
/W W WDec sub def
/R R RInc add def
/G G GInc add def
/B B BInc add def
} bind repeat
} def
/BlurShadow {
Shadow
/BlurSteps ED
/BlurRadius ED
dup mul /BEnd ED dup mul /GEnd ED dup mul /REnd ED
dup mul /BBeg ED dup mul /GBeg ED dup mul /RBeg ED
RBeg REnd add 0.5 mul /RMid ED
GBeg GEnd add 0.5 mul /GMid ED
BBeg BEnd add 0.5 mul /BMid ED
/OuterSteps BlurSteps 2 div cvi def
/InnerSteps BlurSteps OuterSteps sub def
1 setlinejoin
RMid GMid BMid REnd GEnd BEnd OuterSteps Iterate
gsave RBeg sqrt GBeg sqrt BBeg sqrt setrgbcolor fill grestore
clip
0 setlinejoin
RMid GMid BMid RBeg GBeg BBeg InnerSteps Iterate
} def
end
%</prolog>
% \end{macrocode}
% \Finale
%
|