From 0f8acc6eb1940c147de1fb17b307dad849cb3915 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Sat, 8 May 2021 03:01:09 +0000
Subject: CTAN sync 202105080301

---
 macros/latex/contrib/l3kernel/l3color.dtx | 144 +++++++++++++++++-------------
 1 file changed, 80 insertions(+), 64 deletions(-)

(limited to 'macros/latex/contrib/l3kernel/l3color.dtx')

diff --git a/macros/latex/contrib/l3kernel/l3color.dtx b/macros/latex/contrib/l3kernel/l3color.dtx
index b3fd3cfa7a..1b59215b8a 100644
--- a/macros/latex/contrib/l3kernel/l3color.dtx
+++ b/macros/latex/contrib/l3kernel/l3color.dtx
@@ -43,7 +43,7 @@
 %    }^^A
 % }
 %
-% \date{Released 2021-02-18}
+% \date{Released 2021-05-07}
 %
 % \maketitle
 %
@@ -299,7 +299,7 @@
 %   \meta{value(s)} for filling or stroking.
 % \end{function}
 %
-% \begin{variable}{color.sc}
+% \begin{variable}[module = color]{color.sc}
 %   When using \texttt{dvips}, this PostScript variables hold the stroke color.
 % \end{variable}
 %
@@ -342,6 +342,10 @@
 %      model, the second containing space-separated values appropriate
 %      for the model; this is the format required by backend functions
 %      of \pkg{expl3}
+%    \item \texttt{comma-sep-cmyk} Comma-separated cyan-magenta-yellow-black
+%      values
+%    \item \texttt{comma-sep-rgb} Comma-separated red-green-blue values
+%      suitable for use as a PDF annotation color
 %    \item \texttt{HTML} Uppercase two-digit hexadecimal values, expressing
 %      a red-green-blue color; the digits are \emph{not} separated
 %    \item \texttt{space-sep-cmyk} Space-separated cyan-magenta-yellow-black
@@ -1554,38 +1558,61 @@
 %
 % \begin{variable}
 %   {
+%     \c_@@_export_comma-sep-cmyk_tl ,
+%     \c_@@_export_comma-sep-rgb_tl  ,
 %     \c_@@_export_HTML_tl           ,
 %     \c_@@_export_space-sep-cmyk_tl ,
 %     \c_@@_export_space-sep-rgb_tl
 %   }
 %    \begin{macrocode}
+\tl_const:cn { c_@@_export_comma-sep-cmyk_tl } { cmyk }
+\tl_const:cn { c_@@_export_comma-sep-rgb_tl } { rgb }
 \tl_const:Nn \c_@@_export_HTML_tl { rgb }
 \tl_const:cn { c_@@_export_space-sep-cmyk_tl } { cmyk }
 \tl_const:cn { c_@@_export_space-sep-rgb_tl } { rgb }
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{macro}{\@@_export_format_space-sep-cmyk:nnN}
-% \begin{macro}{\@@_export_space-sep-cmyk:Nw}
+% \begin{macro}
+%   {
+%     \@@_export_format_comma-sep-cmyk:nnN ,
+%     \@@_export_format_comma-sep-rgb:nnN  ,
+%     \@@_export_format_space-sep-cmyk:nnN ,
+%     \@@_export_format_space-sep-rgb:nnN
+%   }
 %    \begin{macrocode}
-\cs_new_protected:cpx { @@_export_format_space-sep-cmyk:nnN } #1#2#3
-  {
-    \exp_not:N \@@_export:nnnNN { cmyk } {#1} {#2} #3
-      \exp_not:c { @@_export_space-sep-cmyk:Nw }
-  }
-\cs_new_protected:cpn { @@_export_space-sep-cmyk:Nw } #1#2 \s_@@_stop
-  { \tl_set:Nx #1 {#2} }
+\group_begin:
+  \cs_set_protected:Npn \@@_tmp:w #1#2
+    {
+      \cs_new_protected:cpx { @@_export_format_ #1 :nnN } ##1##2##3
+        {
+          \exp_not:N \@@_export:nnnNN {#2} {##1} {##2} ##3
+            \exp_not:c { @@_export_ #1 :Nw }
+        }
+    }
+  \@@_tmp:w { comma-sep-cmyk } { cmyk }
+  \@@_tmp:w { comma-sep-rgb }  { rgb }
+  \@@_tmp:w { HTML }           { rgb }
+  \@@_tmp:w { space-sep-cmyk } { cmyk }
+  \@@_tmp:w { space-sep-rgb }  { rgb }
+
+\group_end:
 %    \end{macrocode}
 % \end{macro}
+%
+% \begin{macro}{\@@_export_space-sep-cmyk:Nw, \@@_export_comma-sep-cmyk:Nw}
+%    \begin{macrocode}
+\cs_new_protected:cpn { @@_export_comma-sep-cmyk:Nw }
+  #1#2 ~ #3 ~ #4 ~ #5 \s_@@_stop
+  { \tl_set:Nn #1 { #2 , #3 , #4 , #5 } }
+\cs_new_protected:cpn { @@_export_space-sep-cmyk:Nw } #1#2 \s_@@_stop
+  { \tl_set:Nn #1 {#2} }
+%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}
 %   {
-%     \@@_export_format_HTML:nnN          ,
-%     \@@_export_format_space-sep-rgb:nnN
-%   }
-% \begin{macro}
-%   {
+%     \@@_export_comma-sep-rgb:Nw ,
 %     \@@_export_HTML:Nw          ,
 %     \@@_export_space-sep-rgb:Nw
 %   }
@@ -1593,13 +1620,8 @@
 %   \textsc{html} values must be given in |rgb|: we force conversion if
 %   required, then do some simple maths.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_export_format_HTML:nnN #1#2#3
-  { \@@_export:nnnNN { rgb } {#1} {#2}#3 \@@_export_HTML:Nw }
-\cs_new_protected:cpx { @@_export_format_space-sep-rgb:nnN } #1#2#3
-  {
-    \exp_not:N \@@_export:nnnNN { rgb } {#1} {#2} #3
-      \exp_not:c { @@_export_space-sep-rgb:Nw }
-  }
+\cs_new_protected:cpn { @@_export_comma-sep-rgb:Nw } #1#2 ~ #3 ~ #4 \s_@@_stop
+  { \tl_set:Nx #1 { #2 , #3 , #4 } }
 \cs_new_protected:Npn \@@_export_HTML:Nw #1#2 ~ #3 ~ #4 \s_@@_stop
   {
     \tl_set:Nx #1
@@ -1616,11 +1638,10 @@
       { \int_to_Hex:n { \fp_to_int:n { #1 * 255 } } }
   }
 \cs_new_protected:cpn { @@_export_space-sep-rgb:Nw } #1#2 \s_@@_stop
-  { \tl_set:Nx #1 {#2} }
+  { \tl_set:Nn #1 {#2} }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
-% \end{macro}
 %
 % \subsection{Additional color models}
 %
@@ -1750,6 +1771,35 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_model_init:nn}
+%   A shared auxiliary to do the basics of setting up a new model: reserve a
+%   number, create a fallback and white-equivalent, set up links to the backend.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_model_init:nnn #1#2#3
+  {
+    \int_gincr:N \g_@@_model_int
+    \tl_const:cx { c_@@_fallback_ #1 _tl }
+      { 1 \prg_replicate:nn { #2 - 1 } { ~ 1 } }
+    \clist_map_inline:nn { fill , stroke , select }
+      {
+        \cs_new_protected:cpx { @@_backend_ ##1 _ #1 :n } ####1
+          {
+            \exp_not:c { @@_backend_ ##1 _ #3 :nn }
+              { color \int_use:N \g_@@_model_int } {####1}
+          }
+      }
+    \cs_new_protected:cpx { @@_model_ #1 _white: }
+      {
+        \prop_put:Nnn \exp_not:N \l_@@_named_white_prop {#1}
+          { 0 \prg_replicate:nn { #2 - 1 } { ~ 0 } }
+        \exp_not:N \int_compare:nNnF { \tex_currentgrouplevel:D } = 0
+          { \group_insert_after:N \exp_not:c { @@_model_ #1 _ white: } }
+      }
+    \use:c { @@_model_ #1 _white: }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\@@_model_separation:n}
 % \begin{macro}{\@@_model_separation:nn}
 % \begin{macro}{\@@_model_separation:nnn}
@@ -1829,31 +1879,15 @@
 \cs_new_protected:Npn \@@_model_separation:w
   #1 , #2 , #3 , #4 , #5 \s_@@_stop #6#7#8
   {
-    \int_gincr:N \g_@@_model_int
-    \tl_const:cn { c_@@_fallback_ #6 _tl } { 1 }
+    \@@_model_init:nnn {#6} { 1 } { separation }
     \cs_new_eq:cN { @@_parse_mix_ #6 :nw } \@@_parse_mix_gray:nw
     \cs_new:cpn { @@_parse_model_ #6 :w } ##1 , ##2 \s_@@_stop
       { {#6} { \@@_parse_number:n {##1} } }
-    \clist_map_inline:nn { fill , stroke , select }
-      {
-        \cs_new_protected:cpx { @@_backend_ ##1 _ #6 :n } ####1
-          {
-            \exp_not:c { @@_backend_ ##1 _ separation:nn }
-              { color \int_use:N \g_@@_model_int } {####1}
-          }
-      }
     \use:c { @@_model_separation_ #8 :nnnnnn }
       {#6} {#7} {#1} {#2} {#3} {#4}
     \prop_gput:Nnn \g_@@_alternative_model_prop {#6} {#8}
     \prop_gput:Nnx \g_@@_colorants_prop {#6}
       { \str_convert_pdfname:n {#7} }
-    \cs_new_protected:cpx { @@_model_ #6 _white: }
-      {
-        \prop_put:Nnn \exp_not:N \l_@@_named_white_prop {#6} { 0 }
-        \exp_not:N \int_compare:nNnF { \tex_currentgrouplevel:D } = 0
-          { \group_insert_after:N \exp_not:c { @@_model_ #6 _ white: } }
-      }
-    \use:c { @@_model_ #6 _white: }
   }
 \cs_new_protected:Npn \@@_model_separation_cmyk:nnnnnn #1#2#3#4#5#6
   {
@@ -2086,35 +2120,17 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_model_devicen:nnnn #1#2#3#4
   {
-    \int_gincr:N \g_@@_model_int
-    \tl_const:cx { c_@@_fallback_ #4 _tl }
-      { \prg_replicate:nn {#1} { 1 ~ } }
+    \@@_model_init:nnn {#4} {#1} { devicen }
     \cs_if_exist_use:cF { @@_model_devicen_parse_ #1 :nn }
       { \@@_model_devicen_parse_generic:nn }
         {#4} {#1}
-    \clist_map_inline:nn { fill , stroke , select }
-      {
-        \cs_new_protected:cpx { @@_backend_ ##1 _ #4 :n } ####1
-          {
-            \exp_not:c { @@_backend_ ##1 _ devicen:nn }
-              { color \int_use:N \g_@@_model_int } {####1}
-          }
-      }
-    \cs_new_protected:cpx { @@_model_ #4 _white: }
-      {
-        \prop_put:Nnn \exp_not:N \l_@@_named_white_prop {#4}
-          { \prg_replicate:nn {#1} { 0 ~ } }
-        \exp_not:N \int_compare:nNnF { \tex_currentgrouplevel:D } = 0
-          { \group_insert_after:N \exp_not:c { @@_model_ #4 _ white: } }
-      }
-    \use:c { @@_model_ #4 _white: }
     \@@_model_devicen_init:nnn {#1} {#2} {#3}
     \@@_model_devicen_convert:nnn {#4} {#2} {#3}
   }
 %    \end{macrocode}
-%   For short lists of DeviceN colors, wee can use hand-tuned parsing. This
+%   For short lists of DeviceN colors, we can use hand-tuned parsing. This
 %   lines up with other models, where we allow for up to four components. For
-%   larger spaces,. rather than limit artificially, we use a somewhat slow
+%   larger spaces, rather than limit artificially, we use a somewhat slow
 %   approach based on open-ended commas-lists.
 %    \begin{macrocode}
 \cs_new_protected:cpn { @@_model_devicen_parse_1:nn } #1#2
@@ -2499,7 +2515,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \color_show:n #1
   {
-    \msg_show:nnxxxx { LaTeX / color } { show }
+    \__kernel_msg_show:nnxxxx { color } { show }
       {#1}
       {
         \@@_if_defined:nT {#1}
-- 
cgit v1.2.3

