[latex3-commits] [git/LaTeX3-latex3-latex3] color-models: Allow on-the-fly creation of tints (9835287cf)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Jun 25 09:46:39 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : color-models
Link       : https://github.com/latex3/latex3/commit/9835287cf5f37c901493b6a6c17d716b9ac0cfcb

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

commit 9835287cf5f37c901493b6a6c17d716b9ac0cfcb
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Jun 25 08:46:39 2020 +0100

    Allow on-the-fly creation of tints


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

9835287cf5f37c901493b6a6c17d716b9ac0cfcb
 l3experimental/l3color/l3color.dtx                 | 15 ++++++++++++++-
 l3experimental/l3color/testfiles/m3color003.lvt    | 11 +++++++++++
 .../l3color/testfiles/m3color003.ptex.tlg          | 22 ++++++++++++++++++++++
 l3experimental/l3color/testfiles/m3color003.tlg    | 22 ++++++++++++++++++++++
 .../l3color/testfiles/m3color003.uptex.tlg         | 22 ++++++++++++++++++++++
 .../l3color/testfiles/m3color003.xetex.tlg         | 22 ++++++++++++++++++++++
 6 files changed, 113 insertions(+), 1 deletion(-)

diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 175e70bdd..a6e74e245 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -1383,25 +1383,38 @@
 %    \end{macrocode}
 %   As each alternative space leads to a different requirement for conversion,
 %   and as there are only a small number of choices, we manually split the data
-%   and then set up.
+%   and then set up. Notice that mixing tints is really just the same
+%   as mixing \texttt{gray}. The \texttt{white} color is special, as it allows
+%   tints to be adjusted without an additional color space. To make sure the
+%   data is set for that at all group levels, we need to work on a per-level
+%   basis.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_model_separation:nnw
   #1#2 #3 , #4 , #5 , #6 , #7 \s_@@_stop
   {
     \cs_if_exist:cTF { @@_model_separation_ #2 :nnnnn }
       {
+        \cs_new_eq:cN  { @@_parse_mix_ #1 :nw } \@@_parse_mix_gray:nw
         \cs_new:cpn { @@_parse_model_ #1 :w } ##1 , ##2 \s_@@_stop
           { {#1} { \@@_parse_number:n {##1} } }
         \cs_new_protected:cpn { @@_backend_ #1 :n } ##1
           { \@@_backend_family_separation:nn {#1} {##1} }
         \use:c { @@_model_separation_ #2 :nnnnn }
           {#1} {#3} {#4} {#5} {#6}
+        \cs_new_protected:cpx { @@_model_ #1 _ white: }
+          {
+            \prop_put:Nnn \exp_not:N \l_@@_named_white_prop {#1} { 0 }
+            \exp_not:N \int_compare:nNnF { \tex_currentgrouplevel:D } = 0
+              { \group_insert_after:N \exp_not:c { @@_model_ #1 _ white: } }
+          }
+        \use:c { @@_model_ #1 _ white: }
       }
       {
         \__kernel_msg_error:nnn { color }
           { separation-requires-alternative } {#1}
       }
   }
+
 \cs_new_protected:Npn \@@_model_separation_cmyk:nnnnn #1#2#3#4#5
   {
     \cs_new:cpn { @@_convert_ #1 _cmyk:w } ##1 ~ ##2 \s_@@_stop
diff --git a/l3experimental/l3color/testfiles/m3color003.lvt b/l3experimental/l3color/testfiles/m3color003.lvt
index 04c60348d..c4ea79c4b 100644
--- a/l3experimental/l3color/testfiles/m3color003.lvt
+++ b/l3experimental/l3color/testfiles/m3color003.lvt
@@ -152,4 +152,15 @@
     \tl_show:N \l_tmpa_tl
   }
 
+\TEST { Mixing~separations }
+  {
+    \OMIT
+    \color_set:nnn { fooCMYK } { BarToneCMYK } { 1.0 }
+    \TIMO
+    \color_set:nn { foo } { fooCMYK!35 }
+    \color_show:n { foo }
+    \color_set:nn { foo } { fooCMYK!55!white }
+    \color_show:n { foo }
+  }
+
 \END
diff --git a/l3experimental/l3color/testfiles/m3color003.ptex.tlg b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
index 2b6aec37c..52b661dd0 100644
--- a/l3experimental/l3color/testfiles/m3color003.ptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
@@ -153,11 +153,13 @@ l. ...  }
 ============================================================
 TEST 6: Creating new models
 ============================================================
+Defining \__color_parse_mix_BarToneCMYK:nw on line ...
 Defining \__color_parse_model_BarToneCMYK:w on line ...
 Defining \__color_backend_BarToneCMYK:n on line ...
 Defining \__color_convert_BarToneCMYK_cmyk:w on line ...
 Defining \__color_convert_BarToneCMYK_rgb:w on line ...
 Defining \__color_convert_BarToneCMYK_gray:w on line ...
+Defining \__color_model_BarToneCMYK_white: on line ...
 Defining \l__color_named_fooCMYK_tl on line ...
 Defining \l__color_named_fooCMYK_prop on line ...
 The color fooCMYK has the properties:
@@ -165,11 +167,13 @@ The color fooCMYK has the properties:
 >  BarToneCMYK  =>  0.5.
 <recently read> }
 l. ...  }
+Defining \__color_parse_mix_BarToneRGB:nw on line ...
 Defining \__color_parse_model_BarToneRGB:w on line ...
 Defining \__color_backend_BarToneRGB:n on line ...
 Defining \__color_convert_BarToneRGB_rgb:w on line ...
 Defining \__color_convert_BarToneRGB_cmyk:w on line ...
 Defining \__color_convert_BarToneRGB_gray:w on line ...
+Defining \__color_model_BarToneRGB_white: on line ...
 Defining \l__color_named_fooRGB_tl on line ...
 Defining \l__color_named_fooRGB_prop on line ...
 The color fooRGB has the properties:
@@ -177,11 +181,13 @@ The color fooRGB has the properties:
 >  BarToneRGB  =>  0.5.
 <recently read> }
 l. ...  }
+Defining \__color_parse_mix_BarToneGray:nw on line ...
 Defining \__color_parse_model_BarToneGray:w on line ...
 Defining \__color_backend_BarToneGray:n on line ...
 Defining \__color_convert_BarToneGray_cmyk:w on line ...
 Defining \__color_convert_BarToneGray_gray:w on line ...
 Defining \__color_convert_BarToneGray_rgb:w on line ...
+Defining \__color_model_BarToneGray_white: on line ...
 Defining \l__color_named_fooGray_tl on line ...
 Defining \l__color_named_fooGray_prop on line ...
 The color fooGray has the properties:
@@ -247,3 +253,19 @@ l. ...  }
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 9: Mixing separations
+============================================================
+Defining \l__color_named_foo_tl on line ...
+Defining \l__color_named_foo_prop on line ...
+The color foo has the properties:
+>  model  =>  BarToneCMYK
+>  BarToneCMYK  =>  0.35.
+<recently read> }
+l. ...  }
+The color foo has the properties:
+>  model  =>  BarToneCMYK
+>  BarToneCMYK  =>  0.55.
+<recently read> }
+l. ...  }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.tlg b/l3experimental/l3color/testfiles/m3color003.tlg
index 838d40b9f..04eb1e8bf 100644
--- a/l3experimental/l3color/testfiles/m3color003.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.tlg
@@ -148,11 +148,13 @@ l. ...  }
 ============================================================
 TEST 6: Creating new models
 ============================================================
+Defining \__color_parse_mix_BarToneCMYK:nw on line ...
 Defining \__color_parse_model_BarToneCMYK:w on line ...
 Defining \__color_backend_BarToneCMYK:n on line ...
 Defining \__color_convert_BarToneCMYK_cmyk:w on line ...
 Defining \__color_convert_BarToneCMYK_rgb:w on line ...
 Defining \__color_convert_BarToneCMYK_gray:w on line ...
+Defining \__color_model_BarToneCMYK_white: on line ...
 Defining \l__color_named_fooCMYK_tl on line ...
 Defining \l__color_named_fooCMYK_prop on line ...
 The color fooCMYK has the properties:
@@ -160,11 +162,13 @@ The color fooCMYK has the properties:
 >  BarToneCMYK  =>  0.5.
 <recently read> }
 l. ...  }
+Defining \__color_parse_mix_BarToneRGB:nw on line ...
 Defining \__color_parse_model_BarToneRGB:w on line ...
 Defining \__color_backend_BarToneRGB:n on line ...
 Defining \__color_convert_BarToneRGB_rgb:w on line ...
 Defining \__color_convert_BarToneRGB_cmyk:w on line ...
 Defining \__color_convert_BarToneRGB_gray:w on line ...
+Defining \__color_model_BarToneRGB_white: on line ...
 Defining \l__color_named_fooRGB_tl on line ...
 Defining \l__color_named_fooRGB_prop on line ...
 The color fooRGB has the properties:
@@ -172,11 +176,13 @@ The color fooRGB has the properties:
 >  BarToneRGB  =>  0.5.
 <recently read> }
 l. ...  }
+Defining \__color_parse_mix_BarToneGray:nw on line ...
 Defining \__color_parse_model_BarToneGray:w on line ...
 Defining \__color_backend_BarToneGray:n on line ...
 Defining \__color_convert_BarToneGray_cmyk:w on line ...
 Defining \__color_convert_BarToneGray_gray:w on line ...
 Defining \__color_convert_BarToneGray_rgb:w on line ...
+Defining \__color_model_BarToneGray_white: on line ...
 Defining \l__color_named_fooGray_tl on line ...
 Defining \l__color_named_fooGray_prop on line ...
 The color fooGray has the properties:
@@ -242,3 +248,19 @@ l. ...  }
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 9: Mixing separations
+============================================================
+Defining \l__color_named_foo_tl on line ...
+Defining \l__color_named_foo_prop on line ...
+The color foo has the properties:
+>  model  =>  BarToneCMYK
+>  BarToneCMYK  =>  0.35.
+<recently read> }
+l. ...  }
+The color foo has the properties:
+>  model  =>  BarToneCMYK
+>  BarToneCMYK  =>  0.55.
+<recently read> }
+l. ...  }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.uptex.tlg b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
index 2b6aec37c..52b661dd0 100644
--- a/l3experimental/l3color/testfiles/m3color003.uptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
@@ -153,11 +153,13 @@ l. ...  }
 ============================================================
 TEST 6: Creating new models
 ============================================================
+Defining \__color_parse_mix_BarToneCMYK:nw on line ...
 Defining \__color_parse_model_BarToneCMYK:w on line ...
 Defining \__color_backend_BarToneCMYK:n on line ...
 Defining \__color_convert_BarToneCMYK_cmyk:w on line ...
 Defining \__color_convert_BarToneCMYK_rgb:w on line ...
 Defining \__color_convert_BarToneCMYK_gray:w on line ...
+Defining \__color_model_BarToneCMYK_white: on line ...
 Defining \l__color_named_fooCMYK_tl on line ...
 Defining \l__color_named_fooCMYK_prop on line ...
 The color fooCMYK has the properties:
@@ -165,11 +167,13 @@ The color fooCMYK has the properties:
 >  BarToneCMYK  =>  0.5.
 <recently read> }
 l. ...  }
+Defining \__color_parse_mix_BarToneRGB:nw on line ...
 Defining \__color_parse_model_BarToneRGB:w on line ...
 Defining \__color_backend_BarToneRGB:n on line ...
 Defining \__color_convert_BarToneRGB_rgb:w on line ...
 Defining \__color_convert_BarToneRGB_cmyk:w on line ...
 Defining \__color_convert_BarToneRGB_gray:w on line ...
+Defining \__color_model_BarToneRGB_white: on line ...
 Defining \l__color_named_fooRGB_tl on line ...
 Defining \l__color_named_fooRGB_prop on line ...
 The color fooRGB has the properties:
@@ -177,11 +181,13 @@ The color fooRGB has the properties:
 >  BarToneRGB  =>  0.5.
 <recently read> }
 l. ...  }
+Defining \__color_parse_mix_BarToneGray:nw on line ...
 Defining \__color_parse_model_BarToneGray:w on line ...
 Defining \__color_backend_BarToneGray:n on line ...
 Defining \__color_convert_BarToneGray_cmyk:w on line ...
 Defining \__color_convert_BarToneGray_gray:w on line ...
 Defining \__color_convert_BarToneGray_rgb:w on line ...
+Defining \__color_model_BarToneGray_white: on line ...
 Defining \l__color_named_fooGray_tl on line ...
 Defining \l__color_named_fooGray_prop on line ...
 The color fooGray has the properties:
@@ -247,3 +253,19 @@ l. ...  }
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 9: Mixing separations
+============================================================
+Defining \l__color_named_foo_tl on line ...
+Defining \l__color_named_foo_prop on line ...
+The color foo has the properties:
+>  model  =>  BarToneCMYK
+>  BarToneCMYK  =>  0.35.
+<recently read> }
+l. ...  }
+The color foo has the properties:
+>  model  =>  BarToneCMYK
+>  BarToneCMYK  =>  0.55.
+<recently read> }
+l. ...  }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.xetex.tlg b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
index 0491073cf..3a4536fe6 100644
--- a/l3experimental/l3color/testfiles/m3color003.xetex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
@@ -148,11 +148,13 @@ l. ...  }
 ============================================================
 TEST 6: Creating new models
 ============================================================
+Defining \__color_parse_mix_BarToneCMYK:nw on line ...
 Defining \__color_parse_model_BarToneCMYK:w on line ...
 Defining \__color_backend_BarToneCMYK:n on line ...
 Defining \__color_convert_BarToneCMYK_cmyk:w on line ...
 Defining \__color_convert_BarToneCMYK_rgb:w on line ...
 Defining \__color_convert_BarToneCMYK_gray:w on line ...
+Defining \__color_model_BarToneCMYK_white: on line ...
 Defining \l__color_named_fooCMYK_tl on line ...
 Defining \l__color_named_fooCMYK_prop on line ...
 The color fooCMYK has the properties:
@@ -160,11 +162,13 @@ The color fooCMYK has the properties:
 >  BarToneCMYK  =>  0.5.
 <recently read> }
 l. ...  }
+Defining \__color_parse_mix_BarToneRGB:nw on line ...
 Defining \__color_parse_model_BarToneRGB:w on line ...
 Defining \__color_backend_BarToneRGB:n on line ...
 Defining \__color_convert_BarToneRGB_rgb:w on line ...
 Defining \__color_convert_BarToneRGB_cmyk:w on line ...
 Defining \__color_convert_BarToneRGB_gray:w on line ...
+Defining \__color_model_BarToneRGB_white: on line ...
 Defining \l__color_named_fooRGB_tl on line ...
 Defining \l__color_named_fooRGB_prop on line ...
 The color fooRGB has the properties:
@@ -172,11 +176,13 @@ The color fooRGB has the properties:
 >  BarToneRGB  =>  0.5.
 <recently read> }
 l. ...  }
+Defining \__color_parse_mix_BarToneGray:nw on line ...
 Defining \__color_parse_model_BarToneGray:w on line ...
 Defining \__color_backend_BarToneGray:n on line ...
 Defining \__color_convert_BarToneGray_cmyk:w on line ...
 Defining \__color_convert_BarToneGray_gray:w on line ...
 Defining \__color_convert_BarToneGray_rgb:w on line ...
+Defining \__color_model_BarToneGray_white: on line ...
 Defining \l__color_named_fooGray_tl on line ...
 Defining \l__color_named_fooGray_prop on line ...
 The color fooGray has the properties:
@@ -242,3 +248,19 @@ l. ...  }
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 9: Mixing separations
+============================================================
+Defining \l__color_named_foo_tl on line ...
+Defining \l__color_named_foo_prop on line ...
+The color foo has the properties:
+>  model  =>  BarToneCMYK
+>  BarToneCMYK  =>  0.35.
+<recently read> }
+l. ...  }
+The color foo has the properties:
+>  model  =>  BarToneCMYK
+>  BarToneCMYK  =>  0.55.
+<recently read> }
+l. ...  }
+============================================================





More information about the latex3-commits mailing list.