[latex3-commits] [git/LaTeX3-latex3-latex3] color-multi-model: Avoid fixed color model when setting color expresions (9f273adfe)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jun 30 15:05:35 CEST 2020


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

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

commit 9f273adfe3addedf9b8ec4bb0056d717753e52d5
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jun 30 13:49:52 2020 +0100

    Avoid fixed color model when setting color expresions


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

9f273adfe3addedf9b8ec4bb0056d717753e52d5
 l3experimental/l3color/l3color.dtx                 | 19 ++++++++++++++++-
 l3experimental/l3color/testfiles/m3color003.lvt    | 18 ++++++++++++++++
 .../l3color/testfiles/m3color003.ptex.tlg          | 24 ++++++++++++++++++++++
 l3experimental/l3color/testfiles/m3color003.tlg    | 24 ++++++++++++++++++++++
 .../l3color/testfiles/m3color003.uptex.tlg         | 24 ++++++++++++++++++++++
 .../l3color/testfiles/m3color003.xetex.tlg         | 24 ++++++++++++++++++++++
 6 files changed, 132 insertions(+), 1 deletion(-)

diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 459f70193..cdca8575b 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -995,6 +995,8 @@
 % \end{variable}
 %
 % \begin{macro}{\color_set:nn}
+% \begin{macro}{\@@_set:nnn}
+% \begin{macro}{\@@_set:nn}
 % \begin{macro}{\@@_set:nnw}
 % \begin{macro}{\color_set:nnn}
 % \begin{macro}{\@@_set_loop:nw}
@@ -1002,10 +1004,23 @@
 %   Defining named colors means working through the model list and saving
 %   both the \enquote{main} color and any equivalents in other models. Even
 %   if there is only one model, we store a |prop| as well as a |tl|, as there
-%   could be grouping weirdness, etc.
+%   could be grouping weirdness, etc. When setting using an expression,
+%   we need to avoid any fixed model issues, which is done without a group as
+%   in \pkg{l3keys}.
 %    \begin{macrocode}
 \cs_new_protected:Npn \color_set:nn #1#2
   {
+    \exp_args:NV \@@_set:nnn
+      \l_color_fixed_model_tl {#1} {#2}
+  }
+\cs_new_protected:Npn \@@_set:nnn #1#2#3
+  {
+    \tl_clear:N \l_color_fixed_model_tl
+    \@@_set:nn {#2} {#3}
+    \tl_set:Nn \l_color_fixed_model_tl {#1}
+  }
+\cs_new_protected:Npn \@@_set:nn #1#2
+  {
     \str_if_eq:nnF {#1} { . }
       {
         \@@_parse:nN {#2} \l_@@_named_tl
@@ -1096,6 +1111,8 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % A small set of colors are always defined.
 % \begin{macrocode}
diff --git a/l3experimental/l3color/testfiles/m3color003.lvt b/l3experimental/l3color/testfiles/m3color003.lvt
index 2325221b3..f0fc2867a 100644
--- a/l3experimental/l3color/testfiles/m3color003.lvt
+++ b/l3experimental/l3color/testfiles/m3color003.lvt
@@ -122,4 +122,22 @@
     \color_show:n { foo1 }
   }
   
+\TEST { Multiple~models~with~model~fixed }
+  {
+    \OMIT
+    \color_set:nnn { mycr } { cmyk / rgb }
+      { 1 , 0 , 0 , 0 / 1 , 0 , 0 }
+    \color_set:nnn { myrc } { rgb / cmyk }
+      { 1 , 0 , 0 / 1 , 0 , 0 , 0 }
+    \TIMO
+    \color_set:nn  { mixA } { myrc!50!mycr }
+    \color_show:n { mixA }
+    \tl_set:Nn \l_color_fixed_model_tl { cmyk }
+    \color_set:nn  { mixA } { myrc!50!mycr }
+    \color_show:n { mixA }
+    \tl_set:Nn \l_color_fixed_model_tl { rgb }
+    \color_set:nn  { mixA } { myrc!50!mycr }
+    \color_show:n { mixA }
+  }
+
 \END
diff --git a/l3experimental/l3color/testfiles/m3color003.ptex.tlg b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
index 4c89c4bae..da2336117 100644
--- a/l3experimental/l3color/testfiles/m3color003.ptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
@@ -162,3 +162,27 @@ The color foo1 has the properties:
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Multiple models with model fixed
+============================================================
+Defining \l__color_named_mixA_tl on line ...
+Defining \l__color_named_mixA_prop on line ...
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.tlg b/l3experimental/l3color/testfiles/m3color003.tlg
index 7eb25a0af..cd6f777f9 100644
--- a/l3experimental/l3color/testfiles/m3color003.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.tlg
@@ -157,3 +157,27 @@ The color foo1 has the properties:
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Multiple models with model fixed
+============================================================
+Defining \l__color_named_mixA_tl on line ...
+Defining \l__color_named_mixA_prop on line ...
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.uptex.tlg b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
index 4c89c4bae..da2336117 100644
--- a/l3experimental/l3color/testfiles/m3color003.uptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
@@ -162,3 +162,27 @@ The color foo1 has the properties:
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Multiple models with model fixed
+============================================================
+Defining \l__color_named_mixA_tl on line ...
+Defining \l__color_named_mixA_prop on line ...
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.xetex.tlg b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
index 2b5739085..f3bf6e112 100644
--- a/l3experimental/l3color/testfiles/m3color003.xetex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
@@ -157,3 +157,27 @@ The color foo1 has the properties:
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Multiple models with model fixed
+============================================================
+Defining \l__color_named_mixA_tl on line ...
+Defining \l__color_named_mixA_prop on line ...
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+The color mixA has the properties:
+>  model  =>  rgb
+>  rgb  =>  1 0 0
+>  cmyk  =>  1 0 0 0.
+<recently read> }
+l. ...  }
+============================================================





More information about the latex3-commits mailing list.