summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/transparent/transparent.sty
blob: e7d0e5f067c67046a7879da5ab10f47f50e374c3 (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
%%
%% This is file `transparent.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% transparent.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: transparent
%% Version: 2019/11/29 v1.4
%% 
%% Copyright (C)
%%    2007 Heiko Oberdiek
%%    2016-2019 Oberdiek Package Support Group
%% 
%% 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. This version of this license is in
%%    https://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    https://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainers of this work are
%% Heiko Oberdiek and the Oberdiek Package Support Group
%% https://github.com/ho-tex/transparent/issues
%% 
%% 
%% This work consists of the main source file transparent.dtx
%% and the derived files
%%    transparent.sty, transparent.pdf, transparent.ins, transparent.drv,
%%    transparent-example.tex.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{transparent}%
  [2019/11/29 v1.4 Transparency via pdfTeX's color stack (HO)]%
\RequirePackage{iftex}
\ifpdf
\else
  \PackageWarningNoLine{transparent}{%
    Loading aborted, because pdfTeX is not running in PDF mode%
  }%
  \expandafter\endinput
\fi
\ifx\pdfextension\@undefined
  \let\TRP@pdfcolorstackinit\pdfcolorstackinit
  \let\TRP@pdfpageresources\pdfpageresources
  \let\TRP@pdfcolorstack\pdfcolorstack
\else
  \def\TRP@pdfcolorstackinit           {\pdffeedback colorstackinit}
  \protected\edef\TRP@pdfpageresources {\pdfvariable pageresources}
  \protected\def\TRP@pdfcolorstack     {\pdfextension colorstack}
\fi
\ifcsname TRP@pdfcolorstackinit\endcsname\else
  \PackageWarningNoLine{transparent}{%
    Your pdfTeX version does not support color stacks%
  }%
  \expandafter\endinput
\fi
\AtBeginDocument
 {%
   \ifcsname pgfutil@addpdfresource@extgs\endcsname
    \let\TRP@addresource\relax
    \pgfutil@addpdfresource@extgs{\TRP@list}%
   \fi
 }
\RequirePackage{auxhook}
\AddLineBeginAux{%
  \string\providecommand{\string\transparent@use}[1]{}%
}
\gdef\TRP@list{/TRP1<</ca 1/CA 1>>}
\def\transparent@use#1{%
  \@ifundefined{TRP#1}{%
    \g@addto@macro\TRP@list{%
      /TRP#1<</ca #1/CA #1>>%
    }%
    \expandafter\gdef\csname TRP#1\endcsname{/TRP#1 gs}%
  }{%
    % #1 is already known, nothing to do
  }%
}
\AtBeginDocument{%
  \TRP@addresource
  \let\transparent@use\@gobble
}
\def\TRP@addresource{%
  \begingroup
    \edef\x{\endgroup
      \TRP@pdfpageresources{%
        \the\TRP@pdfpageresources
        /ExtGState<<\TRP@list>>%
      }%
    }%
  \x
}
\newif\ifTRP@rerun
\xdef\TRP@colorstack{%
  \TRP@pdfcolorstackinit page direct{/TRP1 gs}%
}
\newcommand*{\transparent}[1]{%
  \begingroup
    \dimen@=#1\p@\relax
    \ifdim\dimen@>\p@
      \dimen@=\p@
    \fi
    \ifdim\dimen@<\z@
      \dimen@=\z@
    \fi
    \ifdim\dimen@=\p@
      \def\x{1}%
    \else
      \ifdim\dimen@=\z@
        \def\x{0}%
      \else
        \edef\x{\strip@pt\dimen@}%
        \edef\x{\expandafter\@gobble\x}%
      \fi
    \fi
    \if@filesw
      \immediate\write\@auxout{%
        \string\transparent@use{\x}%
      }%
    \fi
    \edef\x{\endgroup
      \def\noexpand\transparent@current{\x}%
    }%
  \x
  \transparent@set
}
\AtEndDocument{%
  \ifTRP@rerun
    \PackageWarningNoLine{transparent}{%
      Rerun to get transparencies right%
    }%
  \fi
}
\def\transparent@current{/TRP1 gs}
\def\transparent@set{%
  \@ifundefined{TRP\transparent@current}{%
    \global\TRP@reruntrue
  }{%
    \TRP@pdfcolorstack\TRP@colorstack push{%
      \csname TRP\transparent@current\endcsname
    }%
    \aftergroup\transparent@reset
  }%
}
\def\transparent@reset{%
  \TRP@pdfcolorstack\TRP@colorstack pop\relax
}
\newcommand*{\texttransparent}[2]{%
  \protect\leavevmode
  \begingroup
    \transparent{#1}%
    #2%
  \endgroup
}
\endinput
%%
%% End of file `transparent.sty'.