summaryrefslogtreecommitdiff
path: root/examples/transparency_example.ps
blob: 8609cf9e72f670ceaf97026fa0582993da83ca49 (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
%!PS
%   Postscript that uses Ghostscript extensions to do simple transparency

/PageUsesTransparency true def

systemdict /.setalphaisshape known not
{
    (\n\n%%%% WARNING: Transparency operations ignored - need to include -dALLOWPSTRANSPARENCY\n\n) print flush
    /.pushpdf14devicefilter {pop} bind def
    /.begintransparencygroup {pop pop pop pop pop} bind def
    /.endtransparencygroup {} bind def
    /.poppdf14devicefilter {} bind def
    /.setfillconstantalpha {pop} bind def
    /.setstrokeconstantalpha {pop} bind def
    /PageUsesTransparency false def
} if


<<
   /PageUsesTransparency PageUsesTransparency	% needed if we are using transparency
   /CompatibilityLevel 1.4
   /PageSpotColors 0
>> setpagedevice % in case we are going to pdfwrite

% work around rectfill mapping directly to device fill_rectangle
/rectfill {
  gsave 4 2 roll moveto 1 index 0 rlineto
  0 exch rlineto neg 0 rlineto closepath fill grestore
} bind def

0 .pushpdf14devicefilter % depth .pushpdf14devicefilter -
.5 .9 .2 setrgbcolor
0 0 300 700 rectfill

.2 .5 .9 setrgbcolor
200 100 400 400 rectfill

     << >> clippath pathbbox newpath .begintransparencygroup

     .5 .setfillconstantalpha

     .9 .3 .1 setrgbcolor

     100 200 500 500 rectfill

     .endtransparencygroup
.poppdf14devicefilter
showpage