[latex3-commits] [git/LaTeX3-latex3-latex3] color-models: Error safely if color mixing is attempted mixing Separation and Device spaces (21c56f43c)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Jun 25 12:47:35 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : color-models
Link : https://github.com/latex3/latex3/commit/21c56f43c0ee71830f6d29b664283ac792caaefa
>---------------------------------------------------------------
commit 21c56f43c0ee71830f6d29b664283ac792caaefa
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Jun 25 11:47:35 2020 +0100
Error safely if color mixing is attempted mixing Separation and Device spaces
>---------------------------------------------------------------
21c56f43c0ee71830f6d29b664283ac792caaefa
l3experimental/l3color/l3color.dtx | 33 ++++++++++++++++--
l3experimental/l3color/testfiles/m3color003.lvt | 13 +++++++
.../l3color/testfiles/m3color003.ptex.tlg | 40 ++++++++++++++++++++++
l3experimental/l3color/testfiles/m3color003.tlg | 40 ++++++++++++++++++++++
.../l3color/testfiles/m3color003.uptex.tlg | 40 ++++++++++++++++++++++
.../l3color/testfiles/m3color003.xetex.tlg | 40 ++++++++++++++++++++++
6 files changed, 204 insertions(+), 2 deletions(-)
diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index a6e74e245..981d148b4 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -453,9 +453,17 @@
\cs_generate_variant:Nn \@@_convert:nnN { VV }
\cs_new_protected:Npn \@@_convert:nnnN #1#2#3#4
{
- \tl_set:Nx #4
+ \cs_if_exist:cTF { @@_convert_ #1 _ #2 :w }
{
- \use:c { @@_convert_ #1 _ #2 :w } #3 ~ 0 ~ 0 ~ 0 \s_@@_stop
+ \tl_set:Nx #4
+ {
+ \use:c { @@_convert_ #1 _ #2 :w } #3 ~ 0 ~ 0 ~ 0 \s_@@_stop
+ }
+ }
+ {
+ \__kernel_msg_error:nnnn { color }
+ { conversion-not-available } {#1} {#2}
+ \tl_set_eq:Nc #4 { c_@@_fallback_ #2 _tl }
}
}
\cs_generate_variant:Nn \@@_convert:nnnN { nV , nnV }
@@ -1162,6 +1170,20 @@
% \end{macrocode}
% \end{variable}
%
+% \begin{variable}
+% {
+% \c_@@_fallback_cmyk_tl ,
+% \c_@@_fallback_gray_tl ,
+% \c_@@_fallback_rgb_tl
+% }
+% Fallback definitions for conversion failure.
+% \begin{macrocode}
+\tl_const:Nn \c_@@_fallback_cmyk_tl { 0 ~ 0 ~ 0 ~ 1 }
+\tl_const:Nn \c_@@_fallback_gray_tl { 0 }
+\tl_const:Nn \c_@@_fallback_rgb_tl { 1 ~ 1 ~ 1 }
+% \end{macrocode}
+% \end{variable}
+%
% \subsection{Exporting colors}
%
% \begin{macro}{\color_export:nnN}
@@ -1394,6 +1416,7 @@
{
\cs_if_exist:cTF { @@_model_separation_ #2 :nnnnn }
{
+ \tl_const:cn { c_@@_fallback_ #1 _tl } { 1 }
\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} } }
@@ -1511,6 +1534,12 @@
% \subsection{Messages}
%
% \begin{macrocode}
+\__kernel_msg_new:nnnn { color } { conversion-not-available }
+ { No~model~conversion~available~from~'#1'~to~'#2'. }
+ {
+ LaTeX~has~been~asked~to~convert~a~color~from~model~'#1'~
+ to~model'#2',~but~there~is~no~method~available~to~do~that.
+ }
\__kernel_msg_new:nnnn { color } { model-already-defined }
{ Color~model~'#1'~already~defined. }
{
diff --git a/l3experimental/l3color/testfiles/m3color003.lvt b/l3experimental/l3color/testfiles/m3color003.lvt
index c4ea79c4b..7520658c1 100644
--- a/l3experimental/l3color/testfiles/m3color003.lvt
+++ b/l3experimental/l3color/testfiles/m3color003.lvt
@@ -163,4 +163,17 @@
\color_show:n { foo }
}
+\TEST { Mixing~separation:~failures }
+ {
+ \OMIT
+ \color_set:nnn { fooCMYK } { BarToneCMYK } { 1.0 }
+ \TIMO
+ \color_set:nn { foo } { fooCMYK!35!black }
+ \color_show:n { foo }
+ \color_set:nn { foo } { fooCMYK!35!cyan }
+ \color_show:n { foo }
+ \color_set:nn { foo } { fooCMYK!35!green }
+ \color_show:n { foo }
+ }
+
\END
diff --git a/l3experimental/l3color/testfiles/m3color003.ptex.tlg b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
index 52b661dd0..32b1bf9a3 100644
--- a/l3experimental/l3color/testfiles/m3color003.ptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
@@ -153,6 +153,7 @@ l. ... }
============================================================
TEST 6: Creating new models
============================================================
+Defining \c__color_fallback_BarToneCMYK_tl on line ...
Defining \__color_parse_mix_BarToneCMYK:nw on line ...
Defining \__color_parse_model_BarToneCMYK:w on line ...
Defining \__color_backend_BarToneCMYK:n on line ...
@@ -167,6 +168,7 @@ The color fooCMYK has the properties:
> BarToneCMYK => 0.5.
<recently read> }
l. ... }
+Defining \c__color_fallback_BarToneRGB_tl on line ...
Defining \__color_parse_mix_BarToneRGB:nw on line ...
Defining \__color_parse_model_BarToneRGB:w on line ...
Defining \__color_backend_BarToneRGB:n on line ...
@@ -181,6 +183,7 @@ The color fooRGB has the properties:
> BarToneRGB => 0.5.
<recently read> }
l. ... }
+Defining \c__color_fallback_BarToneGray_tl on line ...
Defining \__color_parse_mix_BarToneGray:nw on line ...
Defining \__color_parse_model_BarToneGray:w on line ...
Defining \__color_backend_BarToneGray:n on line ...
@@ -269,3 +272,40 @@ The color foo has the properties:
<recently read> }
l. ... }
============================================================
+============================================================
+TEST 10: Mixing separation: failures
+============================================================
+! LaTeX3 Error: No model conversion available from 'gray' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'gray' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+! LaTeX3 Error: No model conversion available from 'cmyk' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'cmyk' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+! LaTeX3 Error: No model conversion available from 'rgb' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'rgb' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.tlg b/l3experimental/l3color/testfiles/m3color003.tlg
index 04eb1e8bf..a9afee04e 100644
--- a/l3experimental/l3color/testfiles/m3color003.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.tlg
@@ -148,6 +148,7 @@ l. ... }
============================================================
TEST 6: Creating new models
============================================================
+Defining \c__color_fallback_BarToneCMYK_tl on line ...
Defining \__color_parse_mix_BarToneCMYK:nw on line ...
Defining \__color_parse_model_BarToneCMYK:w on line ...
Defining \__color_backend_BarToneCMYK:n on line ...
@@ -162,6 +163,7 @@ The color fooCMYK has the properties:
> BarToneCMYK => 0.5.
<recently read> }
l. ... }
+Defining \c__color_fallback_BarToneRGB_tl on line ...
Defining \__color_parse_mix_BarToneRGB:nw on line ...
Defining \__color_parse_model_BarToneRGB:w on line ...
Defining \__color_backend_BarToneRGB:n on line ...
@@ -176,6 +178,7 @@ The color fooRGB has the properties:
> BarToneRGB => 0.5.
<recently read> }
l. ... }
+Defining \c__color_fallback_BarToneGray_tl on line ...
Defining \__color_parse_mix_BarToneGray:nw on line ...
Defining \__color_parse_model_BarToneGray:w on line ...
Defining \__color_backend_BarToneGray:n on line ...
@@ -264,3 +267,40 @@ The color foo has the properties:
<recently read> }
l. ... }
============================================================
+============================================================
+TEST 10: Mixing separation: failures
+============================================================
+! LaTeX3 Error: No model conversion available from 'gray' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'gray' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+! LaTeX3 Error: No model conversion available from 'cmyk' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'cmyk' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+! LaTeX3 Error: No model conversion available from 'rgb' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'rgb' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.uptex.tlg b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
index 52b661dd0..32b1bf9a3 100644
--- a/l3experimental/l3color/testfiles/m3color003.uptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
@@ -153,6 +153,7 @@ l. ... }
============================================================
TEST 6: Creating new models
============================================================
+Defining \c__color_fallback_BarToneCMYK_tl on line ...
Defining \__color_parse_mix_BarToneCMYK:nw on line ...
Defining \__color_parse_model_BarToneCMYK:w on line ...
Defining \__color_backend_BarToneCMYK:n on line ...
@@ -167,6 +168,7 @@ The color fooCMYK has the properties:
> BarToneCMYK => 0.5.
<recently read> }
l. ... }
+Defining \c__color_fallback_BarToneRGB_tl on line ...
Defining \__color_parse_mix_BarToneRGB:nw on line ...
Defining \__color_parse_model_BarToneRGB:w on line ...
Defining \__color_backend_BarToneRGB:n on line ...
@@ -181,6 +183,7 @@ The color fooRGB has the properties:
> BarToneRGB => 0.5.
<recently read> }
l. ... }
+Defining \c__color_fallback_BarToneGray_tl on line ...
Defining \__color_parse_mix_BarToneGray:nw on line ...
Defining \__color_parse_model_BarToneGray:w on line ...
Defining \__color_backend_BarToneGray:n on line ...
@@ -269,3 +272,40 @@ The color foo has the properties:
<recently read> }
l. ... }
============================================================
+============================================================
+TEST 10: Mixing separation: failures
+============================================================
+! LaTeX3 Error: No model conversion available from 'gray' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'gray' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+! LaTeX3 Error: No model conversion available from 'cmyk' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'cmyk' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+! LaTeX3 Error: No model conversion available from 'rgb' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'rgb' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+============================================================
diff --git a/l3experimental/l3color/testfiles/m3color003.xetex.tlg b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
index 3a4536fe6..bdb3c8163 100644
--- a/l3experimental/l3color/testfiles/m3color003.xetex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
@@ -148,6 +148,7 @@ l. ... }
============================================================
TEST 6: Creating new models
============================================================
+Defining \c__color_fallback_BarToneCMYK_tl on line ...
Defining \__color_parse_mix_BarToneCMYK:nw on line ...
Defining \__color_parse_model_BarToneCMYK:w on line ...
Defining \__color_backend_BarToneCMYK:n on line ...
@@ -162,6 +163,7 @@ The color fooCMYK has the properties:
> BarToneCMYK => 0.5.
<recently read> }
l. ... }
+Defining \c__color_fallback_BarToneRGB_tl on line ...
Defining \__color_parse_mix_BarToneRGB:nw on line ...
Defining \__color_parse_model_BarToneRGB:w on line ...
Defining \__color_backend_BarToneRGB:n on line ...
@@ -176,6 +178,7 @@ The color fooRGB has the properties:
> BarToneRGB => 0.5.
<recently read> }
l. ... }
+Defining \c__color_fallback_BarToneGray_tl on line ...
Defining \__color_parse_mix_BarToneGray:nw on line ...
Defining \__color_parse_model_BarToneGray:w on line ...
Defining \__color_backend_BarToneGray:n on line ...
@@ -264,3 +267,40 @@ The color foo has the properties:
<recently read> }
l. ... }
============================================================
+============================================================
+TEST 10: Mixing separation: failures
+============================================================
+! LaTeX3 Error: No model conversion available from 'gray' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'gray' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+! LaTeX3 Error: No model conversion available from 'cmyk' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'cmyk' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+! LaTeX3 Error: No model conversion available from 'rgb' to 'BarToneCMYK'.
+For immediate help type H <return>.
+ ...
+l. ... }
+LaTeX has been asked to convert a color from model 'rgb' to
+model'BarToneCMYK', but there is no method available to do that.
+The color foo has the properties:
+> model => BarToneCMYK
+> BarToneCMYK => 1.
+<recently read> }
+l. ... }
+============================================================
More information about the latex3-commits
mailing list.