Debian Codegraph @

texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.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 \ifnum\luatexversion<95
29 \immediate\write-1{luatex driver of pgfplots: detected lua version \the\luatexversion; falling back to old pdftex driver^^J}%
30 \input pgflibrarypgfplots.surfshading.pgfsys-pdftex.def
31 \expandafter\endinput
32 \fi
33
34
35 % The lowlevel call for surface shadings. It uses a pattern type 2
36 % dictionary as fill color and has thus several things to do. This is
37 % a little bit more complicated than using the '/sh' operator (as
38 % other pgf shadings do): the surface shading must be positioned
39 % exactly at the requested coordinates, otherwise it is quite useless.
40 %
41 % Since shadings are *not* affected by changes in the canvas
42 % transformation matrix (shifts, rotations etc), it is necessary to
43 % pack the shading into a separate xform object which is then rotated
44 % and translated correctly.
45 %
46 % There is just one more transformation necessary: the shift inside of
47 % the xform. This shift is done using changes in the canvas
48 % transformation matrix and it is UNDONE in the /Matrix argument of
49 % the pattern dictionary. This last step can't be done with the /sh
50 % operator which is why I am using pattern dictionaries.
51 \def\pgfplotslibrarysurfdraw@sys{%
52 \begingroup
53 %\pgfinterruptpicture% needed?
54 \setbox\pgfutil@tempboxa=\hbox{%
55 \pgfpicture
56 \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa%
57 \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa
58 \pgfpathrectanglecorners
59 {\pgfplotslibrarysurf@corner@sw}
60 {\pgfplotslibrarysurf@corner@ne}%
61 \pgfplotslibrarysurfusepath
62 \endpgfpicture
63 }%
64 \immediate\saveboxresource resources{
65 /Pattern << \pgfplots@glob@TMPa >> % write the pattern resource dictionary
66 }\pgfutil@tempboxa
67 \leavevmode
68 \useboxresource\lastsavedboxresourceindex
69 %\endpgfinterruptpicture
70 \endgroup
71 }
72
73 % To be used inside of a pgfpicture.
74 %
75 % #1: a macro name. The contents of this macro needs to be written
76 % into the pdf pattern dictionary contained in the pdf resources of
77 % the current context. The current context is either the current page
78 % or an xform object.
79 %
80 %
81 \def\pgfplotssys@do@surfshading@fillpaths#1{%
82 \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
83 \else
84 % Unfortunately, there is a bug in pdftex/luatex: if we
85 % provide a /Filter as attr, and pdftex compresses the stream,
86 % it overwrites the /Filter argument -- and the viewer cannot
87 % decode the stream. We have to deactivate compression here:
88 \pdfvariable compresslevel=0
89 \fi
90 \def\pgfplots@loc@TMPa{%
91 % stream length will be computed automatically
92 /ShadingType \pgfplotslibrarysurf@type\space
93 /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space
94 /BitsPerComponent \pgfplotslibrarysurf@bitspercomponent\space
95 \if5\pgfplotslibrarysurf@type
96 /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols}
97 \else
98 /BitsPerFlag 8
99 \fi
100 /ColorSpace /Device\pgfplotslibrarysurf@colorspace
101 /Decode [\pgfplotslibrarysurf@decode]
102 \ifpgfplotslibrarysurf@usecolormap
103 /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap}
104 \fi
105 \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
106 \else
107 /Filter /\pgfplotslibrarysurf@filter@decode\space
108 \fi
109 }%
110 %
111 % \pgfplots@loc@TMPb := final boolean luaBinaryEncoding;
112 \pgfutil@IfUndefined{directlua}{%
113 \def\pgfplots@loc@TMPb{0}%
114 }{%
115 \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
116 % ah - we have binary encoding (the standard).
117 \def\pgfplots@loc@TMPb{1}%
118 \else
119 % ah - base 16 ASCII encoding:
120 \def\pgfplots@loc@TMPb{0}%
121 \fi
122 }%
123 \if0\pgfplots@loc@TMPb
124 % no lua binary encoding. Use standard pdftex operations:
125 \immediate\pdfextension obj stream attr {%
126 \pgfplots@loc@TMPa
127 } {%
128 \pgfplotslibrarysurf@binarystream
129 }%
130 \edef\pgfplots@loc@TMPa{\the\numexpr\pdffeedback lastobj\relax}%
131 \else
132 % special handling for luatex binary encoding (see docs for \pgfplotsbinarytoluabinary):
133 \pgfplotsbinarytoluabinary{\pgfplotslibrarysurf@binarystream}%
134 \edef\pgfplots@loc@TMPa{%
135 \directlua{%
136 tex.print(pdf.immediateobj(\pgfplotsDQ stream\pgfplotsDQ , pgfplotsretval, \pgfplotsDQ \pgfplots@loc@TMPa\pgfplotsDQ ));
137 pgfplotsretval=nil;
138 }%
139 }%
140 \fi
141 \pgf@process{\pgfpointdiff{\pgfplotslibrarysurf@corner@sw}{\pgfkeysvalueof{/pgfplots/surf shading/anchor}}}%
142 \pgf@sys@bp@correct\pgf@x%
143 \pgf@sys@bp@correct\pgf@y%
144 \immediate\pdfextension obj {<<
145 /Type /Pattern
146 /PatternType 2
147 % /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]
148 % FIXME: INCORPORATE TIKZ CM
149 /Matrix [1 0 0 1 \pgf@sys@tonumber\pgf@x\space \pgf@sys@tonumber\pgf@y] %226.533 518.141]
150 %--------------------------------------------------
151 % /ExtGState
152 % <<
153 % /LW 2
154 % /OP true
155 % /OPM 1
156 % >>
157 %--------------------------------------------------
158 /Shading \pgfplots@loc@TMPa\space 0 R
159 >>}%
160 \edef#1{%
161 /pgfpatPlotsurface\pgfplotslibrarysurf@count\space \the\numexpr\pdffeedback lastobj\relax\space 0 R
162 }%
163 \pgfsys@setpatterncolored{Plotsurface\pgfplotslibrarysurf@count}%
164 \pgfplotsutil@advancestringcounter@global\pgfplotslibrarysurf@count
165 }
166
167 \endinput
168 % vi: ft=tex