[latex3-commits] [git/LaTeX3-latex3-latex3] color-multi-model: Correct mixing with gray model (783e38047)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Jul 1 13:34:52 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : color-multi-model
Link       : https://github.com/latex3/latex3/commit/783e3804755cbf54d0399a0eca06b71148afc607

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

commit 783e3804755cbf54d0399a0eca06b71148afc607
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Jul 1 12:34:52 2020 +0100

    Correct mixing with gray model


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

783e3804755cbf54d0399a0eca06b71148afc607
 l3experimental/l3color/l3color.dtx                 | 55 ++++++++++++----------
 l3experimental/l3color/testfiles/m3color001.lvt    | 10 +++-
 .../l3color/testfiles/m3color001.ptex.tlg          | 28 +++++++++--
 l3experimental/l3color/testfiles/m3color001.tlg    | 28 +++++++++--
 .../l3color/testfiles/m3color001.uptex.tlg         | 28 +++++++++--
 .../l3color/testfiles/m3color001.xetex.tlg         | 28 +++++++++--
 6 files changed, 132 insertions(+), 45 deletions(-)

diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index cdca8575b..a6a59bd3e 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -491,6 +491,7 @@
 % \begin{macro}{\@@_parse_loop_init:Nnn}
 % \begin{macro}{\@@_parse_loop:w}
 % \begin{macro}{\@@_parse_loop:nn}
+% \begin{macro}{\@@_parse_gray:n, \@@_parse_std:n}
 % \begin{macro}{\@@_parse_break:w}
 % \begin{macro}{\@@_parse_end:}
 % \begin{macro}[aux, EXP]{\@@_parse_mix:Nnnn, \@@_parse_mix:NVVn}
@@ -641,29 +642,9 @@
         \@@_extract:nNN {#2} \l_@@_next_model_tl \l_@@_next_value_tl
         \tl_if_eq:NNF \l_@@_model_tl \l_@@_next_model_tl
           {
-            \str_if_eq:VnT \l_@@_model_tl { gray }
-              {
-                \use:x
-                  {
-                    \tl_set:Nn \exp_not:N \l_@@_model_tl
-                      { \l_@@_next_model_tl }
-                    \tl_set:Nn \exp_not:N \l_@@_value_tl
-                      { \l_@@_next_value_tl }
-                    \tl_set:Nn \exp_not:N \l_next_@@_model_tl
-                      { \l_@@_model_tl }
-                    \tl_set:Nn \exp_not:N \l_next_@@_value_tl
-                      { \l_@@_value_tl }
-                  }
-              }
-            \prop_get:cVNF { l_@@_named_ #2 _prop }
-              \l_@@_model_tl
-              \l_@@_next_value_tl
-              {
-                \@@_convert:VVN
-                  \l_@@_next_model_tl
-                  \l_@@_model_tl
-                  \l_@@_next_value_tl
-              }
+            \str_if_eq:VnTF \l_@@_model_tl { gray }
+              { \@@_parse_gray:n {#2} }
+              { \@@_parse_std:n {#2} }
           }
         \tl_set:Nx \l_@@_value_tl
           {
@@ -677,6 +658,30 @@
         \@@_parse_break:w
       }
   }
+%    \end{macrocode}
+%   The \texttt{gray} model needs special handling: the models need to be
+%   swapped: we do that using a dedicated function.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_parse_gray:n #1
+  {
+    \tl_set_eq:NN \l_@@_model_tl \l_@@_next_model_tl
+    \exp_args:NnV \@@_convert:nnN { gray } \l_@@_next_model_tl
+      \l_@@_value_tl
+    \prop_get:cVN { l_@@_named_ #1 _prop } \l_@@_model_tl
+      \l_@@_next_value_tl
+  }
+\cs_new_protected:Npn \@@_parse_std:n #1
+  {
+    \prop_get:cVNF { l_@@_named_ #1 _prop }
+      \l_@@_model_tl
+      \l_@@_next_value_tl
+        {
+          \@@_convert:VVN
+            \l_@@_next_model_tl
+            \l_@@_model_tl
+            \l_@@_next_value_tl
+        }
+  }
 \cs_new_protected:Npn \@@_parse_break:w #1 \@@_parse_end: { }
 \cs_new_protected:Npn \@@_parse_end: { }
 %    \end{macrocode}
@@ -726,6 +731,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}[EXP]
 %   {
@@ -1054,7 +1060,8 @@
                   \@@_parse:nN {#2} \l_@@_internal_tl
                 \exp_args:NNNV \group_end:
                 \tl_set:Nn \l_@@_internal_tl \l_@@_internal_tl
-                \prop_put:cnx { l_@@_named_ #1 _prop } {##1}
+                \prop_put:cxx { l_@@_named_ #1 _prop }
+                  { \@@_model:N \l_@@_internal_tl }
                   { \@@_values:N \l_@@_internal_tl }
               }
           }
diff --git a/l3experimental/l3color/testfiles/m3color001.lvt b/l3experimental/l3color/testfiles/m3color001.lvt
index 5a72a4f13..ae5ab8d90 100644
--- a/l3experimental/l3color/testfiles/m3color001.lvt
+++ b/l3experimental/l3color/testfiles/m3color001.lvt
@@ -1,5 +1,5 @@
 %
-% Copyright (C) 2017,2018 The LaTeX3 Project
+% Copyright (C) 2017,2018,2020 The LaTeX3 Project
 %
 
 \documentclass{minimal}
@@ -64,6 +64,14 @@
     \color_show:n { foo4 }
   }
 
+\TEST { Mixing~with~the~gray~model }
+  {
+    \color_set:nn { mywhitemixA } { white!40!red }
+    \color_show:n { mywhitemixA }
+    \color_set:nn { mywhitemixB } { red!60!white }
+    \color_show:n { mywhitemixB }
+  }
+
 \TEST { Copying~named~colors }
   {
     \color_set:nn { foo1 } { cyan!25!magenta }
diff --git a/l3experimental/l3color/testfiles/m3color001.ptex.tlg b/l3experimental/l3color/testfiles/m3color001.ptex.tlg
index e5e9bf62f..23c161318 100644
--- a/l3experimental/l3color/testfiles/m3color001.ptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color001.ptex.tlg
@@ -103,7 +103,25 @@ The color foo4 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 5: Copying named colors
+TEST 5: Mixing with the gray model
+============================================================
+Defining \l__color_named_mywhitemixA_tl on line ...
+Defining \l__color_named_mywhitemixA_prop on line ...
+The color mywhitemixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0.4 0.4.
+<recently read> }
+l. ...  }
+Defining \l__color_named_mywhitemixB_tl on line ...
+Defining \l__color_named_mywhitemixB_prop on line ...
+The color mywhitemixB has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0.4 0.4.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 6: Copying named colors
 ============================================================
 The color foo2 has the properties:
 >  model  =>  cmyk
@@ -112,7 +130,7 @@ The color foo2 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 6: Copying the current color
+TEST 7: Copying the current color
 ============================================================
 Defining \l__color_named_foo_tl on line ...
 Defining \l__color_named_foo_prop on line ...
@@ -123,7 +141,7 @@ The color foo has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 7: Selecting colors
+TEST 8: Selecting colors
 ============================================================
 > \box...=
 \hbox(6.94444+0.0)x22.50005
@@ -179,7 +197,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 8: Fixing the model
+TEST 9: Fixing the model
 ============================================================
 > \box...=
 \hbox(6.94444+0.0)x22.50005
@@ -235,7 +253,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 9: Showing colors
+TEST 10: Showing colors
 ============================================================
 The color unknown is undefined.
 > .
diff --git a/l3experimental/l3color/testfiles/m3color001.tlg b/l3experimental/l3color/testfiles/m3color001.tlg
index 9debf4224..b04f747cd 100644
--- a/l3experimental/l3color/testfiles/m3color001.tlg
+++ b/l3experimental/l3color/testfiles/m3color001.tlg
@@ -103,7 +103,25 @@ The color foo4 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 5: Copying named colors
+TEST 5: Mixing with the gray model
+============================================================
+Defining \l__color_named_mywhitemixA_tl on line ...
+Defining \l__color_named_mywhitemixA_prop on line ...
+The color mywhitemixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0.4 0.4.
+<recently read> }
+l. ...  }
+Defining \l__color_named_mywhitemixB_tl on line ...
+Defining \l__color_named_mywhitemixB_prop on line ...
+The color mywhitemixB has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0.4 0.4.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 6: Copying named colors
 ============================================================
 The color foo2 has the properties:
 >  model  =>  cmyk
@@ -112,7 +130,7 @@ The color foo2 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 6: Copying the current color
+TEST 7: Copying the current color
 ============================================================
 Defining \l__color_named_foo_tl on line ...
 Defining \l__color_named_foo_prop on line ...
@@ -123,7 +141,7 @@ The color foo has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 7: Selecting colors
+TEST 8: Selecting colors
 ============================================================
 > \box...=
 \hbox(6.94444+0.0)x22.50005
@@ -175,7 +193,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 8: Fixing the model
+TEST 9: Fixing the model
 ============================================================
 > \box...=
 \hbox(6.94444+0.0)x22.50005
@@ -227,7 +245,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 9: Showing colors
+TEST 10: Showing colors
 ============================================================
 The color unknown is undefined.
 > .
diff --git a/l3experimental/l3color/testfiles/m3color001.uptex.tlg b/l3experimental/l3color/testfiles/m3color001.uptex.tlg
index e5e9bf62f..23c161318 100644
--- a/l3experimental/l3color/testfiles/m3color001.uptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color001.uptex.tlg
@@ -103,7 +103,25 @@ The color foo4 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 5: Copying named colors
+TEST 5: Mixing with the gray model
+============================================================
+Defining \l__color_named_mywhitemixA_tl on line ...
+Defining \l__color_named_mywhitemixA_prop on line ...
+The color mywhitemixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0.4 0.4.
+<recently read> }
+l. ...  }
+Defining \l__color_named_mywhitemixB_tl on line ...
+Defining \l__color_named_mywhitemixB_prop on line ...
+The color mywhitemixB has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0.4 0.4.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 6: Copying named colors
 ============================================================
 The color foo2 has the properties:
 >  model  =>  cmyk
@@ -112,7 +130,7 @@ The color foo2 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 6: Copying the current color
+TEST 7: Copying the current color
 ============================================================
 Defining \l__color_named_foo_tl on line ...
 Defining \l__color_named_foo_prop on line ...
@@ -123,7 +141,7 @@ The color foo has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 7: Selecting colors
+TEST 8: Selecting colors
 ============================================================
 > \box...=
 \hbox(6.94444+0.0)x22.50005
@@ -179,7 +197,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 8: Fixing the model
+TEST 9: Fixing the model
 ============================================================
 > \box...=
 \hbox(6.94444+0.0)x22.50005
@@ -235,7 +253,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 9: Showing colors
+TEST 10: Showing colors
 ============================================================
 The color unknown is undefined.
 > .
diff --git a/l3experimental/l3color/testfiles/m3color001.xetex.tlg b/l3experimental/l3color/testfiles/m3color001.xetex.tlg
index 91637d967..29e5c4941 100644
--- a/l3experimental/l3color/testfiles/m3color001.xetex.tlg
+++ b/l3experimental/l3color/testfiles/m3color001.xetex.tlg
@@ -103,7 +103,25 @@ The color foo4 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 5: Copying named colors
+TEST 5: Mixing with the gray model
+============================================================
+Defining \l__color_named_mywhitemixA_tl on line ...
+Defining \l__color_named_mywhitemixA_prop on line ...
+The color mywhitemixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0.4 0.4.
+<recently read> }
+l. ...  }
+Defining \l__color_named_mywhitemixB_tl on line ...
+Defining \l__color_named_mywhitemixB_prop on line ...
+The color mywhitemixB has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0.4 0.4.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 6: Copying named colors
 ============================================================
 The color foo2 has the properties:
 >  model  =>  cmyk
@@ -112,7 +130,7 @@ The color foo2 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 6: Copying the current color
+TEST 7: Copying the current color
 ============================================================
 Defining \l__color_named_foo_tl on line ...
 Defining \l__color_named_foo_prop on line ...
@@ -123,7 +141,7 @@ The color foo has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 7: Selecting colors
+TEST 8: Selecting colors
 ============================================================
 > \box...=
 \hbox(6.94444+0.0)x22.50005
@@ -175,7 +193,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 8: Fixing the model
+TEST 9: Fixing the model
 ============================================================
 > \box...=
 \hbox(6.94444+0.0)x22.50005
@@ -227,7 +245,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 9: Showing colors
+TEST 10: Showing colors
 ============================================================
 The color unknown is undefined.
 > .





More information about the latex3-commits mailing list.