[latex3-commits] [git/LaTeX3-latex3-latex3] color-export: Add color export "space-sep-cmyk" method (74c3c6e9e)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Jun 15 11:11:22 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : color-export
Link       : https://github.com/latex3/latex3/commit/74c3c6e9eaf8e31eb61bc168660c16c82e828cd4

>---------------------------------------------------------------

commit 74c3c6e9eaf8e31eb61bc168660c16c82e828cd4
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Jun 15 10:11:22 2020 +0100

    Add color export "space-sep-cmyk" method


>---------------------------------------------------------------

74c3c6e9eaf8e31eb61bc168660c16c82e828cd4
 l3experimental/l3color/l3color.dtx              | 48 +++++++++++++++++--------
 l3experimental/l3color/testfiles/m3color002.lvt |  2 +-
 l3experimental/l3color/testfiles/m3color002.tlg | 12 +++++++
 3 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 1688ebbf6..2af27e0a4 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -272,6 +272,8 @@
 %      of \pkg{expl3}
 %    \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
+%      values
 %    \item \texttt{space-sep-rgb} Space-separated red-green-blue values
 %      suitable for use as a PDF annotation color
 % \end{itemize}
@@ -1022,12 +1024,41 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_export:nnnNN}
+%   A generic auxiliary for cases where only one model is appropriate.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_export:nnnNN #1#2#3#4#5
+  {
+    \str_if_eq:nnTF {#2} {#1}
+      { #5 #4 #3 \s_@@_stop }
+      {
+        \@@_convert:nnnN {#2} {#1} {#3} #4
+        \exp_after:wN #5 \exp_after:wN #4
+          #4 \s_@@_stop
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_export_format_space-sep-cmyk:nnN}
+% \begin{macro}{\@@_export_space-sep-cmyk:Nw}
+%    \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} }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}
 %   {
 %     \@@_export_format_HTML:nnN          ,
 %     \@@_export_format_space-sep-rgb:nnN
 %   }
-% \begin{macro}{\@@_export_rgb:nnNN}
 % \begin{macro}
 %   {
 %     \@@_export_HTML:Nw          ,
@@ -1038,22 +1069,12 @@
 %   required, then do some simple maths.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_export_format_HTML:nnN #1#2#3
-  { \@@_export_rgb:nnNN {#1} {#2}#3 \@@_export_HTML:Nw }
+  { \@@_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_rgb:nnNN {#1} {#2} #3
+    \exp_not:N \@@_export:nnnNN { rgb } {#1} {#2} #3
       \exp_not:c { @@_export_space-sep-rgb:Nw }
   }
-\cs_new_protected:Npn \@@_export_rgb:nnNN #1#2#3#4
-  {
-    \str_if_eq:nnTF {#1} { rgb }
-      { #4 #3 #2 \s_@@_stop }
-      {
-        \@@_convert:nnnN {#1} { rgb } {#2} #3
-        \exp_after:wN #4 \exp_after:wN #3
-          #3 \s_@@_stop
-      }
-  }
 \cs_new_protected:Npn \@@_export_HTML:Nw #1#2 ~ #3 ~ #4 \s_@@_stop
   {
     \tl_set:Nx #1
@@ -1075,7 +1096,6 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
-% \end{macro}
 %
 % \subsection{Diagnostics}
 %
diff --git a/l3experimental/l3color/testfiles/m3color002.lvt b/l3experimental/l3color/testfiles/m3color002.lvt
index 4c3be2330..a2ad42cf5 100644
--- a/l3experimental/l3color/testfiles/m3color002.lvt
+++ b/l3experimental/l3color/testfiles/m3color002.lvt
@@ -54,7 +54,7 @@
 \TEST { Exporting~colors }
   {
     \clist_map_inline:nn
-      { backend , HTML , space-sep-rgb }
+      { backend , HTML , space-sep-cmyk , space-sep-rgb }
       {
         \color_export:nnN { blue } {#1} \l_tmpa_tl
         \tl_show:N \l_tmpa_tl
diff --git a/l3experimental/l3color/testfiles/m3color002.tlg b/l3experimental/l3color/testfiles/m3color002.tlg
index 078f6b1d3..cd750a052 100644
--- a/l3experimental/l3color/testfiles/m3color002.tlg
+++ b/l3experimental/l3color/testfiles/m3color002.tlg
@@ -93,6 +93,18 @@ l. ...  }
 > \l_tmpa_tl=999999.
 <recently read> }
 l. ...  }
+> \l_tmpa_tl=1 1 0 0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0 0.5 0 0.5.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0 0 0 0.4.
+<recently read> }
+l. ...  }
 > \l_tmpa_tl=0.0 0.0 1.0.
 <recently read> }
 l. ...  }





More information about the latex3-commits mailing list.