[latex3-commits] [git/LaTeX3-latex3-latex3] color-multi-model: Parse multiple color model data in expressions (30a6dc7b1)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jun 16 11:01:28 CEST 2020


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

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

commit 30a6dc7b19e0e0e121e091528aa4214dbba0b464
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jun 16 10:01:28 2020 +0100

    Parse multiple color model data in expressions


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

30a6dc7b19e0e0e121e091528aa4214dbba0b464
 l3experimental/l3color/l3color.dtx                 | 30 ++++++++++++++++++++++
 l3experimental/l3color/testfiles/m3color003.lvt    | 12 +++++++++
 .../l3color/testfiles/m3color003.ptex.tlg          | 28 +++++++++++++++++++-
 l3experimental/l3color/testfiles/m3color003.tlg    | 28 +++++++++++++++++++-
 .../l3color/testfiles/m3color003.uptex.tlg         | 28 +++++++++++++++++++-
 .../l3color/testfiles/m3color003.xetex.tlg         | 28 +++++++++++++++++++-
 6 files changed, 150 insertions(+), 4 deletions(-)

diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index bbe018fdd..80481a7c5 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -956,6 +956,7 @@
 % \end{variable}
 %
 % \begin{macro}{\color_set:nn}
+% \begin{macro}{\@@_set:nnw}
 % \begin{macro}{\color_set:nnn}
 % \begin{macro}{\@@_set:nw}
 % \begin{macro}{\@@_set_loop:nw}
@@ -972,6 +973,34 @@
         \@@_parse:nN {#2} \l_@@_named_tl
         \exp_args:Nnx \@@_set_store:nn {#1}
           { \exp_after:wN \use_i:nn \l_@@_named_tl }
+        \@@_set:nnw {#1} #2 ! \s_@@_stop
+      }
+  }
+%    \end{macrocode}
+%   When setting an expression-based color, there could be multiple model
+%   data available for one or more of the input colors. Where that is true for
+%   the \emph{first} named color in an expression, we re-parse the expression
+%   when they are also parameter-based: only |cmyk|, |gray| and |rgb| make
+%   any sense here. There is a bit of a performance hit but this should be
+%   rare and taking place during set-up.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_set:nnw #1#2 ! #3 \s_@@_stop
+  {
+    \clist_map_inline:nn { cmyk , gray , rgb }
+      {
+        \prop_get:cnNT { l_@@_named_ #2 _prop } {##1} \l_@@_named_tl
+          {
+            \prop_if_in:cnF { l_@@_named_ #1 _prop } {##1}
+              {
+                \group_begin:
+                  \tl_set_eq:cN { l_@@_named_ #2_ tl } \l_@@_named_tl
+                  \@@_parse:nN {#2} \l_@@_named_tl
+                \exp_args:NNNV \group_end:
+                \tl_set:Nn \l_@@_named_tl \l_@@_named_tl
+                \prop_put:cnV { l_@@_named_ #1 _prop } {##1}
+                  \l_@@_named_tl
+              }
+          }
       }
   }
 \cs_new_protected:Npn \color_set:nnn #1#2#3
@@ -1035,6 +1064,7 @@
 % \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 a630bd159..bf34f45a2 100644
--- a/l3experimental/l3color/testfiles/m3color003.lvt
+++ b/l3experimental/l3color/testfiles/m3color003.lvt
@@ -72,6 +72,18 @@
     \color_show:n { test }
   }
 
+\TEST { Mixing~multiple~models }
+  {
+    \color_set:nnn { myrgbcmyk } { rgb / cmyk }
+      { 1 , 0 , 1 / 1 , 0 , 0 , 1 }
+    \color_set:nnn { mycmykrgb } { cmyk / rgb }
+      { 1 , 0 , 0 , 1 / 1 , 0 , 1 }
+    \color_set:nn { myexpr1 } { myrgbcmyk!30!mycmykrgb }
+    \color_show:n { myexpr1 }
+    \color_set:nn { myexpr2 } { mycmykrgb!30!myrgbcmyk }
+    \color_show:n { myexpr2 }
+  }
+
 \TEST { Showing~multiple~models }
   {
     \color_set:nnn { foo1 } { cmyk / rgb }
diff --git a/l3experimental/l3color/testfiles/m3color003.ptex.tlg b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
index fcd6e5a22..c8b5cca58 100644
--- a/l3experimental/l3color/testfiles/m3color003.ptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
@@ -89,7 +89,33 @@ The color test has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 3: Showing multiple models
+TEST 3: Mixing multiple models
+============================================================
+Defining \l__color_named_myrgbcmyk_tl on line ...
+Defining \l__color_named_myrgbcmyk_prop on line ...
+Defining \l__color_named_mycmykrgb_tl on line ...
+Defining \l__color_named_mycmykrgb_prop on line ...
+Defining \l__color_named_myexpr1_tl on line ...
+Defining \l__color_named_myexpr1_prop on line ...
+The color myexpr1 has the properties:
+>  model  =>  rgb
+>  value  =>  1 0 1
+>  rgb  =>  1 0 1
+>  cmyk  =>  1.0 0.0 0.0 1.0.
+<recently read> }
+l. ...  }
+Defining \l__color_named_myexpr2_tl on line ...
+Defining \l__color_named_myexpr2_prop on line ...
+The color myexpr2 has the properties:
+>  model  =>  cmyk
+>  value  =>  1 0 0 1
+>  cmyk  =>  1 0 0 1
+>  rgb  =>  1.0 0.0 1.0.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 4: Showing multiple models
 ============================================================
 The color foo1 has the properties:
 >  model  =>  cmyk
diff --git a/l3experimental/l3color/testfiles/m3color003.tlg b/l3experimental/l3color/testfiles/m3color003.tlg
index a39e06edc..8592e1fc5 100644
--- a/l3experimental/l3color/testfiles/m3color003.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.tlg
@@ -84,7 +84,33 @@ The color test has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 3: Showing multiple models
+TEST 3: Mixing multiple models
+============================================================
+Defining \l__color_named_myrgbcmyk_tl on line ...
+Defining \l__color_named_myrgbcmyk_prop on line ...
+Defining \l__color_named_mycmykrgb_tl on line ...
+Defining \l__color_named_mycmykrgb_prop on line ...
+Defining \l__color_named_myexpr1_tl on line ...
+Defining \l__color_named_myexpr1_prop on line ...
+The color myexpr1 has the properties:
+>  model  =>  rgb
+>  value  =>  1 0 1
+>  rgb  =>  1 0 1
+>  cmyk  =>  1.0 0.0 0.0 1.0.
+<recently read> }
+l. ...  }
+Defining \l__color_named_myexpr2_tl on line ...
+Defining \l__color_named_myexpr2_prop on line ...
+The color myexpr2 has the properties:
+>  model  =>  cmyk
+>  value  =>  1 0 0 1
+>  cmyk  =>  1 0 0 1
+>  rgb  =>  1.0 0.0 1.0.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 4: Showing multiple models
 ============================================================
 The color foo1 has the properties:
 >  model  =>  cmyk
diff --git a/l3experimental/l3color/testfiles/m3color003.uptex.tlg b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
index fcd6e5a22..c8b5cca58 100644
--- a/l3experimental/l3color/testfiles/m3color003.uptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
@@ -89,7 +89,33 @@ The color test has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 3: Showing multiple models
+TEST 3: Mixing multiple models
+============================================================
+Defining \l__color_named_myrgbcmyk_tl on line ...
+Defining \l__color_named_myrgbcmyk_prop on line ...
+Defining \l__color_named_mycmykrgb_tl on line ...
+Defining \l__color_named_mycmykrgb_prop on line ...
+Defining \l__color_named_myexpr1_tl on line ...
+Defining \l__color_named_myexpr1_prop on line ...
+The color myexpr1 has the properties:
+>  model  =>  rgb
+>  value  =>  1 0 1
+>  rgb  =>  1 0 1
+>  cmyk  =>  1.0 0.0 0.0 1.0.
+<recently read> }
+l. ...  }
+Defining \l__color_named_myexpr2_tl on line ...
+Defining \l__color_named_myexpr2_prop on line ...
+The color myexpr2 has the properties:
+>  model  =>  cmyk
+>  value  =>  1 0 0 1
+>  cmyk  =>  1 0 0 1
+>  rgb  =>  1.0 0.0 1.0.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 4: Showing multiple models
 ============================================================
 The color foo1 has the properties:
 >  model  =>  cmyk
diff --git a/l3experimental/l3color/testfiles/m3color003.xetex.tlg b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
index 1ba149d0d..aa14b90a8 100644
--- a/l3experimental/l3color/testfiles/m3color003.xetex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
@@ -84,7 +84,33 @@ The color test has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 3: Showing multiple models
+TEST 3: Mixing multiple models
+============================================================
+Defining \l__color_named_myrgbcmyk_tl on line ...
+Defining \l__color_named_myrgbcmyk_prop on line ...
+Defining \l__color_named_mycmykrgb_tl on line ...
+Defining \l__color_named_mycmykrgb_prop on line ...
+Defining \l__color_named_myexpr1_tl on line ...
+Defining \l__color_named_myexpr1_prop on line ...
+The color myexpr1 has the properties:
+>  model  =>  rgb
+>  value  =>  1 0 1
+>  rgb  =>  1 0 1
+>  cmyk  =>  1.0 0.0 0.0 1.0.
+<recently read> }
+l. ...  }
+Defining \l__color_named_myexpr2_tl on line ...
+Defining \l__color_named_myexpr2_prop on line ...
+The color myexpr2 has the properties:
+>  model  =>  cmyk
+>  value  =>  1 0 0 1
+>  cmyk  =>  1 0 0 1
+>  rgb  =>  1.0 0.0 1.0.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 4: Showing multiple models
 ============================================================
 The color foo1 has the properties:
 >  model  =>  cmyk





More information about the latex3-commits mailing list.