Debian Codegraph @

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

raw
1 %--------------------------------------------
2 %
3 % Package pgfplots
4 %
5 % Provides a user-friendly interface to create function plots (normal
6 % plots, semi-logplots and double-logplots).
7 %
8 % It is based on Till Tantau's PGF package.
9 %
10 % Copyright 2007-2012 by Christian Feuersänger.
11 %
12 % This program is free software: you can redistribute it and/or modify
13 % it under the terms of the GNU General Public License as published by
14 % the Free Software Foundation, either version 3 of the License, or
15 % (at your option) any later version.
16 %
17 % This program is distributed in the hope that it will be useful,
18 % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 % GNU General Public License for more details.
21 %
22 % You should have received a copy of the GNU General Public License
23 % along with this program. If not, see <http://www.gnu.org/licenses/>.
24 %
25 %--------------------------------------------
26
27 \newcount\c@pgfplotslibrarysurf@streamlen
28
29 \def\pgfplotslibrarysurf@initstream{%
30 % binary doesn't work due to limitations of DVI.
31 % We NEED an ASCII encoding.
32 %
33 \def\pgfplotslibrarysurf@filter@encode{ASCIIHexEncode}%
34 \def\pgfplotslibrarysurf@filter@decode{ASCIIHexDecode}%
35 \global\c@pgfplotslibrarysurf@streamlen=0 %
36 }%
37
38 \def\pgfplotslibrarysurf@advancestreamlen#1{%
39 \global\advance\c@pgfplotslibrarysurf@streamlen by#1\relax
40 }%
41
42 % The lowlevel call for surface shadings. It uses a pattern type 2
43 % dictionary as fill color and has thus several things to do. This is
44 % a little bit more complicated than using the '/sh' operator (as
45 % other pgf shadings do): the surface shading must be positioned
46 % exactly at the requested coordinates, otherwise it is quite useless.
47 %
48 % Since shadings are *not* affected by changes in the canvas
49 % transformation matrix (shifts, rotations etc), it is necessary to
50 % pack the shading into a separate xform object which is then rotated
51 % and translated correctly.
52 %
53 % There is just one more transformation necessary: the shift inside of
54 % the xform. This shift is done using changes in the canvas
55 % transformation matrix and it is UNDONE in the /Matrix argument of
56 % the pattern dictionary. This last step can't be done with the /sh
57 % operator which is why I am using pattern dictionaries.
58 \def\pgfplotslibrarysurfdraw@sys{%
59 \begingroup
60 \setbox\pgfutil@tempboxa=\hbox
61 {%
62 \pgfpicture
63 \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa%
64 \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa
65 \pgfpathrectanglecorners
66 {\pgfplotslibrarysurf@corner@sw}
67 {\pgfplotslibrarysurf@corner@ne}%
68 \pgfplotslibrarysurfusepath
69 \endpgfpicture
70 }%
71 %
72 % NOTE : this code was broken due to some driver in pgf. I fixed
73 % that and brought the fix with pgfplots.
74 %
75 % for some reason, dvipdfmx requires to move the XObject
76 % declaration out of the current stream.
77 % Perhaps I should rephrase and say that for some reason, this appears to be
78 % unnecessary for pdftex.
79 %
80 % FIXME : this might have N^2 time due to "box-append"!
81 \pgfutil@insertatbegincurrentpagefrombox
82 {%
83 \special{pdf: bxobj @pgfplotsX\pgfplotslibrarysurf@count\space
84 width \the\wd\pgfutil@tempboxa\space height \the\ht\pgfutil@tempboxa}%
85 \special{pdf: put @resources
86 % write the pattern resource dictionary of the XObject
87 % (only!):
88 << /Pattern << \pgfplots@glob@TMPa >> >>
89 }%
90 %
91 % no need to add the pattern to the page's resource list!
92 % we do not need this:
93 %\pgfutil@addpdfresource@patterns{\pgfplots@glob@TMPa}%
94 \leavevmode
95 \box\pgfutil@tempboxa
96 \special{pdf: exobj}%
97 }%
98 \endgroup
99 \special{pdf: uxobj @pgfplotsX\pgfplotslibrarysurf@count\space}%
100 \pgfplotsutil@advancestringcounter@global\pgfplotslibrarysurf@count
101 }
102
103 % To be used inside of a pgfpicture.
104 %
105 % #1: a macro name. The contents of this macro needs to be written
106 % into the pdf pattern dictionary contained in the pdf resources of
107 % the current context. The current context is either the current page
108 % or an xform object.
109 %
110 %
111 \def\pgfplotssys@do@surfshading@fillpaths#1{%
112 % it contain the BINARY bytes. But it is ASCII encoded, see docs of ASCIIHexEncode.
113 \global\multiply\c@pgfplotslibrarysurf@streamlen by2 %
114 %
115 \def\pgfplots@loc@TMPa{%
116 % stream length will be computed automatically
117 /ShadingType \pgfplotslibrarysurf@type\space
118 /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space
119 /BitsPerComponent \pgfplotslibrarysurf@bitspercomponent\space
120 \if5\pgfplotslibrarysurf@type
121 /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols}
122 \else
123 /BitsPerFlag 8
124 \fi
125 /ColorSpace /Device\pgfplotslibrarysurf@colorspace
126 /Decode [\pgfplotslibrarysurf@decode]
127 \ifpgfplotslibrarysurf@usecolormap
128 /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap}
129 \fi
130 \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
131 \else
132 /Filter /\pgfplotslibrarysurf@filter@decode\space
133 \fi
134 /Length \the\c@pgfplotslibrarysurf@streamlen
135 }%
136 %
137 \pgf@process{\pgfpointdiff{\pgfplotslibrarysurf@corner@sw}{\pgfkeysvalueof{/pgfplots/surf shading/anchor}}}%
138 \pgf@sys@bp@correct\pgf@x%
139 \pgf@sys@bp@correct\pgf@y%
140 %
141 %\noexpand\pgfutil@insertatbegincurrentpagefrombox
142 {%
143 \special{pdf: object @pgfplotsShading\pgfplotslibrarysurf@count\space << \pgfplots@loc@TMPa >>
144 stream^^J%
145 \pgfplotslibrarysurf@binarystream
146 endstream
147 }%
148 \special{pdf: close @pgfplotsShading\pgfplotslibrarysurf@count\space }%
149 \special{pdf: object @pgfplotsPattern\pgfplotslibrarysurf@count\space <<
150 /Type /Pattern
151 /PatternType 2
152 % /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]
153 % FIXME: INCORPORATE TIKZ CM
154 /Matrix [1 0 0 1 \pgf@sys@tonumber\pgf@x\space \pgf@sys@tonumber\pgf@y] %226.533 518.141]
155 %--------------------------------------------------
156 % /ExtGState
157 % <<
158 % /LW 2
159 % /OP true
160 % /OPM 1
161 % >>
162 %--------------------------------------------------
163 /Shading @pgfplotsShading\pgfplotslibrarysurf@count
164 >>
165 }%
166 \special{pdf: close @pgfplotsPattern\pgfplotslibrarysurf@count\space }%
167 }%
168 \edef#1{%
169 /pgfplotsSurface\pgfplotslibrarysurf@count\space @pgfplotsPattern\pgfplotslibrarysurf@count
170 }%
171 %
172 % I inlined \pgfsys@setpatterncolored here because it appears to be
173 % natural - and in order to bring this driver to PGF 2.00 (which
174 % would fail otherwise)
175 \pgfsysprotocol@literal{/Pattern cs /pgfplotsSurface\pgfplotslibrarysurf@count\space scn}%
176 }
177
178 \endinput
179 % vi: ft=tex