[latex3-commits] [git/LaTeX3-latex3-pdfresources] splitting: rewrote new-transparent to use new dvipdfmx special (ed10eda)
Ulrike Fischer
fischer at troubleshooting-tex.de
Sun Sep 6 18:44:07 CEST 2020
Repository : https://github.com/latex3/pdfresources
On branch : splitting
Link : https://github.com/latex3/pdfresources/commit/ed10edaba487cd857ccd3528ee93fdec82f6baa6
>---------------------------------------------------------------
commit ed10edaba487cd857ccd3528ee93fdec82f6baa6
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sun Sep 6 18:44:07 2020 +0200
rewrote new-transparent to use new dvipdfmx special
>---------------------------------------------------------------
ed10edaba487cd857ccd3528ee93fdec82f6baa6
newpackages/new-transparent.sty | 185 ++++++++++++++++++++--------------------
1 file changed, 92 insertions(+), 93 deletions(-)
diff --git a/newpackages/new-transparent.sty b/newpackages/new-transparent.sty
index 9d2af24..ae86091 100644
--- a/newpackages/new-transparent.sty
+++ b/newpackages/new-transparent.sty
@@ -1,107 +1,106 @@
%%
-%% 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: 2018/11/18 v1.3
-%%
-%% Copyright (C) 2007 by
-%% Heiko Oberdiek <heiko.oberdiek at googlemail.com>
-%%
-%% 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
-%% http://www.latex-project.org/lppl/lppl-1-3c.txt
-%% and the latest version of this license is in
-%% http://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".
-%%
-%% This Current Maintainer of this work is Heiko Oberdiek.
-%%
-%% 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.
+%% This is file `new-transparent.sty',
+%% base on transparent sty from Heiko Oberdiek
%%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{new-transparent}%
- [2020/04/10 v1.41 Transparency via pdfTeX's color stack (HO)]%
-\RequirePackage{ifpdf}
-\ifpdf
-\else
- \PackageWarningNoLine{transparent}{%
- Loading aborted, because pdfTeX is not running in PDF mode%
- }%
- \expandafter\endinput
-\fi
-\ifx\pdfextension\@undefined
- \let\TRP at pdfcolorstackinit\pdfcolorstackinit
- \let\TRP at pdfpageresources\pdfpageresources
- \let\TRP at pdfcolorstack\pdfcolorstack
-\else
- \def\TRP at pdfcolorstackinit {\pdffeedback colorstackinit}
- \protected\edef\TRP at pdfpageresources {\pdfvariable pageresources}
- \protected\def\TRP at pdfcolorstack {\pdfextension colorstack}
-\fi
-\ifcsname pdfcoredict_gput:nnn\endcsname
-\else
-\PackageWarningNoLine{new-transparent}{%
- Loading aborted, because pdf resource management code not found%
- }%
- \expandafter\endinput
-\fi
-
-\ExplSyntaxOn
-\pdfcoredict_gput:nnn{Page/Resources/ExtGState}{TRP1}{<</ca~1/CA~1>>}
-\cs_new_protected:Npn \__transparent_use:n #1
- {
- \tl_if_exist:cF { c__transparent_TRP#1_tl }
- {
- \pdfcoredict_gput:nnn{Page/Resources/ExtGState}{TRP#1}{<</ca~#1/CA~#1>>}
- \tl_const:cn { c__transparent_TRP#1_tl }{ /TRP#1~gs }
- }
- }
+\ProvidesExplPackage{new-transparent}%
+ {2020-09-06}{v1.42}{Transparency with color stacks (based on transparent from Heiko Oberdiek)}%
+%pdftex + luatex in pdf mode
+\sys_if_output_pdf:T
+ {
+ \bool_lazy_and:nnF {\bool_if_exist_p:N \g__pdf_Core_active_bool } { \g__pdf_Core_active_bool }
+ {
+ \PackageWarningNoLine{new-transparent}
+ {
+ Loading~aborted,~because~pdf~resource~management~code~not~found~%
+ or~not~active
+ }
+ \endinput
+ }
+ }
+\sys_if_engine_pdftex:T
+ {
+ \let\TRP at pdfcolorstackinit\tex_pdfcolorstackinit:D
+ \let\TRP at pdfcolorstack\tex_pdfcolorstack:D
+ }
-\xdef\TRP at colorstack{%
- \TRP at pdfcolorstackinit~page~direct{/TRP1~gs}%
-}
-\newcommand*{\transparent}[1]
+\sys_if_engine_luatex:T
{
- \exp_args:Nx\__transparent_use:n { \fp_eval:n{ min(max(0,#1),1)}}
- \tl_set:Nx \transparent at current { \fp_eval:n{ min(max(0,#1),1)}}
- \transparent at set
+ \def\TRP at pdfcolorstackinit {\pdffeedback~colorstackinit}
+ \protected\def\TRP at pdfcolorstack {\pdfextension~colorstack}
}
-\def\transparent at current{/TRP1 gs}
-\def\transparent at set
+\sys_if_output_pdf:T
{
- \TRP at pdfcolorstack\TRP at colorstack~push~
+ %initialize opacity 1
+ \pdfcoredict_gput:nnn{Page/Resources/ExtGState}{TRP1}{<</ca~1/CA~1>>}
+ %
+ \cs_new_protected:Npn \__transparent_use:n #1
+ {
+ \tl_if_exist:cF { c__transparent_TRP#1_tl }
+ {
+ \pdfcoredict_gput:nnn{Page/Resources/ExtGState}{TRP#1}{<</ca~#1/CA~#1>>}
+ \tl_const:cn { c__transparent_TRP#1_tl }{ /TRP#1~gs }
+ }
+ }
+ \xdef\TRP at colorstack{%
+ \TRP at pdfcolorstackinit~page~direct{/TRP1~gs}}
+ \NewDocumentCommand{\transparent} { m }
+ {
+ \exp_args:Nx\__transparent_use:n { \fp_eval:n{ min(max(0,#1),1)}}
+ \tl_set:Nx \transparent at current { \fp_eval:n{ min(max(0,#1),1)}}
+ \transparent at set
+ }
+
+ \def\transparent at current{/TRP1~gs}
+ \def\transparent at set
+ {
+ \TRP at pdfcolorstack\TRP at colorstack~push~
+ {
+ \tl_use:c { c__transparent_TRP\transparent at current _tl }
+ }
+ \aftergroup\transparent at reset
+ }
+
+ \def\transparent at reset{\TRP at pdfcolorstack\TRP at colorstack~pop\relax}
+
+ }
+
+%xetex, dvipdfmx
+\str_case_e:nnT {\g__sys_backend_tl}
+ {
+ {xetex}{}
+ {dvipdfmx}{}
+ }
+ {
+ \PackageInfo{new-transparent}{xetex~and~dvipdfmx~need~dvipdfmx~newer~than~20200901}{}
+ \NewDocumentCommand{\transparent} { m }
{
- \tl_use:c { c__transparent_TRP\transparent at current _tl }
+ \transparent at set{#1}
}
+ \def\transparent at set #1
+ {
+ \special{pdf:bxgstate~<</CA~#1/ca~#1>>}
\aftergroup\transparent at reset
+ }
+
+ \def\transparent at reset{\special{pdf:exgstate}}
+ }
+
+%warning for dvips currently missing
+% but it should at least not error
+\ProvideDocumentCommand\transparent { m }{}
+
+\NewDocumentCommand{\texttransparent}{m m}
+ {
+ \protect\leavevmode
+ \begingroup
+ \transparent{#1}
+ #2
+ \endgroup
}
-\ExplSyntaxOff
-\def\transparent at reset{%
- \TRP at pdfcolorstack\TRP at colorstack pop\relax
-}
-\newcommand*{\texttransparent}[2]{%
- \protect\leavevmode
- \begingroup
- \transparent{#1}%
- #2%
- \endgroup
-}
+
+
\endinput
%%
-%% End of file `transparent.sty'.
+%% End of file `new-transparent.sty'.
More information about the latex3-commits
mailing list.