[latex3-commits] [git/LaTeX3-latex3-latex3] color-models: Generalise color model support (d367c41fc)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Jun 1 17:39:01 CEST 2020


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

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

commit d367c41fcbe18a43d5c9385927c7de02b139a8f6
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Jun 1 16:35:45 2020 +0100

    Generalise color model support


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

d367c41fcbe18a43d5c9385927c7de02b139a8f6
 l3backend/l3backend-color.dtx           | 20 +++++---
 l3experimental/CHANGELOG.md             |  1 +
 l3experimental/l3color/l3color.dtx      | 82 +++++++++++++++++++++++++++++----
 l3kernel/testfiles/m3expl001.luatex.tlg |  2 +-
 l3kernel/testfiles/m3expl001.ptex.tlg   |  2 +-
 l3kernel/testfiles/m3expl001.tlg        |  2 +-
 l3kernel/testfiles/m3expl001.uptex.tlg  |  2 +-
 l3kernel/testfiles/m3expl001.xetex.tlg  |  2 +-
 l3kernel/testfiles/m3expl003.luatex.tlg |  2 +-
 l3kernel/testfiles/m3expl003.ptex.tlg   |  2 +-
 l3kernel/testfiles/m3expl003.tlg        |  2 +-
 l3kernel/testfiles/m3expl003.uptex.tlg  |  2 +-
 l3kernel/testfiles/m3expl003.xetex.tlg  |  2 +-
 13 files changed, 99 insertions(+), 24 deletions(-)

diff --git a/l3backend/l3backend-color.dtx b/l3backend/l3backend-color.dtx
index ae01721df..33e345a3c 100644
--- a/l3backend/l3backend-color.dtx
+++ b/l3backend/l3backend-color.dtx
@@ -113,7 +113,6 @@
 % \begin{macro}{\@@_backend_cmyk:w}
 % \begin{macro}{\@@_backend_gray:w}
 % \begin{macro}{\@@_backend_rgb:w}
-% \begin{macro}{\@@_backend_spot:w}
 % \begin{macro}{\@@_backend_select:n, \@@_backend_select:x}
 % \begin{macro}{\@@_backend_reset:}
 % \begin{macro}{color.fc}
@@ -136,8 +135,6 @@
     \@@_backend_select:x
       { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} }
   }
-\cs_new_protected:Npn \@@_backend_spot:w #1 ~ #2 \s_@@_stop
-  { \@@_backend_select:n { #1 } }
 \cs_new_protected:Npn \@@_backend_select:n #1
   {
     \__kernel_backend_literal:n { color~push~ #1 }
@@ -156,6 +153,13 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+%
+% \begin{macro}{\@@_backend_meta_spot:w}
+%   Setup for meta-models.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_meta_spot:w #1 \s_@@_mark #2 \s_@@_stop
+  { \@@_backend_select:n { #1 } }
+%    \end{macrocode}
 % \end{macro}
 %
 %    \begin{macrocode}
@@ -229,7 +233,6 @@
 % \begin{macro}{\@@_backend_cmyk:w, \@@_backend_cmyk:nnnn}
 % \begin{macro}{\@@_backend_gray:w, \@@_backend_gray:n}
 % \begin{macro}{\@@_backend_rgb:w, \@@_backend_rgb:nnn}
-% \begin{macro}{\@@_backend_spot:w}
 % \begin{macro}{\@@_backend_select:n, \@@_backend_select:x}
 % \begin{macro}{\@@_backend_reset:}
 %   Simply dump the data, but allowing for \LuaTeX{}.
@@ -266,8 +269,6 @@
   }
 \cs_new_protected:Npn \@@_backend_rgb:nnn #1#2#3
   { \@@_backend_select:n { #1 ~ #2 ~ #3 ~ rg ~ #1 ~ #2 ~ #3 ~ RG } }
-\cs_new_protected:Npn \@@_backend_spot:w #1 ~ #2 \s_@@_stop
-  { \@@_backend_select:n { /#1 ~ cs ~ /#1 ~ CS ~ #2 ~ sc ~ #2 ~ SC } }
 \cs_new_protected:Npx \@@_backend_select:n #1
   {
     \cs_if_exist:NTF \tex_pdfextension:D
@@ -290,6 +291,13 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+%
+% \begin{macro}{\@@_backend_meta_spot:w}
+%   Set up for meta-models.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_backend_meta_spot:w #1 \s_@@_mark #2 \s_@@_stop
+  { \@@_backend_select:n { /#1 ~ cs ~ /#1 ~ CS ~ #2 ~ sc ~ #2 ~ SC } }
+%    \end{macrocode}
 % \end{macro}
 %
 %    \begin{macrocode}
diff --git a/l3experimental/CHANGELOG.md b/l3experimental/CHANGELOG.md
index 6c72d0d3e..fd94d9246 100644
--- a/l3experimental/CHANGELOG.md
+++ b/l3experimental/CHANGELOG.md
@@ -10,6 +10,7 @@ this project uses date-based 'snapshot' version identifiers.
 ### Added
 - `\cctab_select:N`
 - Support for `Hsb`, `HSB`, `HTML` and `RGB` color models
+- Generalise color model support
 
 ## [2020-05-18]
 
diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 46f9a2478..e32ca306c 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -71,9 +71,6 @@
 %     the components
 %   \item \texttt{cmyk} Cyan-magenta-yellow-black color, with four axes, one for
 %     each of the components
-%   \item \texttt{spot} Spot color, with one value, the name of the color
-%     (see \url{https://helpx.adobe.com/indesign/using/spot-process-colors.html}
-%     for details of the use of spot colors in print)
 % \end{itemize}
 % There are also interface models: these are convenient for users but have
 % to be manipulated before storing/passing to the backend. Interface models
@@ -93,9 +90,9 @@
 % \end{itemize}
 % All interface models are internally stored as |rgb|.
 % 
-% Additional models may be created to allow mixing of spot colors
-% with each other or with those from other models. See
-% Section~\ref{l3color:sec:spot} for more detail of spot color support.
+% Additional models may be created to allow for more complex constructs, for
+% example support for spot colors. See Section~\ref{l3color:sec:addn} for more
+% detail.
 %
 % When color is selected by model, the \meta{values} given are specified as
 % a comma-separated list. The length of the list will therefore be determined
@@ -267,8 +264,27 @@
 %   representation).
 % \end{function}
 %
-% \section{Spot colors}
-% \label{l3color:sec:spot}
+% \section{Additional color models}
+% \label{l3color:sec:addn}
+%
+% Additional color models are required to support specialist workflows, for
+% example those involving spot colors (see
+% \url{https://helpx.adobe.com/indesign/using/spot-process-colors.html}
+% for details of the use of spot colors in print).
+% 
+% \begin{function}{\color_model_new:nnn}
+%   \begin{syntax}
+%     \cs{color_model_new:nnn} \Arg{name} \Arg{type} \Arg{cmyk eq}
+%   \end{syntax}
+%   Creates a new \meta{model} (which should be a simple text string without
+%   spaces) of the \meta{type}, which must be one of
+%   \begin{itemize}
+%     \item \texttt{spot}: A spot color which can be used with an amount of
+%       tint
+%   \end{itemize}
+%   The \meta{cmyk eq} should be a conversion value, used to approximate the
+%   color where the \meta{model type} is not supported.
+% \end{function}
 %
 % \end{documentation}
 %
@@ -943,6 +959,42 @@
 %    \end{macrocode}
 % \end{variable}
 %
+% \subsection{Additional color models}
+%
+% \begin{macro}{\color_model_new:nnn}
+% \begin{macro}[EXP]{\@@_parse_meta_spot:w}
+%    \begin{macrocode}
+\cs_new_protected:Npn \color_model_new:nnn #1#2#3
+  {
+    \cs_if_exist:cTF { @@_parse_model_ \tl_to_str:n {#1} :w }
+      {
+        \__kernel_msg_error:nnn { color } { model-already-defined } {#2}
+      }
+      {
+        \cs_if_exist:cTF { @@_parse_meta_ #1 :w }
+          {
+            \cs_new:cpx { @@_parse_model_ \tl_to_str:n {#1} :w }
+              {
+                \exp_not:c { @@_parse_meta_ #1 :w }
+                  \tl_to_str:n {#1} \exp_not:N \s_@@_mark
+              }
+            \cs_new_protected:cpx { @@_backend_ \tl_to_str:n {#1} :w }
+              {
+                \exp_not:c { @@_backend_meta_ #1 :w }
+                  \tl_to_str:n {#1} \exp_not:N \s_@@_mark
+              }
+          }
+          {
+            \__kernel_msg_error:nnn { color } { unknown-model-type } {#1}
+          }
+      }
+  }
+\cs_new:Npn \@@_parse_meta_spot:w #1 \s_@@_mark #3 , #4 \s_@@_stop
+  { #1 ~ \@@_parse_number:n {#3} }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \subsection{Diagnostics}
 %
 % \begin{macro}{\color_show:n}
@@ -980,6 +1032,14 @@
 % \subsection{Messages}
 %
 % \begin{macrocode}
+\__kernel_msg_new:nnnn { color } { model-already-defined }
+  { Color~model~'#2'~already~defined. }
+  {
+    \c_@@_coding_error_text_tl
+    LaTeX~was~asked~to~define~a~new~color~model~called~'#1',~but~
+    this~color~model~already~exists.
+    \c_@@_return_text_tl
+  }
 \__kernel_msg_new:nnnn { color } { unknown-color }
   { Unknown~color~'#1'. }
   {
@@ -992,6 +1052,12 @@
     LaTeX~has~been~asked~to~use~a~color~model~called~'#1',~
     but~this~model~is~not~set~up.
   }
+\__kernel_msg_new:nnnn { color } { unknown-model-type }
+  { Unknown~color~model~type~'#1'. }
+  {
+    LaTeX~has~been~asked~to~use~create~a~new~color~model~of~type~'#1',~
+    but~this~type~of~model~is~not~set~up.
+  }
 % \end{macrocode}
 %
 % \begin{macrocode}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index a39732b9d..18023e175 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -36,10 +36,10 @@ Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_gray:n on line ...
 Defining \__color_backend_rgb:w on line ...
 Defining \__color_backend_rgb:nnn on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 0579d89f1..0f16fe757 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -32,10 +32,10 @@ Defining \__color_backend_pickup:N on line ...
 Defining \__color_backend_cmyk:w on line ...
 Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_rgb:w on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index a39732b9d..18023e175 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -36,10 +36,10 @@ Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_gray:n on line ...
 Defining \__color_backend_rgb:w on line ...
 Defining \__color_backend_rgb:nnn on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 0579d89f1..0f16fe757 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -32,10 +32,10 @@ Defining \__color_backend_pickup:N on line ...
 Defining \__color_backend_cmyk:w on line ...
 Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_rgb:w on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index d2fbebcf3..375422c12 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -29,10 +29,10 @@ Defining \__color_backend_pickup:N on line ...
 Defining \__color_backend_cmyk:w on line ...
 Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_rgb:w on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index a39732b9d..18023e175 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -36,10 +36,10 @@ Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_gray:n on line ...
 Defining \__color_backend_rgb:w on line ...
 Defining \__color_backend_rgb:nnn on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 0579d89f1..0f16fe757 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -32,10 +32,10 @@ Defining \__color_backend_pickup:N on line ...
 Defining \__color_backend_cmyk:w on line ...
 Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_rgb:w on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index a39732b9d..18023e175 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -36,10 +36,10 @@ Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_gray:n on line ...
 Defining \__color_backend_rgb:w on line ...
 Defining \__color_backend_rgb:nnn on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 0579d89f1..0f16fe757 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -32,10 +32,10 @@ Defining \__color_backend_pickup:N on line ...
 Defining \__color_backend_cmyk:w on line ...
 Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_rgb:w on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index d2fbebcf3..375422c12 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -29,10 +29,10 @@ Defining \__color_backend_pickup:N on line ...
 Defining \__color_backend_cmyk:w on line ...
 Defining \__color_backend_gray:w on line ...
 Defining \__color_backend_rgb:w on line ...
-Defining \__color_backend_spot:w on line ...
 Defining \__color_backend_select:n on line ...
 Defining \__color_backend_select:x on line ...
 Defining \__color_backend_reset: on line ...
+Defining \__color_backend_meta_spot:w on line ...
 Defining \__box_backend_clip:N on line ...
 Defining \__box_backend_rotate:Nn on line ...
 Defining \__box_backend_rotate_aux:Nn on line ...





More information about the latex3-commits mailing list.