[latex3-commits] [git/LaTeX3-latex3-latex3] color-export: Add "annotation" color export (b0b1d639d)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Jun 11 18:22:38 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : color-export
Link : https://github.com/latex3/latex3/commit/b0b1d639d99ae33b3e949e003d28b8255588478c
>---------------------------------------------------------------
commit b0b1d639d99ae33b3e949e003d28b8255588478c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Jun 11 17:22:38 2020 +0100
Add "annotation" color export
>---------------------------------------------------------------
b0b1d639d99ae33b3e949e003d28b8255588478c
l3experimental/l3color/l3color.dtx | 22 ++++++++++++++++------
l3experimental/l3color/testfiles/m3color002.lvt | 21 +++++++++++++--------
l3experimental/l3color/testfiles/m3color002.tlg | 12 ++++++++++++
3 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index d2026b107..5431abce8 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -268,6 +268,8 @@
% \begin{itemize}
% \item \texttt{HTML} Uppercase two-digit hexadecimal values, expressing
% a red-green-blue color; the digits are \emph{not} separated
+% \item \texttt{annotation} Space-separated red-green-blue values
+% suitable for use as a PDF annotation color
% \end{itemize}
%
% \begin{function}{\color_export:nnN}
@@ -995,7 +997,7 @@
{ \exp_after:wN \@@_export:nnnN #2 {#1} #2 }
\cs_new:Npn \@@_export:nnnN #1#2#3#4
{
- \cs_if_exist_use:cF { @@_export_ #3 :nnN }
+ \cs_if_exist_use:cF { @@_export_format_ #3 :nnN }
{
\__kernel_msg_error:nnn { color } { unknown-export-format } {#3}
\use_none:nnn
@@ -1008,22 +1010,29 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\@@_export_HTML:nnN}
-% \begin{macro}{\@@_export_HTML:Nw}
+% \begin{macro}{\@@_export_format_annotation:nnN, \@@_export_format_HTML:nnN}
+% \begin{macro}{\@@_export_rgb:nnNN}
+% \begin{macro}{\@@_export_annotation:Nw, \@@_export_HTML:Nw}
% \begin{macro}[EXP]{\@@_export_HTML:n}
% \textsc{html} values must be given in |rgb|: we force conversion if
% required, then do some simple maths.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_export_HTML:nnN #1#2#3
+\cs_new_protected:Npn \@@_export_format_annotation:nnN #1#2#3
+ { \@@_export_rgb:nnNN {#1} {#2} #3 \@@_export_HTML:Nw }
+\cs_new_protected:Npn \@@_export_format_HTML:nnN #1#2#3
+ { \@@_export_rgb:nnNN {#1} {#2}#3 \@@_export_annotation:Nw }
+\cs_new_protected:Npn \@@_export_rgb:nnNN #1#2#3#4
{
\str_if_eq:nnTF {#1} { rgb }
- { \@@_export_HTML:Nw #3 #2 \s_@@_stop }
+ { #4 #3 #2 \s_@@_stop }
{
\@@_convert:nnnN {#1} { rgb } {#2} #3
- \exp_after:wN \@@_export_HTML:Nw \exp_after:wN #3
+ \exp_after:wN #4 \exp_after:wN #3
#3 \s_@@_stop
}
}
+\cs_new_protected:Npn \@@_export_annotation:Nw #1#2 \s_@@_stop
+ { \tl_set:Nx #1 {#2} }
\cs_new_protected:Npn \@@_export_HTML:Nw #1#2 ~ #3 ~ #4 \s_@@_stop
{
\tl_set:Nx #1
@@ -1043,6 +1052,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Diagnostics}
%
diff --git a/l3experimental/l3color/testfiles/m3color002.lvt b/l3experimental/l3color/testfiles/m3color002.lvt
index 95d5a16f4..471c839f3 100644
--- a/l3experimental/l3color/testfiles/m3color002.lvt
+++ b/l3experimental/l3color/testfiles/m3color002.lvt
@@ -50,16 +50,21 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
\TEST { Exporting~colors }
{
- \color_export:nnN { blue } { HTML } \l_tmpa_tl
- \tl_show:N \l_tmpa_tl
- \color_export:nnN { blue!50!red } { HTML } \l_tmpa_tl
- \tl_show:N \l_tmpa_tl
- \color_export:nnN { cyan } { HTML } \l_tmpa_tl
- \tl_show:N \l_tmpa_tl
- \color_export:nnnN { gray } { 0.6 } { HTML } \l_tmpa_tl
- \tl_show:N \l_tmpa_tl
+ \clist_map_inline:nn
+ { annotation , HTML }
+ {
+ \color_export:nnN { blue } {#1} \l_tmpa_tl
+ \tl_show:N \l_tmpa_tl
+ \color_export:nnN { blue!50!red } {#1} \l_tmpa_tl
+ \tl_show:N \l_tmpa_tl
+ \color_export:nnN { cyan } {#1} \l_tmpa_tl
+ \tl_show:N \l_tmpa_tl
+ \color_export:nnnN { gray } { 0.6 } {#1} \l_tmpa_tl
+ \tl_show:N \l_tmpa_tl
+ }
}
\TEST { Exporting~color:~errors }
diff --git a/l3experimental/l3color/testfiles/m3color002.tlg b/l3experimental/l3color/testfiles/m3color002.tlg
index b86d41c05..8268b22a2 100644
--- a/l3experimental/l3color/testfiles/m3color002.tlg
+++ b/l3experimental/l3color/testfiles/m3color002.tlg
@@ -81,6 +81,18 @@ l. ... }
> \l_tmpa_tl=999999.
<recently read> }
l. ... }
+> \l_tmpa_tl=0.0 0.0 1.0.
+<recently read> }
+l. ... }
+> \l_tmpa_tl=0.5 0 0.5.
+<recently read> }
+l. ... }
+> \l_tmpa_tl=0 1 1.
+<recently read> }
+l. ... }
+> \l_tmpa_tl=0.6 0.6 0.6.
+<recently read> }
+l. ... }
============================================================
============================================================
TEST 4: Exporting color: errors
More information about the latex3-commits
mailing list.