Debian Codegraph @

texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-pdf-via-dvi.def

raw
1 % Copyright 2019 by Till Tantau
2 % CMYK and grayscale shadings adaptation copyright 2019 by David Purton
3 %
4 % This file may be distributed and/or modified
5 %
6 % 1. under the LaTeX Project Public License and/or
7 % 2. under the GNU Public License.
8 %
9 % See the file doc/generic/pgf/licenses/LICENSE for more details.
10
11 \ProvidesFileRCS{pgfsys-common-pdf-via-dvi.def}
12
13 % Common driver commands for all drivers that produce pdf via the
14 % detour of a dvi file
15
16 % For unique object name:
17 \newcount\pgfsys@objnum\pgfsys@objnum\@ne
18
19 % Hboxes
20
21 \def\pgfsys@beginpurepicture{\special{pdf: content q}}
22
23
24 \def\pgfsys@imagesuffixlist{.pdf:.jpg:.jpeg:.png:}
25 \def\pgfsys@horishading#1#2#3{%
26 {%
27 \pgf@parsefunc{#3}%
28 \pgf@process{\pgfpoint{\pgf@max}{#2}}%
29 \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: beginxobj @pgfshade\the\pgfsys@objnum\space width \the\pgf@max\space height \the\pgf@y}}}\@temp%
30 \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: put @resources <<
31 /Shading << /Sh << /ShadingType 2
32 /ColorSpace \pgf@shading@device\space
33 /Domain [\pgf@pdfparseddomain]
34 /Coords [\pgf@doma\space0 \pgf@domb\space0]
35 /Function \pgf@pdfparsedfunction
36 /Extend [false false] >> >> >>}}}\@temp% <<
37 \pgfutil@insertatbegincurrentpage{\special{pdf: content /Sh sh}%
38 \special{pdf: endxobj}}%
39 \xdef\pgfutil@tempa{%
40 \hbox to\the\pgf@max{\vbox to#2{\vfil\special{pdf: usexobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
41 }%
42 \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
43 \global\advance\pgfsys@objnum\@ne
44 }
45 \def\pgfsys@vertshading#1#2#3{%
46 {%
47 \pgf@parsefunc{#3}%
48 \pgf@process{\pgfpoint{\pgf@max}{#2}}%
49 \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: beginxobj @pgfshade\the\pgfsys@objnum\space width \the\pgf@y\space height \the\pgf@max\space}}}\@temp%
50 \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: put @resources <<
51 /Shading << /Sh << /ShadingType 2
52 /ColorSpace \pgf@shading@device\space
53 /Domain [\pgf@pdfparseddomain]
54 /Coords [0 \pgf@doma\space0 \pgf@domb]
55 /Function \pgf@pdfparsedfunction
56 /Extend [false false] >> >> >>}}}\@temp% <<
57 \pgfutil@insertatbegincurrentpage{\special{pdf: content /Sh sh}%
58 \special{pdf: endxobj}}%
59 \xdef\pgfutil@tempa{%
60 \hbox to#2{\vbox to\the\pgf@max{\vfil\special{pdf: usexobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
61 }%
62 \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
63 \global\advance\pgfsys@objnum\@ne
64 }
65 \def\pgfsys@radialshading#1#2#3{%
66 {%
67 \pgf@parsefunc{#3}%
68 \pgf@process{#2}%
69 \pgf@xa=\pgf@x%
70 \pgf@ya=\pgf@y%
71 \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
72 \advance\pgf@xa by \pgf@x\relax%
73 \advance\pgf@ya by \pgf@y\relax%
74 \pgf@sys@bp@correct{\pgf@x}%
75 \pgf@sys@bp@correct{\pgf@y}%
76 \pgf@sys@bp@correct{\pgf@xa}%
77 \pgf@sys@bp@correct{\pgf@ya}%
78 \pgfutil@tempdima=2\pgf@max\relax%
79 \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: beginxobj @pgfshade\the\pgfsys@objnum\space width \the\pgfutil@tempdima\space height \the\pgfutil@tempdima}}}\@temp%
80 \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: put @resources <<
81 /Shading << /Sh << /ShadingType 3
82 /ColorSpace \pgf@shading@device\space
83 /Domain [\pgf@pdfparseddomain]
84 /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb]
85 /Function \pgf@pdfparsedfunction
86 /Extend [true false] >> >> >>}}}\@temp% <<
87 \pgfutil@insertatbegincurrentpage{\special{pdf: content /Sh sh}%
88 \special{pdf: endxobj}}%
89 \xdef\pgfutil@tempa{%
90 \hbox to\the\pgfutil@tempdima{\vbox to\the\pgfutil@tempdima{\vfil\special{pdf: usexobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
91 }%
92 \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
93 \global\advance\pgfsys@objnum\@ne
94 }%
95
96 \def\pgf@sys@pdf@dvi@tracker{
97 \def\pgfsys@markposition##1{%
98 \pdfsavepos%
99 \edef\pgf@temp{##1}%
100 \expandafter\write\expandafter\pgfutil@auxout\expandafter{%
101 \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\pdflastxpos}{\the\pdflastypos}}%
102 }
103 \def\pgfsyspdfmark##1##2##3{%
104 \expandafter\gdef\csname pgf@sys@pdf@mark@pos@##1\endcsname{\pgfqpoint{##2sp}{##3sp}}%
105 }
106 \def\pgfsys@getposition##1##2{%
107 \edef\pgf@marshal{\let\noexpand##2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@##1\endcsname}%
108 \pgf@marshal%
109 }
110 \def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfpointorigin}
111 }
112
113
114
115 %
116 % Resource management
117 %
118
119 \newif\ifpgf@sys@pdf@colorspaces@exists
120 \newif\ifpgf@sys@pdf@patterns@exists
121 \newif\ifpgf@sys@pdf@extgs@exists
122 \newif\ifpgf@sys@pdf@colorspaces@created
123 \newif\ifpgf@sys@pdf@patterns@created
124 \newif\ifpgf@sys@pdf@extgs@created
125 \newif\ifpgf@sys@pdf@any@resources
126
127 \def\pgf@sys@setuppdfresources@plain{%
128 % This command will setup pdf resource in plain and in latex
129 % mode. ConTeXt has its own handler
130 \pgfutil@insertatbegineverypage{%
131 \pgf@sys@pdf@any@resourcesfalse%
132 \ifpgf@sys@pdf@extgs@exists%
133 \pgf@sys@pdf@any@resourcestrue%
134 \ifpgf@sys@pdf@extgs@created \else \special{pdf: obj @pgfextgs <<>>} \global\pgf@sys@pdf@extgs@createdtrue \fi% <<
135 \fi%
136 \ifpgf@sys@pdf@colorspaces@exists%
137 \pgf@sys@pdf@any@resourcestrue%
138 \ifpgf@sys@pdf@colorspaces@created \else \special{pdf: obj @pgfcolorspaces <<>>} \global\pgf@sys@pdf@colorspaces@createdtrue \fi% <<
139 \fi%
140 \ifpgf@sys@pdf@patterns@exists%
141 \pgf@sys@pdf@any@resourcestrue%
142 \ifpgf@sys@pdf@patterns@created \else \special{pdf: obj @pgfpatterns <<>>} \global\pgf@sys@pdf@patterns@createdtrue \fi% <<
143 \fi%
144 \ifpgf@sys@pdf@any@resources%
145 \special{pdf: put @resources <<
146 \ifpgf@sys@pdf@extgs@exists /ExtGState @pgfextgs \fi
147 \ifpgf@sys@pdf@patterns@exists /Pattern @pgfpattern \fi
148 \ifpgf@sys@pdf@colorspaces@exists /ColorSpace @pgfcolorspaces \fi
149 >>}% <<
150 \fi%
151 }
152 \def\pgf@sys@addpdfresource@extgs@plain##1{%
153 \global\pgf@sys@pdf@extgs@existstrue%
154 \pgfutil@insertatbegincurrentpage{\special{pdf: put @pgfextgs << ##1 >>}}% <<
155 }
156 \def\pgf@sys@addpdfresource@colorspaces@plain##1{%
157 \global\pgf@sys@pdf@colorspaces@existstrue%
158 \pgfutil@insertatbegincurrentpage{\special{pdf: put @pgfcolorspaces << ##1 >>}}% <<
159 }
160 \def\pgf@sys@addpdfresource@patterns@plain##1{%
161 \global\pgf@sys@pdf@patterns@existstrue%
162 \pgfutil@insertatbegincurrentpage{\special{pdf: put @pgfpatterns << ##1 >>}}% <<
163 }
164 }
165 \pgfutil@setuppdfresources % possibly call the above
166
167
168 \endinput
169
170 %%% Local Variables:
171 %%% mode: latex
172 %%% End: