summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3backend/l3backend-opacity.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-03-15 03:06:35 +0000
committerNorbert Preining <norbert@preining.info>2024-03-15 03:06:35 +0000
commit12679ab7d3c2a210f4123163671b532b8b55d5f9 (patch)
tree0060d13467186ad977f4e73488ee20dd6c0017ab /macros/latex/contrib/l3backend/l3backend-opacity.dtx
parent62170822e034fdd3f81de7274835d0d3b0467100 (diff)
CTAN sync 202403150306
Diffstat (limited to 'macros/latex/contrib/l3backend/l3backend-opacity.dtx')
-rw-r--r--macros/latex/contrib/l3backend/l3backend-opacity.dtx78
1 files changed, 38 insertions, 40 deletions
diff --git a/macros/latex/contrib/l3backend/l3backend-opacity.dtx b/macros/latex/contrib/l3backend/l3backend-opacity.dtx
index 6cc972f7d8..a5828bfd90 100644
--- a/macros/latex/contrib/l3backend/l3backend-opacity.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-opacity.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2024-02-20}
+% \date{Released 2024-03-14}
%
% \maketitle
%
@@ -71,9 +71,9 @@
%<*dvips>
% \end{macrocode}
%
-% \begin{macro}{\@@_backend_select:n,\@@_backend_select_aux:n}
+% \begin{macro}{\@@_backend_select:n}
% \begin{macro}{\@@_backend_fill:n, \@@_backend_stroke:n}
-% \begin{macro}{\@@_backend:nnn, \@@_backend:enn}
+% \begin{macro}{\@@_backend:nnn}
% No stack so set values directly. The need to deal with Distiller and
% Ghostscript separately means we use a common auxiliary: the two
% systems require different PostScript for transparency. This is
@@ -83,25 +83,20 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_backend_select:n #1
{
- \exp_args:Ne \@@_backend_select_aux:n
- { \fp_eval:n { min(max(0,#1),1) } }
- }
-\cs_new_protected:Npn \@@_backend_select_aux:n #1
- {
\@@_backend:nnn {#1} { fill } { ca }
\@@_backend:nnn {#1} { stroke } { CA }
}
\cs_new_protected:Npn \@@_backend_fill:n #1
{
- \@@_backend:enn
- { \fp_eval:n { min(max(0,#1),1) } }
+ \@@_backend:nnn
+ { #1 }
{ fill }
{ ca }
}
\cs_new_protected:Npn \@@_backend_stroke:n #1
{
- \@@_backend:enn
- { \fp_eval:n { min(max(0,#1),1) } }
+ \@@_backend:nnn
+ { #1 }
{ stroke }
{ CA }
}
@@ -124,7 +119,6 @@
ifelse
}
}
-\cs_generate_variant:Nn \@@_backend:nnn { e }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -143,7 +137,7 @@
% \begin{macrocode}
\bool_lazy_and:nnT
{ \cs_if_exist_p:N \pdfmanagement_if_active_p: }
- { \pdfmanagement_if_active_p:}
+ { \pdfmanagement_if_active_p: }
{
%<*luatex|pdftex>
\__kernel_color_backend_stack_init:Nnn \c_@@_backend_stack_int
@@ -157,24 +151,21 @@
%
% \begin{variable}{\l_@@_backend_fill_tl, \l_@@_backend_stroke_tl}
% We use |tl| here for speed: at the backend, this should be reasonable.
+% Both need to start off fully opaque.
% \begin{macrocode}
\tl_new:N \l_@@_backend_fill_tl
\tl_new:N \l_@@_backend_stroke_tl
+\tl_set:Nn \l_@@_backend_fill_tl { 1 }
+\tl_set:Nn \l_@@_backend_stroke_tl { 1 }
% \end{macrocode}
% \end{variable}
%
-% \begin{macro}{\@@_backend_select:n, \@@_backend_select_aux:n}
+% \begin{macro}{\@@_backend_select:n}
% \begin{macro}{\@@_backend_reset:}
-% Other than the need to evaluate the opacity as an \texttt{fp}, much the
-% same as color.
+% Much the same as color.
% \begin{macrocode}
\cs_new_protected:Npn \@@_backend_select:n #1
{
- \exp_args:Ne \@@_backend_select_aux:n
- { \fp_eval:n { min(max(0,#1),1) } }
- }
-\cs_new_protected:Npn \@@_backend_select_aux:n #1
- {
\tl_set:Nn \l_@@_backend_fill_tl {#1}
\tl_set:Nn \l_@@_backend_stroke_tl {#1}
\pdfmanagement_add:nnn { Page / Resources / ExtGState }
@@ -189,12 +180,6 @@
{ /opacity #1 ~ gs }
\group_insert_after:N \@@_backend_reset:
}
-\bool_lazy_and:nnF
- { \cs_if_exist_p:N \pdfmanagement_if_active_p: }
- { \pdfmanagement_if_active_p:}
- {
- \cs_gset_protected:Npn \@@_backend_select_aux:n #1 { }
- }
\cs_new_protected:Npn \@@_backend_reset:
{
%<*dvipdfmx|xetex>
@@ -210,26 +195,26 @@
% \end{macro}
%
% \begin{macro}{\@@_backend_fill:n, \@@_backend_stroke:n}
-% \begin{macro}{\@@_backend_fillstroke:nn, \@@_backend_fillstroke:ee}
+% \begin{macro}{\@@_backend_fill_stroke:nn}
% For separate fill and stroke, we need to work out if we need to do
% more work or if we can stick to a single setting.
% \begin{macrocode}
\cs_new_protected:Npn \@@_backend_fill:n #1
{
- \@@_backend_fill_stroke:ee
- { \fp_eval:n { min(max(0,#1),1) } }
- \l_@@_backend_stroke_tl
+ \exp_args:Nno \@@_backend_fill_stroke:nn
+ { #1 }
+ { \l_@@_backend_stroke_tl }
}
\cs_new_protected:Npn \@@_backend_stroke:n #1
{
- \@@_backend_fill_stroke:ee
- \l_@@_backend_fill_tl
- { \fp_eval:n { min(max(0,#1),1) } }
+ \exp_args:No \@@_backend_fill_stroke:nn
+ { \l_@@_backend_fill_tl }
+ { #1 }
}
\cs_new_protected:Npn \@@_backend_fill_stroke:nn #1#2
{
\str_if_eq:nnTF {#1} {#2}
- { \@@_backend_select_aux:n {#1} }
+ { \@@_backend_select:n {#1} }
{
\tl_set:Nn \l_@@_backend_fill_tl {#1}
\tl_set:Nn \l_@@_backend_stroke_tl {#2}
@@ -237,7 +222,7 @@
{ opacity.fill #1 }
{ << /ca ~ #1 >> }
\pdfmanagement_add:nnn { Page / Resources / ExtGState }
- { opacity.stroke #1 }
+ { opacity.stroke #2 }
{ << /CA ~ #2 >> }
%<*dvipdfmx|xetex>
\__kernel_backend_literal_pdf:n
@@ -249,11 +234,24 @@
\group_insert_after:N \@@_backend_reset:
}
}
-\cs_generate_variant:Nn \@@_backend_fill_stroke:nn { ee }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\@@_backend_select:n, \@@_backend_fill_stroke:nn}
+% Redefine them to stubs if pdfmanagement is either not loaded or
+% deactivated.
+% \begin{macrocode}
+\bool_lazy_and:nnF
+ { \cs_if_exist_p:N \pdfmanagement_if_active_p: }
+ { \pdfmanagement_if_active_p: }
+ {
+ \cs_gset_protected:Npn \@@_backend_select:n #1 { }
+ \cs_gset_protected:Npn \@@_backend_fill_stroke:nn #1#2 { }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</dvipdfmx|luatex|pdftex|xetex>
% \end{macrocode}
@@ -272,9 +270,9 @@
\cs_new_protected:Npn \@@_backend_fill:n #1
{ \@@_backend:nn {#1} { fill- } }
\cs_new_protected:Npn \@@_backend_stroke:n #1
- { \@@_backend:nn { {#1} } { stroke- } }
+ { \@@_backend:nn {#1} { stroke- } }
\cs_new_protected:Npn \@@_backend:nn #1#2
- { \__kernel_backend_scope:e { #2 opacity = " \fp_eval:n { min(max(0,#1),1) } " } }
+ { \__kernel_backend_scope:e { #2 opacity = " #1 " } }
% \end{macrocode}
% \end{macro}
% \end{macro}