summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pgf-cmykshadings/pgfsys-cmykshadings-common-postscript.def
blob: 585e69a7a7bb6b239057436e5c933c4563681a5a (plain)
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
%%
%% This is file `pgfsys-cmykshadings-common-postscript.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pgf-cmykshadings.dtx  (with options: `common-ps-driver')
%% 
%% This is a generated file.
%% 
%% Copyright (c) 2018 David Purton <dcpurton@marshwiggle.net>
%% 
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3c of this license
%% or (at your option) any later version. The latest version of this
%% license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This work is "maintained" (as per the LPPL maintenance status)
%% by David Purton.
%% 
%% This work consists of the files pgf-cmykshadings.ins,
%% pgf-cmykshadings.dtx, README.md, and the derived files
%%   - pgf-cmykshadings.sty
%%   - pgfsys-cmykshadings-pdftex.def
%%   - pgfsys-cmykshadings-xetex.def
%%   - pgfsys-cmykshadings-luatex.def
%%   - pgfsys-cmykshadings-dvipdfmx.def
%%   - pgfsys-cmykshadings-dvipdfm.def
%%   - pgfsys-cmykshadings-dvips.def
%%   - pgfsys-cmykshadings-textures.def
%%   - pgfsys-cmykshadings-vtex.def
%%   - pgfsys-cmykshadings-common-postscript.def
%%   - pgf-cmykshadings.pdf
%% 
%% 
%% Substantial parts of the code for this package are taken from the pgf package
%% file pgfcoreshade.code.tex, along with the driver files pgfsys-*.def, copyright
%% (c) 2006 Till Tantau and then slightly modified to support CMYK and grayscale
%% shadings.
%% 
\ProvidesFile{pgfsys-cmykshadings-common-postscript.def}%
  [2018/10/24
   CMYK and grayscale shadings support for PGF PostScript driver (DCP)]
\def\pgfsys@horishading#1#2#3{%
  {%
    \pgf@parsefunc{#3}%
    \pgfmathsetlength\pgf@x{#2}%
    \pgf@xa=\pgf@x
    \pgf@sys@bp@correct{\pgf@x}%
    \pgf@y=\pgf@max
    \pgf@sys@bp@correct{\pgf@y}%
    \expandafter\xdef\csname @pgfshading#1!\endcsname{\hbox to \the\pgf@max{%
        \noexpand\vrule width0pt height\the\pgf@xa
        \noexpand\pgfsys@beginpurepicture
          \noexpand\pgfsys@rect{0pt}{0pt}{\the\pgf@max}{\the\pgf@xa}%
          \noexpand\pgfsys@clipnext
          \noexpand\pgfsys@discardpath
          \noexpand\pgfsys@invoke{\pgf@domb\space \pgf@sys@tonumber{\pgf@x}
            pgfH\pgf@shading@model\space \pgf@psfuncs\space pop}%
          \hss
        \noexpand\pgfsys@endpurepicture}}%
    \expandafter\xdef\csname @pgfshading#1@model!\endcsname{%
      \pgf@shading@model}%
  }%
}
\def\pgfsys@vertshading#1#2#3{%
  {%
    \pgf@parsefunc{#3}%
    \pgfmathsetlength\pgf@x{#2}%
    \pgf@xa=\pgf@x
    \pgf@sys@bp@correct{\pgf@x}%
    \pgf@y=\pgf@max
    \pgf@sys@bp@correct{\pgf@y}%
    \expandafter\xdef\csname @pgfshading#1!\endcsname{\hbox to\the\pgf@xa{%
        \noexpand\vrule width0pt height\the\pgf@max
        \noexpand\pgfsys@beginpurepicture
          \noexpand\pgfsys@rect{0pt}{0pt}{\the\pgf@xa}{\the\pgf@max}%
          \noexpand\pgfsys@clipnext
          \noexpand\pgfsys@discardpath
          \noexpand\pgfsys@invoke{\pgf@domb\space \pgf@sys@tonumber{\pgf@x}
            pgfV\pgf@shading@model\space \pgf@psfuncs\space pop}%
          \hss
        \noexpand\pgfsys@endpurepicture}}%
    \expandafter\xdef\csname @pgfshading#1@model!\endcsname{%
      \pgf@shading@model}%
  }%
}
\def\pgfsys@radialshading#1#2#3{%
  {%
    \pgf@parsefunc{#3}%
    \pgf@process{#2}%
    \pgf@sys@bp@correct{\pgf@x}%
    \pgf@sys@bp@correct{\pgf@y}%
    \pgf@xa=2\pgf@max
    \pgf@sys@bp@correct{\pgf@max}%
    \advance\pgf@x by \pgf@max
    \advance\pgf@y by \pgf@max
    \expandafter\xdef\csname @pgfshading#1!\endcsname{\hbox to \the\pgf@xa{%
        \noexpand\vrule width0pt height\the\pgf@xa
        \noexpand\pgfsys@beginpurepicture
          \noexpand\pgfsys@invoke{%
            \pgf@domb\space \pgf@sys@tonumber{\pgf@y}
            \pgf@sys@tonumber{\pgf@x}
            \pgf@sys@tonumber{\pgf@max} pgfR1\pgf@shading@model\space
            \pgf@psfuncs\space \pgf@firstcolor\space \pgf@doma\space
            pgfR2\pgf@shading@model}%
          \hss
        \noexpand\pgfsys@endpurepicture}}%
    \expandafter\xdef\csname @pgfshading#1@model!\endcsname{%
      \pgf@shading@model}%
  }%
}
\def\pgfsys@functionalshading#1#2#3#4{%
  {%
    \pgf@process{#2}%
    \pgf@xa=\pgf@x
    \pgf@ya=\pgf@y
    \pgf@process{#3}%
    \pgf@xb=\pgf@x
    \pgf@yb=\pgf@y
    \advance\pgf@x by-\pgf@xa
    \advance\pgf@y by-\pgf@ya
    \pgf@sys@bp@correct{\pgf@xa}%
    \pgf@sys@bp@correct{\pgf@ya}%
    \pgf@sys@bp@correct{\pgf@xb}%
    \pgf@sys@bp@correct{\pgf@yb}%
    \pgf@xc=-\pgf@xa
    \pgf@yc=-\pgf@ya
    \expandafter\xdef\csname @pgfshading#1!\endcsname{%
      \hbox to\the\pgf@x{\vbox to\the\pgf@y{\vfil
          \noexpand\pgfsys@beginpurepicture
          \noexpand\pgfsys@invoke{%
            \pgf@sys@tonumber{\pgf@xc} \pgf@sys@tonumber{\pgf@yc} translate
            1.1 setlinewidth [] 0 setdash 0 setlinecap
            /pgfproc {#4} bind def
            \pgf@sys@tonumber{\pgf@ya} 1 \pgf@sys@tonumber{\pgf@yb}
            {
              \pgf@sys@tonumber{\pgf@xa} 1 \pgf@sys@tonumber{\pgf@xb}
              { 1 index 2 copy pgfproc \pgf@shading@ps@device\space
                moveto 1.1 0 rlineto stroke }
              for
              pop
            }
            for
          }%
        \noexpand\pgfsys@endpurepicture
      }\hfil}%
    }%
    \expandafter\xdef\csname @pgfshading#1@model!\endcsname{%
      \pgf@shading@model}%
  }%
}
\g@addto@macro\pgfsys@atbegindocument{%
  \pgf@sys@postscript@header{/pgfHrgb { pgfH } bind def}%
  \pgf@sys@postscript@header{/pgfVrgb { pgfV } bind def}%
  \pgf@sys@postscript@header{/pgfR1rgb { pgfR1 } bind def}%
  \pgf@sys@postscript@header{/pgfR2rgb { pgfR2 } bind def}%
  \pgf@sys@postscript@header{/pgfHcmyk{
      /pgfheight exch def 0.75 setlinewidth [] 0 setdash
      /pgfshade {pgfAcmyk} def /pgfdir { dup 0 moveto
        dup 6 index lineto } bind def} bind def}%
  \pgf@sys@postscript@header{/pgfVcmyk{
      /pgfheight exch def 0.75 setlinewidth [] 0 setdash
      /pgfshade {pgfAcmyk} def /pgfdir { dup 0 exch moveto dup 6 index
        exch lineto } bind def} bind def}%
  \pgf@sys@postscript@header{/pgfAcmyk{
      /pgfdiff 10 index round cvi 10 index round cvi sub 2 mul 1 add def
      3 index 8 index sub pgfdiff div % put cyan-step on stack
      3 index 8 index sub pgfdiff div % put magenta-step on stack
      3 index 8 index sub pgfdiff div % put yellow-step on stack
      3 index 8 index sub pgfdiff div % put black-step on stack
      pgfheight 12 index 12 index 12 index 12 index 18 index
      pgfdiff {
        4 index 4 index 4 index 4 index setcmykcolor % Set color
        pgfdir
        stroke
        5 -1 roll 9 index add % cyan += inccyan
        5 -1 roll 8 index add % magenta += incmagenta
        5 -1 roll 7 index add % yellow += incyellow
        5 -1 roll 6 index add % black += incblack
        5 -1 roll .5 sub % x += 0.5
      } repeat
      mark 19 1 roll cleartomark exch pop % leave only start x on stack
    }bind def }%
  \pgf@sys@postscript@header{/pgfR1cmyk{
      newpath dup dup dup 0 360 arc clip newpath
      dup /pgfendx exch def
      /pgfendy exch def
      0.875 setlinewidth
      [] 0 setdash
      /pgfshade {pgfRcmyk} def
      /pgfstartx exch def
      /pgfstarty exch def
      /pgfdiffx pgfendx pgfstartx sub def
      /pgfdiffy pgfendy pgfstarty sub def
      dup /pgfdomb exch def
    }bind def }%
  \pgf@sys@postscript@header{/pgfR2cmyk{
      newpath 0.5 add pgfcircx pgfcircy 3 2 roll 0 360 arc
      setcmykcolor fill pop}bind def }%
  \pgf@sys@postscript@header{/pgfRcmyk{
      /pgfdiff 10 index round cvi 10 index round cvi sub 4 mul 1 add def
      /pgfcircx pgfstartx 11 index pgfdiffx pgfdomb div mul add def
      /pgfcircy pgfstarty 11 index pgfdiffy pgfdomb div mul add def
      /pgfcircxe pgfstartx 10 index pgfdiffx pgfdomb div mul add def
      /pgfcircye pgfstarty 10 index pgfdiffy pgfdomb div mul add def
      /pgfxstep pgfcircxe pgfcircx sub pgfdiff div def
      /pgfystep pgfcircye pgfcircy sub pgfdiff div def
      3 index 8 index sub pgfdiff div % put cyan-step on stack
      3 index 8 index sub pgfdiff div % put magenta-step on stack
      3 index 8 index sub pgfdiff div % put yellow-step on stack
      3 index 8 index sub pgfdiff div % put black-step on stack
      11 index 11 index 11 index 11 index 17 index
      pgfdiff {
        4 index 4 index 4 index 4 index setcmykcolor % Set color
        pgfcircx pgfcircy 2 index 0 360 arc closepath
        stroke
        5 -1 roll 8 index add % cyan += inccyan
        5 -1 roll 7 index add % magenta += incmagenta
        5 -1 roll 6 index add % yellow += incyellow
        5 -1 roll 5 index add % black += incblack
        5 -1 roll .25 sub % x += 0.25
        /pgfcircx pgfcircx pgfxstep add def
        /pgfcircy pgfcircy pgfystep add def
      } repeat
      mark 18 1 roll cleartomark exch pop % leave only start x on stack
    }bind def}%
  \pgf@sys@postscript@header{/pgfHgray{
      /pgfheight exch def 0.75 setlinewidth [] 0 setdash
      /pgfshade {pgfAgray} def /pgfdir { dup 0 moveto
        dup 3 index lineto } bind def} bind def}%
  \pgf@sys@postscript@header{/pgfVgray{
      /pgfheight exch def 0.75 setlinewidth [] 0 setdash
      /pgfshade {pgfAgray} def /pgfdir { dup 0 exch moveto dup 3 index
        exch lineto } bind def} bind def}%
  \pgf@sys@postscript@header{/pgfAgray{
      /pgfdiff 4 index round cvi 4 index round cvi sub 2 mul 1 add def
      dup 2 index sub pgfdiff div % put gray-step on stack
      pgfheight 3 index 6 index
      pgfdiff {
        1 index setgray % Set color
        pgfdir
        stroke
        exch 3 index add % gray += incgray
        exch .5 sub % x += 0.5
      } repeat
      mark 7 1 roll cleartomark exch pop % leave only start x on stack
    }bind def }%
  \pgf@sys@postscript@header{/pgfR1gray{
      newpath dup dup dup 0 360 arc clip newpath
      dup /pgfendx exch def
      /pgfendy exch def
      0.875 setlinewidth
      [] 0 setdash
      /pgfshade {pgfRgray} def
      /pgfstartx exch def
      /pgfstarty exch def
      /pgfdiffx pgfendx pgfstartx sub def
      /pgfdiffy pgfendy pgfstarty sub def
      dup /pgfdomb exch def
    }bind def }%
  \pgf@sys@postscript@header{/pgfR2gray{
      newpath 0.5 add pgfcircx pgfcircy 3 2 roll 0 360 arc
      setgray fill pop}bind def }%
  \pgf@sys@postscript@header{/pgfRgray{
      /pgfdiff 4 index round cvi 4 index round cvi sub 4 mul 1 add def
      /pgfcircx pgfstartx 5 index pgfdiffx pgfdomb div mul add def
      /pgfcircy pgfstarty 5 index pgfdiffy pgfdomb div mul add def
      /pgfcircxe pgfstartx 4 index pgfdiffx pgfdomb div mul add def
      /pgfcircye pgfstarty 4 index pgfdiffy pgfdomb div mul add def
      /pgfxstep pgfcircxe pgfcircx sub pgfdiff div def
      /pgfystep pgfcircye pgfcircy sub pgfdiff div def
      dup 2 index sub pgfdiff div % put gray-step on stack
      2 index 5 index
      pgfdiff {
        1 index setgray % Set color
        pgfcircx pgfcircy 2 index 0 360 arc closepath
        stroke
        exch 2 index add % gray += incgray
        exch .25 sub % x += 0.25
        /pgfcircx pgfcircx pgfxstep add def
        /pgfcircy pgfcircy pgfystep add def
      } repeat
      mark 6 1 roll cleartomark exch pop % leave only start x on stack
    }bind def}%
}
%% 
%%
%% End of file `pgfsys-cmykshadings-common-postscript.def'.