Debian Codegraph @

texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def

raw
1 %--------------------------------------------
2 % $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/sys/pgflibrarysurfshading.pgfsys-pdftex.def,v 1.1 2009/06/11 07:14:52 ludewich Exp $
3 %
4 % Package pgfplots
5 %
6 % Provides a user-friendly interface to create function plots (normal
7 % plots, semi-logplots and double-logplots).
8 %
9 % It is based on Till Tantau's PGF package.
10 %
11 % Copyright 2007/2008 by Christian Feuersänger.
12 %
13 % This program is free software: you can redistribute it and/or modify
14 % it under the terms of the GNU General Public License as published by
15 % the Free Software Foundation, either version 3 of the License, or
16 % (at your option) any later version.
17 %
18 % This program is distributed in the hope that it will be useful,
19 % but WITHOUT ANY WARRANTY; without even the implied warranty of
20 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 % GNU General Public License for more details.
22 %
23 % You should have received a copy of the GNU General Public License
24 % along with this program. If not, see <http://www.gnu.org/licenses/>.
25 %
26 %--------------------------------------------
27
28 % The lowlevel call for surface shadings. It uses a pattern type 2
29 % dictionary as fill color and has thus several things to do. This is
30 % a little bit more complicated than using the '/sh' operator (as
31 % other pgf shadings do): the surface shading must be positioned
32 % exactly at the requested coordinates, otherwise it is quite useless.
33 %
34 % Since shadings are *not* affected by changes in the canvas
35 % transformation matrix (shifts, rotations etc), it is necessary to
36 % pack the shading into a separate xform object which is then rotated
37 % and translated correctly.
38 %
39 % There is just one more transformation necessary: the shift inside of
40 % the xform. This shift is done using changes in the canvas
41 % transformation matrix and it is UNDONE in the /Matrix argument of
42 % the pattern dictionary. This last step can't be done with the /sh
43 % operator which is why I am using pattern dictionaries.
44 \def\pgfplotslibrarysurfdraw@sys{%
45 \begingroup
46 %\pgfinterruptpicture% needed?
47 \setbox\pgfutil@tempboxa=\hbox{%
48 \pgfpicture
49 \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa%
50 \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa
51 \pgfpathrectanglecorners
52 {\pgfplotslibrarysurf@corner@sw}
53 {\pgfplotslibrarysurf@corner@ne}%
54 \pgfplotslibrarysurfusepath
55 \endpgfpicture
56 }%
57 \immediate\pdfxform resources{
58 /Pattern << \pgfplots@glob@TMPa >> % write the pattern resource dictionary
59 }\pgfutil@tempboxa
60 \leavevmode
61 \pdfrefxform\pdflastxform
62 %\endpgfinterruptpicture
63 \endgroup
64 }
65
66 % To be used inside of a pgfpicture.
67 %
68 % #1: a macro name. The contents of this macro needs to be written
69 % into the pdf pattern dictionary contained in the pdf resources of
70 % the current context. The current context is either the current page
71 % or an xform object.
72 %
73 %
74 \def\pgfplotssys@do@surfshading@fillpaths#1{%
75 \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
76 \else
77 % Unfortunately, there is a bug in pdftex/luatex: if we
78 % provide a /Filter as attr, and pdftex compresses the stream,
79 % it overwrites the /Filter argument -- and the viewer cannot
80 % decode the stream. We have to deactivate compression here:
81 \pdfcompresslevel=0
82 \fi
83 \def\pgfplots@loc@TMPa{%
84 % stream length will be computed automatically
85 /ShadingType \pgfplotslibrarysurf@type\space
86 /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space
87 /BitsPerComponent \pgfplotslibrarysurf@bitspercomponent\space
88 \if5\pgfplotslibrarysurf@type
89 /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols}
90 \else
91 /BitsPerFlag 8
92 \fi
93 /ColorSpace /Device\pgfplotslibrarysurf@colorspace
94 /Decode [\pgfplotslibrarysurf@decode]
95 \ifpgfplotslibrarysurf@usecolormap
96 /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap}
97 \fi
98 \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
99 \else
100 /Filter /\pgfplotslibrarysurf@filter@decode\space
101 \fi
102 %/AntiAlias \space true
103 }%
104 %
105 % \pgfplots@loc@TMPb := final boolean luaBinaryEncoding;
106 \pgfutil@IfUndefined{directlua}{%
107 \def\pgfplots@loc@TMPb{0}%
108 }{%
109 \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
110 % ah - we have binary encoding (the standard).
111 \def\pgfplots@loc@TMPb{1}%
112 \else
113 % ah - base 16 ASCII encoding:
114 \def\pgfplots@loc@TMPb{0}%
115 \fi
116 }%
117 \if0\pgfplots@loc@TMPb
118 % no lua binary encoding. Use standard pdftex operations:
119 \immediate\pdfobj stream attr {%
120 \pgfplots@loc@TMPa
121 } {%
122 \pgfplotslibrarysurf@binarystream
123 }%
124 \edef\pgfplots@loc@TMPa{\the\pdflastobj}%
125 \else
126 % special handling for luatex binary encoding (see docs for \pgfplotsbinarytoluabinary):
127 \pgfplotsbinarytoluabinary{\pgfplotslibrarysurf@binarystream}%
128 \edef\pgfplots@loc@TMPa{%
129 \directlua{%
130 tex.print(pdf.immediateobj(\pgfplotsDQ stream\pgfplotsDQ , pgfplotsretval, \pgfplotsDQ \pgfplots@loc@TMPa\pgfplotsDQ ));
131 pgfplotsretval=nil;
132 }%
133 }%
134 \fi
135 \pgf@process{\pgfpointdiff{\pgfplotslibrarysurf@corner@sw}{\pgfkeysvalueof{/pgfplots/surf shading/anchor}}}%
136 \pgf@sys@bp@correct\pgf@x%
137 \pgf@sys@bp@correct\pgf@y%
138 \immediate\pdfobj {<<
139 /Type /Pattern
140 /PatternType 2
141 % /Matrix [\pgf@pt@aa\space\pgf@pt@ab\space\pgf@pt@ba\space\pgf@pt@bb\space\pgf@sys@tonumber\pgf@pt@x\space\pgf@sys@tonumber\pgf@pt@y]
142 % FIXME: INCORPORATE TIKZ CM
143 /Matrix [1 0 0 1 \pgf@sys@tonumber\pgf@x\space \pgf@sys@tonumber\pgf@y] %226.533 518.141]
144 %--------------------------------------------------
145 % /ExtGState
146 % <<
147 % /LW 2
148 % /OP true
149 % /OPM 1
150 % >>
151 %--------------------------------------------------
152 /Shading \pgfplots@loc@TMPa\space 0 R
153 >>}%
154 \edef#1{%
155 /pgfpatPlotsurface\pgfplotslibrarysurf@count\space \the\pdflastobj\space 0 R
156 }%
157 \pgfsys@setpatterncolored{Plotsurface\pgfplotslibrarysurf@count}%
158 \pgfplotsutil@advancestringcounter@global\pgfplotslibrarysurf@count
159 }
160
161 \endinput
162 % vi: ft=tex