[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add tests for Separation/DeviceN export (0150ae3b3)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Sep 24 12:06:43 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/0150ae3b3bad38dd55f1df733c62cfc48a3e0ebc

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

commit 0150ae3b3bad38dd55f1df733c62cfc48a3e0ebc
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Sep 24 10:38:33 2020 +0100

    Add tests for Separation/DeviceN export


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

0150ae3b3bad38dd55f1df733c62cfc48a3e0ebc
 l3experimental/l3color/l3color.dtx              | 64 ++++++++++++++++++-------
 l3experimental/l3color/testfiles/m3color002.lvt | 34 +++++++++++++
 l3experimental/l3color/testfiles/m3color002.tlg | 40 ++++++++++++++++
 3 files changed, 120 insertions(+), 18 deletions(-)

diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index ea663c5e8..697b4c2c8 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -1888,14 +1888,16 @@
 %   }
 % \begin{macro}{\@@_model_devicen_tranform:nnn}
 % \begin{macro}[EXP]{\@@_model_devicen_colorant:n}
-% \begin{macro}{\@@_model_devicen_convert:nnnn}
-% \begin{macro}[EXP]{\@@_model_devicen_convert:n}
+% \begin{macro}{\@@_model_devicen_convert:nnn}
 % \begin{macro}
 %   {
 %     \@@_model_devicen_convert_cmyk:n ,
 %     \@@_model_devicen_convert_gray:n ,
 %     \@@_model_devicen_convert_rgb:n
 %   }
+% \begin{macro}{\@@_model_devicen_convert:nnnn}
+% \begin{macro}[EXP]{\@@_model_devicen_convert:n, \@@_model_devicen_convert_aux:n}
+% \begin{macro}[EXP]{\@@_model_devicen_convert:w}
 % \begin{macro}[EXP]{\@@_convert_devicen_cmyk:nnnnw}
 % \begin{macro}[EXP]{\@@_convert_devicen_cmyk:nnnnnnnnn}
 % \begin{macro}[EXP]{\@@_convert_devicen_cmyk_aux:nnnnw}
@@ -2003,7 +2005,7 @@
       }
     \use:c { @@_model_ #4 _white: }
     \@@_model_devicen_init:nnn {#1} {#2} {#3}
-    \@@_model_devicen_convert:nnnn {#4} {#2} {#1} {#3}
+    \@@_model_devicen_convert:nnn {#4} {#2} {#3}
   }
 %    \end{macrocode}
 %   For short lists of DeviceN colors, wee can use hand-tuned parsing. This
@@ -2217,6 +2219,28 @@
 %   to other parameter-based spaces. Essentially the approach is exactly the same
 %   as the PostScript, just expressed in \TeX{} terms.
 %    \begin{macrocode}
+\cs_new_protected:Npn \@@_model_devicen_convert:nnn #1#2#3
+  {
+    \use:c { @@_model_devicen_convert_ #2 :nn } {#1} {#3}
+  }
+\cs_new_protected:Npn \@@_model_devicen_convert_cmyk:nn #1#2
+  {
+    \@@_model_convert:nnn {#1} { cmyk } { gray }
+    \@@_model_convert:nnn {#1} { cmyk } { rgb }
+    \@@_model_devicen_convert:nnnn {#1} { cmyk } { 4 } {#2}
+  }
+\cs_new_protected:Npn \@@_model_devicen_convert_gray:nn #1#2
+  {
+    \@@_model_convert:nnn {#1} { gray } { cmyk }
+    \@@_model_convert:nnn {#1} { gray } { rgb }
+    \@@_model_devicen_convert:nnnn {#1} { gray } { 1 } {#2}
+  }
+\cs_new_protected:Npn \@@_model_devicen_convert_rgb:nn #1#2
+  {
+    \@@_model_convert:nnn {#1} { rgb } { cmyk }
+    \@@_model_convert:nnn {#1} { rgb } { gray }
+    \@@_model_devicen_convert:nnnn {#1} { rgb } { 3 } {#2}
+  }
 \cs_new_protected:Npn \@@_model_devicen_convert:nnnn #1#2#3#4
   {
     \cs_new:cpx { @@_convert_ #1 _ #2 :w } ##1 \s_@@_stop
@@ -2227,26 +2251,28 @@
           \clist_map_function:nN {#4} \@@_model_devicen_convert:n
           \exp_not:N \s_@@_stop
       }
-   \use:c { @@_model_devicen_convert_ #2 :n } {#1}
   }
 \cs_new:Npn \@@_model_devicen_convert:n #1
   {
-    { \prop_item:Nn \g_@@_alternative_values_prop {#1} }
-  }
-\cs_new_protected:Npn \@@_model_devicen_convert_cmyk:n #1
-  {
-    \@@_model_convert:nnn {#1} { cmyk } { gray }
-    \@@_model_convert:nnn {#1} { cmyk } { rgb }
-  }
-\cs_new_protected:Npn \@@_model_devicen_convert_gray:n #1
-  {
-    \@@_model_convert:nnn {#1} { gray } { cmyk }
-    \@@_model_convert:nnn {#1} { gray } { rgb }
+    { 
+      \exp_args:Ne \@@_model_devicen_convert_aux:n 
+        { \prop_item:Nn \g_@@_alternative_values_prop {#1} }
+    }
   }
-\cs_new_protected:Npn \@@_model_devicen_convert_rgb:n #1
+\cs_new:Npn \@@_model_devicen_convert_aux:n #1
+  { \@@_model_devicen_convert_aux:w #1 , , , , \s_@@_stop }
+\cs_new:Npn \@@_model_devicen_convert_aux:w #1 , #2 , #3 , #4 , #5 \s_@@_stop
   {
-    \@@_model_convert:nnn {#1} { rgb } { cmyk }
-    \@@_model_convert:nnn {#1} { rgb } { gray }
+    {#1}
+    \tl_if_blank:nF {#2}
+      {
+        {#2}
+        \tl_if_blank:nF {#3}
+          {
+            {#3}
+            \tl_if_blank:nF {#4} { {#4} }
+          }
+      }
   }
 \cs_new:Npn \@@_convert_devicen_cmyk:nnnnw
   #1#2#3#4#5 ~ #6 \s_@@_mark #7#8 \s_@@_stop
@@ -2357,6 +2383,8 @@
 % \end{macro}
 % \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 18c4d4f40..d66b75122 100644
--- a/l3experimental/l3color/testfiles/m3color002.lvt
+++ b/l3experimental/l3color/testfiles/m3color002.lvt
@@ -103,4 +103,38 @@
     \color_export:nnnN { gray } { 0.6 } { mumble } \l_tmpa_tl
   }
 
+
+\TEST { Exporting~complex~models }
+  {
+    \OMIT
+    \color_model_new:nnn { BarToneCMYK } { Separation }
+      {
+        name = BarTone~555~GN , 
+        alternative-model = cmyk ,
+        alternative-values = { 0.8 , 0.2 , 0.5 , 0.3 }
+      }
+    \color_model_new:nnn { BarToneCIELAB } { Separation }
+      {
+        name = BarTone~555~GN , 
+        alternative-model = CIELAB ,
+        alternative-values = {50, -30, -40},
+        illuminant = d65
+      }
+    \color_model_new:nnn { TwoUp } { DeviceN }
+      {
+        names = { BarToneCMYK , black }
+      }
+    \TIMO
+    \clist_map_inline:nn
+      { backend , HTML , space-sep-cmyk , space-sep-rgb }
+      {
+        \color_export:nnnN { BarToneCMYK } { 0.6 } {#1} \l_tmpa_tl
+        \tl_show:N \l_tmpa_tl
+        \color_export:nnnN { BarToneCIELAB } { 0.6 } {#1} \l_tmpa_tl
+        \tl_show:N \l_tmpa_tl
+        \color_export:nnnN { TwoUp } { 0.6 , 0.4 } {#1} \l_tmpa_tl
+        \tl_show:N \l_tmpa_tl
+      }
+  }
+
 \END
diff --git a/l3experimental/l3color/testfiles/m3color002.tlg b/l3experimental/l3color/testfiles/m3color002.tlg
index 976be52f0..0c8654164 100644
--- a/l3experimental/l3color/testfiles/m3color002.tlg
+++ b/l3experimental/l3color/testfiles/m3color002.tlg
@@ -252,3 +252,43 @@ l. ...  }
 LaTeX has been asked to export a color in format 'mumble', but this has never
 been defined.
 ============================================================
+============================================================
+TEST 8: Exporting complex models
+============================================================
+> \l_tmpa_tl={BarToneCMYK}{0.6}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl={BarToneCIELAB}{0.6}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl={TwoUp}{0.6 0.4}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=57B285.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=FFFFFF.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=57B285.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.48 0.12 0.3 0.18.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0 0 0 1.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.48 0.12 0.3 0.18.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.34 0.7 0.52.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1 1 1.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.34 0.7 0.52.
+<recently read> }
+l. ...  }
+============================================================





More information about the latex3-commits mailing list.