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
|
\ProvidesPackage{pgfshade}[2004/10/08 ver 0.64]
% Copyright 2003 by Till Tantau <tantau@cs.tu-berlin.de>.
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt.
\RequirePackage{pgf}
\RequirePackage{xxcolor}
\DeclareOption{pdf}
{
\def\pgfsys@horishading#1#2#3{%
{%
\pgf@parsefunc{#3}%
\setbox\pgf@tempbox=\hbox to\pgf@max{\vbox to#2{\vfil\pdfliteral{/Sh sh}}\hfil}%
\pgf@process{\pgfpoint{\pgf@max}{#2}}%
\pdfxform resources {%
/Shading << /Sh << /ShadingType 2
/ColorSpace /DeviceRGB
/Domain [\pgf@doma\space\pgf@domb]
/Coords [\pgf@doma\space0 \pgf@domb\space0]
/Function \pgf@pdfparsedfunction
/Extend [false false] >> >>}\pgf@tempbox%
\expandafter\xdef\csname @pgfshading#1!\endcsname{\noexpand\pdfrefxform\the\pdflastxform}%
}%
}
\def\pgfsys@vertshading#1#2#3{%
{%
\pgf@parsefunc{#3}%
\setbox\pgf@tempbox=\hbox to#2{\vbox to\pgf@max{\vfil\pdfliteral{/Sh sh}}\hfil}%
\pgf@process{\pgfpoint{#2}{\pgf@max}}%
\pdfxform resources {%
/Shading << /Sh << /ShadingType 2
/ColorSpace /DeviceRGB
/Domain [\pgf@doma\space\pgf@domb]
/Coords [0 \pgf@doma\space0 \pgf@domb]
/Function \pgf@pdfparsedfunction
/Extend [false false] >> >>}\pgf@tempbox%
\expandafter\xdef\csname @pgfshading#1!\endcsname{\noexpand\pdfrefxform\the\pdflastxform}%
}%
}
\def\pgfsys@radialshading#1#2#3{%
{%
\pgf@parsefunc{#3}%
\setbox\pgf@tempbox=\hbox to2\pgf@max{\vbox to2\pgf@max{\vfil\pdfliteral{/Sh sh}}\hfil}%
\pgf@process{#2}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
\advance\pgf@xa by \pgf@x%
\advance\pgf@ya by \pgf@y%
\pdfxform resources {%
/Shading << /Sh << /ShadingType 3
/ColorSpace /DeviceRGB
/Domain [\pgf@doma\space\pgf@domb]
/Coords [\pgfget{xa} \pgfget{ya} \pgf@doma\space \pgfget x
\pgfget y \pgf@domb]
/Function \pgf@pdfparsedfunction
/Extend [true false] >> >>}\pgf@tempbox%
\expandafter\xdef\csname @pgfshading#1!\endcsname{\noexpand\pdfrefxform\the\pdflastxform}%
}%
}%
}
\DeclareOption{postscript}
{
\def\pgfsys@horishading#1#2#3{%
{%
\pgf@parsefunc{#3}%
\setlength\pgf@x{#2}%
\pgf@bpcorr{\pgf@x}%
\expandafter\xdef\csname @pgfshading#1!\endcsname{\hbox{%
\noexpand\begin{pgfpicture}{0pt}{0pt}{\the\pgf@max}{#2}%
\noexpand\pgfrect[clip]{\noexpand\pgforigin}{\noexpand\pgfpoint{\the\pgf@max}{#2}}%
\noexpand\pgf@ps{\pgf@domb\space \pgfget{x} pgfH \pgf@psfuncs\space pop}%
\noexpand\end{pgfpicture}}}%
}%
}
\def\pgfsys@vertshading#1#2#3{%
{%
\pgf@parsefunc{#3}%
\setlength\pgf@x{#2}%
\pgf@bpcorr{\pgf@x}%
\expandafter\xdef\csname @pgfshading#1!\endcsname{\hbox{%
\noexpand\begin{pgfpicture}{0pt}{0pt}{#2}{\the\pgf@max}%
\noexpand\pgfrect[clip]{\noexpand\pgforigin}{\noexpand\pgfpoint{#2}{\the\pgf@max}}%
\noexpand\pgf@ps{\pgf@domb\space \pgfget{x} pgfV \pgf@psfuncs\space pop}%
\noexpand\end{pgfpicture}}}%
}%
}
\def\pgfsys@radialshading#1#2#3{%
{%
\pgf@parsefunc{#3}%
\pgf@process{#2}%
\pgf@xa=2\pgf@max%
\pgf@bpcorr{\pgf@max}%
\advance\pgf@x by \pgf@max%
\advance\pgf@y by \pgf@max%
\expandafter\xdef\csname @pgfshading#1!\endcsname{\hbox{%
\noexpand\begin{pgfpicture}{0pt}{0pt}{\the\pgf@xa}{\the\pgf@xa}%
\noexpand\pgf@ps{%
\pgf@domb\space \pgfget{y} \pgfget{x} \pgfget{max} pgfR1
\pgf@psfuncs\space \pgf@firstcolor\space \pgf@doma\space pgfR2}%
\noexpand\end{pgfpicture}}}%
}%
}
% Parameters to horizontal pre axishade: \pgf@domb x
\special{! /pgfH{%
/pgfheight exch def 0.75 setlinewidth [] 0 setdash
/pgfshade {pgfA} def /pgfdir { dup 0 moveto
dup 5 index lineto } bind def} B}%
% Parameters to vertical pre axishade: \pgf@domb x
\special{! /pgfV{%
/pgfheight exch def 0.75 setlinewidth [] 0 setdash
/pgfshade {pgfA} def /pgfdir { dup 0 exch moveto dup 5 index
exch lineto } bind def} B}%
% Parameters to axishade: end x, start x, r-, g-, b- of first color, r-, g-, b- of second color
% Stack afterwards: end x
\special{! /pgfA{
/pgfdiff 8 index round cvi 8 index round cvi sub 2 mul 1 add def
2 index 6 index sub pgfdiff div % put red-step on stack
2 index 6 index sub pgfdiff div % put green-step on stack
2 index 6 index sub pgfdiff div % put green-step on stack
pgfheight 9 index 9 index 9 index 14 index
pgfdiff {
3 index 3 index 3 index setrgbcolor % Set color
pgfdir
stroke
4 -1 roll 7 index add % red += incred
4 -1 roll 6 index add % green += incgreen
4 -1 roll 5 index add % blue += incblue
4 -1 roll .5 sub % x += 0.5
} repeat
mark 15 1 roll cleartomark exch pop % leave only start x on stack
}B }
% Parameters to radialshade pre: \pgf@domb y x max
\special{! /pgfR1{
newpath dup dup dup 0 360 arc clip newpath
dup /pgfendx exch def
/pgfendy exch def
0.875 setlinewidth
[] 0 setdash
/pgfshade {pgfR} def
/pgfstartx exch def
/pgfstarty exch def
/pgfdiffx pgfendx pgfstartx sub def
/pgfdiffy pgfendy pgfstarty sub def
dup /pgfdomb exch def
}B }
% Parameters to radialshade post: \pgf@firstcolor \pgf@doma
\special{! /pgfR2{
newpath 0.5 add pgfcircx pgfcircy 3 2 roll 0 360 arc
setrgbcolor fill pop}B }%
% Parameters to radialshade: end x, start x, r-, g-, b- of first color, r-, g-, b- of second color
% Stack afterwards: end x
\special{! /pgfR{
/pgfdiff 8 index round cvi 8 index round cvi sub 4 mul 1 add def
/pgfcircx pgfstartx 9 index pgfdiffx pgfdomb div mul add def
/pgfcircy pgfstarty 9 index pgfdiffy pgfdomb div mul add def
/pgfcircxe pgfstartx 8 index pgfdiffx pgfdomb div mul add def
/pgfcircye pgfstarty 8 index pgfdiffy pgfdomb div mul add def
/pgfxstep pgfcircxe pgfcircx sub pgfdiff div def
/pgfystep pgfcircye pgfcircy sub pgfdiff div def
2 index 6 index sub pgfdiff div % put red-step on stack
2 index 6 index sub pgfdiff div % put green-step on stack
2 index 6 index sub pgfdiff div % put green-step on stack
8 index 8 index 8 index 13 index
pgfdiff {
3 index 3 index 3 index setrgbcolor % Set color
pgfcircx pgfcircy 2 index 0 360 arc closepath
stroke
4 -1 roll 6 index add % red += incred
4 -1 roll 5 index add % green += incgreen
4 -1 roll 4 index add % blue += incblue
4 -1 roll .25 sub % x += 0.25
/pgfcircx pgfcircx pgfxstep add def
/pgfcircy pgfcircy pgfystep add def
} repeat
mark 14 1 roll cleartomark exch pop % leave only start x on stack
}B}
}
\ProcessOptions
%
% Parsing functions
%
\newdimen\pgf@max
\def\pgf@parsefunc#1{%
\edef\temp{{#1}}%
\expandafter\pgf@convertrgbstring\temp%
\edef\temp{{\pgf@rgbconv}}%
\expandafter\pgf@@parsefunc\temp}
\def\pgf@@parsefunc#1{%
\def\pgf@bounds{}%
\def\pgf@funcs{}%
\def\pgf@psfuncs{}%
\def\pgf@encode{}%
\pgf@parsefirst[#1; ]%
\pgf@parselastdom[#1; ]%
\pgf@parsemid[#1; ]%
\edef\pgf@pdfparsedfunction{%
<< /FunctionType 3 /Domain [\pgf@doma\space\pgf@domb] /Functions
[\pgf@funcs\space] /Bounds [\pgf@bounds] /Encode [0 1 \pgf@encode]
>> }%
\xdef\pgf@psfuncs{\pgf@psfuncs}%
}
\def\pgf@parsefirst[rgb(#1)=(#2,#3,#4)#5]{%
\setlength\pgf@x{#1}%
\pgf@bpcorr\pgf@x%
\edef\pgf@doma{\pgfget x}%
\edef\pgf@prevx{\pgfget x}%
\pgf@getrgbtuplewithmixin{#2}{#3}{#4}%
\edef\pgf@prevcolor{\pgf@rgb}%
\edef\pgf@firstcolor{\pgf@rgb}}
\def\pgf@parselastdom[rgb(#1)=(#2,#3,#4); {%
\@ifnextchar]{%
\setlength\pgf@x{#1}%
\pgf@max=\pgf@x\relax%
\pgf@bpcorr\pgf@x%
\edef\pgf@domb{\pgfget x}%
\@gobble}{\pgf@parselastdom[}}
\def\pgf@parsemid[rgb(#1)=(#2,#3,#4); {\pgf@parserest[}
\def\pgf@parserest[rgb(#1)=(#2,#3,#4); {%
\@ifnextchar]{%
\pgf@getrgbtuplewithmixin{#2}{#3}{#4}%
\edef\pgf@funcs{\pgf@funcs\space%
<< /FunctionType 2 /Domain [\pgf@doma\space\pgf@domb] /C0
[\pgf@prevcolor] /C1 [\pgf@rgb] /N 1 >> }%
\edef\pgf@psfuncs{\pgf@prevx\space \pgf@rgb\space \pgf@prevcolor\space pgfshade \pgf@psfuncs}%
\@gobble}{%
\setlength\pgf@x{#1}%
\pgf@bpcorr\pgf@x%
\pgf@getrgbtuplewithmixin{#2}{#3}{#4}%
\edef\pgf@psfuncs{\pgf@prevx\space \pgf@rgb\space \pgf@prevcolor\space pgfshade \pgf@psfuncs}%
\edef\pgf@prevx{\pgfget{x}}%
\edef\pgf@bounds{\pgf@bounds\space\pgfget x}%
\edef\pgf@encode{\pgf@encode\space0 1}%
\edef\pgf@funcs{\pgf@funcs\space%
<< /FunctionType 2 /Domain [\pgf@doma\space\pgf@domb] /C0
[\pgf@prevcolor] /C1 [\pgf@rgb] /N 1 >> }%
\edef\pgf@prevcolor{\pgf@rgb}%
\pgf@parserest[}}
\def\pgf@getrgbtuplewithmixin#1#2#3{%
\definecolor{pgfshadetemp}{rgb}{#1,#2,#3}%
\applycolormixins{pgfshadetemp}%
\extractcolorspec{pgfshadetemp}{\pgf@tempcolor}%
\expandafter\convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}%
\expandafter\pgf@getrgb@@\pgf@rgbcolor!}
\def\pgf@getrgb@@#1,#2,#3!{%
\def\pgf@rgb{#1 #2 #3}}
\def\pgf@convertrgbstring#1{%
\def\pgf@rgbconv{}%
\pgf@converttorgb#1]%
}
\def\pgf@converttorgb{%
\@ifnextchar]{\@gobble}%done!
{%
\@ifnextchar;{\pgf@grabsemicolor}%
{%
\@ifnextchar r{\pgf@grabrgb}%
{%
\@ifnextchar g{\pgf@grabgray}%
{%
\@ifnextchar c{\pgf@grabcolor}%
{\PackageError{pgfshade}{Illformed shading
specification}{}\pgf@converttorgb}%
}%
}%
}%
}%
}
\def\pgf@grabsemicolor;{%
\edef\pgf@rgbconv{\pgf@rgbconv; }\pgf@converttorgb}
\def\pgf@grabrgb rgb(#1)=(#2,#3,#4){%
\edef\pgf@rgbconv{\pgf@rgbconv rgb(#1)=(#2,#3,#4)}\pgf@converttorgb}
\def\pgf@grabgray gray(#1)=(#2){%
\edef\pgf@rgbconv{\pgf@rgbconv rgb(#1)=(#2,#2,#2)}\pgf@converttorgb}
\def\pgf@grabcolor color(#1)=(#2){%
\colorlet{pgf@tempcol}{#2}%
\extractcolorspec{pgf@tempcol}{\pgf@tempcolor}%
\expandafter\convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}%
\expandafter\pgf@convgetrgb@\expandafter{\pgf@rgbcolor}{#1}%
}
\def\pgf@convgetrgb@#1#2{%
\edef\pgf@rgbconv{\pgf@rgbconv rgb(#2)=(#1)}\pgf@converttorgb}
% Declares a horizontal shading for later use. The shading is a
% horizontal bar that changes its color.
%
% #1 = name of the shading for later use
% #2 = height of the shading
% #3 = color specification in the following format: A list of colors
% that the bar should have at certain points. If the bar should
% be red at 1cm, this is specified as
% "rgb(1cm)=(1,0,0)". Multiple specifications are separated by a
% semicolon and a space. At least two specifications must be
% given. The specified positions must be given in increasing
% order.
%
% Example:
%
% \pgfdeclarehorizontalshading{redtogreentoblue}{1cm}{%
% rgb(0cm)=(1,0,0); % red
% rgb(1cm)=(0,1,0); % green
% rgb(2cm)=(0,0,1)}
%
% \begin{document}
% The following bar is 2cm long: \pgfuseshading{redtogreentoblue}.
% \end{document}
\newcommand\pgfdeclarehorizontalshading[4][]{%
\expandafter\def\csname pgf@deps@pgfshading#2!\endcsname{#1}%
\expandafter\ifx\csname pgf@deps@pgfshading#2!\endcsname\@empty%
\pgfsys@horishading{#2}{#3}{#4}%
\else%
\expandafter\def\csname pgf@func@pgfshading#2!\endcsname{\pgfsys@horishading}%
\expandafter\def\csname pgf@args@pgfshading#2!\endcsname{{#3}{#4}}%
\expandafter\let\csname @pgfshading#2!\endcsname=\@empty%
\fi}
% Declares a vertical shading for later use.
%
% #1 = name of the shading for later use
% #2 = height of the shading
% #3 = color specification
%
% Example:
%
% \pgfdeclareverticalshading{redtogreentoblue}{1cm}{%
% rgb(0cm)=(1,0,0); % red
% rgb(1cm)=(0,1,0); % green
% rgb(2cm)=(0,0,1)}
%
% \begin{document}
% The following bar is 2cm high: \pgfuseshading{redtogreentoblue}.
% \end{document}
\newcommand\pgfdeclareverticalshading[4][]{%
\expandafter\def\csname pgf@deps@pgfshading#2!\endcsname{#1}%
\expandafter\ifx\csname pgf@deps@pgfshading#2!\endcsname\@empty%
\pgfsys@vertshading{#2}{#3}{#4}%
\else%
\expandafter\def\csname pgf@func@pgfshading#2!\endcsname{\pgfsys@vertshading}%
\expandafter\def\csname pgf@args@pgfshading#2!\endcsname{{#3}{#4}}%
\expandafter\let\csname @pgfshading#2!\endcsname=\@empty%
\fi}
% Declares a radial shading for later use.
%
% #1 = name of the shading for later use
% #2 = center of inner circle
% #3 = color specification
%
% Description:
%
% A radial shading creates a smooth color transition between two
% circles. The center of the inner circle is at the give position. Its
% radius is the start of the color specification. The
% center of the outer circle is at the center of the whole shading,
% whose radius is the end of the color specification. For example,
% suppose the color specification is "rgb(1cm)=(1,1,1); rgb(2cm)=(0,0,0)".
% Then the shading would be 4cm times 4cm large. The inner circle would
% have diameter 1cm and the outer circle would have diameter 2cm. The
% outer circle would be centered in the middle of the shading, whereas
% the outer circle would be centered at the given position.
%
% Example:
%
% \pgfdeclareradialshading{redtogreentoblue}{\pgfpoint{2cm}{2cm}}{%
% rgb(10pt)=(1,0,0); % red
% rgb(2cm)=(0,1,0); % green
% rgb(3cm)=(0,0,1)}
%
% \begin{document}
% The following ball has diameter 3cm: \pgfuseshading{redtogreentoblue}.
% \end{document}
\newcommand\pgfdeclareradialshading[4][]{%
\expandafter\def\csname pgf@deps@pgfshading#2!\endcsname{#1}%
\expandafter\ifx\csname pgf@deps@pgfshading#2!\endcsname\@empty%
\pgfsys@radialshading{#2}{#3}{#4}%
\else%
\expandafter\def\csname pgf@func@pgfshading#2!\endcsname{\pgfsys@radialshading}%
\expandafter\def\csname pgf@args@pgfshading#2!\endcsname{{#3}{#4}}%
\expandafter\let\csname @pgfshading#2!\endcsname=\@empty%
\fi}
% Inserts a box into the text that contains a previously defined
% shading.
%
% #1 = Name of a shading
%
% Example:
%
% \pgfuseshading{redtogreentoblue}
\def\pgfuseshading#1{%
\edef\pgf@shadingname{@pgfshading#1}%
\pgf@tryextensions{\pgf@shadingname}{\pgfalternateextension}%
\expandafter\@ifundefined\expandafter{\pgf@shadingname}%
{\PackageError{pgfshade}{Undefined shading "#1"}{}}%
{%
{%
\globalcolorsfalse%
\def\pgf@shade@adds{}%
\@ifundefined{pgf@deps\pgf@shadingname}%
{}%
{%
\edef\@list{\csname pgf@deps\pgf@shadingname\endcsname}%
\@for\@temp:=\@list\do{%
{%
\applycolormixins{\@temp}%
\extractcolorspec{\@temp}{\pgf@tempcolor}%
\expandafter\convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}%
\xdef\pgf@shade@adds{\pgf@shade@adds,\pgf@rgbcolor}%
}%
}%
}%
\expandafter\pgf@strip@shadename\pgf@shadingname!!%
\@ifundefined{@pgfshading\pgf@basename\pgf@shade@adds!}%
{%
{%
\expandafter\def\expandafter\@temp\expandafter{\csname pgf@func\pgf@shadingname\endcsname}%
\edef\@args{{\pgf@basename\pgf@shade@adds}}%
\expandafter\expandafter\expandafter\def%
\expandafter\expandafter\expandafter\@@args%
\expandafter\expandafter\expandafter{\csname pgf@args\pgf@shadingname\endcsname}%
\expandafter\expandafter\expandafter\@temp\expandafter\@args\@@args%
%
}%
}%
{}%
\csname @pgfshading\pgf@basename\pgf@shade@adds!\endcsname%
}%
}%
}
\def\pgf@strip@shadename @pgfshading#1!!!{\def\pgf@basename{#1}}
% Create an alias name for a shading
%
% #1 = name of the alias
% #2 = name of the original
%
% Example:
%
% \pgfaliasshading{shading!25}{shadingshaded}
\def\pgfaliasshading#1#2{%
\expandafter\let\expandafter\pgf@temp\expandafter=\csname @pgfshading#2!\endcsname%
\expandafter\let\csname @pgfshading#1!\endcsname=\pgf@temp%
\expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@deps@pgfshading#2!\endcsname%
\expandafter\let\csname pgf@deps@pgfshading#1!\endcsname=\pgf@temp%
\expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@func@pgfshading#2!\endcsname%
\expandafter\let\csname pgf@func@pgfshading#1!\endcsname=\pgf@temp%
\expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@args@pgfshading#2!\endcsname%
\expandafter\let\csname pgf@args@pgfshading#1!\endcsname=\pgf@temp%
}
\endinput
|