summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/colo-ini.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/colo-ini.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/colo-ini.mkiv83
1 files changed, 75 insertions, 8 deletions
diff --git a/Master/texmf-dist/tex/context/base/colo-ini.mkiv b/Master/texmf-dist/tex/context/base/colo-ini.mkiv
index 5721bb513bb..7052bf6c9c9 100644
--- a/Master/texmf-dist/tex/context/base/colo-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/colo-ini.mkiv
@@ -242,8 +242,8 @@
\setfalse\c_colo_convert_gray
\getvalue{\??colorconversions\directcolorsparameter\c!conversion}% could be a nice \ifcsname
% too often:
- \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors9\v!rgb \fi
- \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors9\v!cmyk\fi
+ \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors{10}\v!rgb \fi
+ \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors{10}\v!cmyk\fi
\colo_helpers_set_current_model
\ifproductionrun
\edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}%
@@ -357,16 +357,26 @@
\normalexpanded{\colo_palets_define[#1][\csname\??colorpaletspecification#2\endcsname]}%
\fi}}
-\def\colo_palets_define_one#1#2% get rid of { } in #2
- {\colo_palets_define_two{#1}[#2]}%
+% \def\colo_palets_define_one#1#2% get rid of { } in #2
+% {\colo_palets_define_two{#1}[#2]}%
+
+\def\colo_palets_define_one#1#2% get rid of { }
+ {\doifassignmentelse{#2} % catch empty entries
+ {\colo_palets_define_two{#1}[#2]}
+ {\colo_palets_define_three{#1}{#2}}}
\def\colo_palets_define_two#1[#2=#3]%
{\edef\m_colo_palets_tmp{\ifx\m_colo_palets_tmp\empty\else\m_colo_palets_tmp,\fi#2}%
\colo_palets_define_set{#1}{#2}{#3}}%
+\def\colo_palets_define_three#1#2%
+ {\ifcsname\??colorpaletspecification#2\endcsname
+ \processcommacommand[\csname\??colorpaletspecification#2\endcsname]{\colo_palets_define_one{#1}}%
+ \fi}
+
\let\paletsize\!!zerocount
-\def\getpaletsize[#1]%
+\unexpanded\def\getpaletsize[#1]% only works for valid k=v definitions
{\getcommacommandsize[\csname\??colorpaletspecification#1\endcsname]%
\edef\paletsize{\number\commalistsize}}
@@ -577,6 +587,34 @@
\letvalue{\??colorsetter-}\empty % used?
\letvalue{\??transparencysetter-}\empty % used?
+% new: expandable (see tbl)
+
+\def\colo_helpers_fast_activate
+ {\ifx\currentcolorprefix\empty
+ \expandafter\colo_helpers_fast_activate_nop
+ \else
+ \expandafter\colo_helpers_fast_activate_yes
+ \fi}
+
+\def\colo_helpers_fast_activate_yes#1%
+ {\ifcsname\??colorsetter\currentcolorprefix#1\endcsname
+ \csname\??colorsetter\currentcolorprefix#1\endcsname
+ \csname\??transparencysetter\currentcolorprefix#1\endcsname
+ \else\ifcsname\??colorsetter#1\endcsname
+ \csname\??colorsetter#1\endcsname
+ \csname\??transparencysetter#1\endcsname
+ \fi\fi}
+
+\def\colo_helpers_fast_activate_nop#1%
+ {\ifcsname\??colorsetter#1\endcsname
+ \csname\??colorsetter#1\endcsname
+ \csname\??transparencysetter#1\endcsname
+ \fi}
+
+\let\dofastcoloractivation\colo_helpers_fast_activate
+
+% so far
+
\def\colo_helpers_activate % two-step is not that much faster but less tracing
{\ifx\currentcolorprefix\empty
\expandafter\colo_helpers_activate_nop
@@ -688,6 +726,25 @@
% test {\mycolord OEPS} test
% test {\mycolorx OEPS} test
% \stoptext
+%
+% Beware: if we say:
+%
+% \definecolor[one][two]
+%
+% only color one is actually defined and two is not seen at the
+% \LUA\ end. This means that this doesn't work:
+%
+% \definecolor[ColorA][red]
+% \definecolor[ColorB][.5(ColorA)]
+% \definecolor[ColorC][.5(ColorB,white)]
+%
+% But this does work:
+%
+% \definecolor[ColorA][1.0(red)]
+% \definecolor[ColorB][0.5(ColorA)]
+% \definecolor[ColorC][0.5(ColorB,white)]
+%
+% because the fractional definition results in a new definition.
\unexpanded\def\defineintermediatecolor
{\dotripleempty\colo_basics_define_intermediate}
@@ -699,7 +756,7 @@
{\ctxcommand{defineintermediatecolor("#1","#2",
\thecolorattribute{#3},\thecolorattribute{#4},
\thetransparencyattribute{#3},\thetransparencyattribute{#4},
- "#5",false,\iffreezecolors true\else false\fi)}% not global
+ "#5",false,\v_colo_freeze_state)}% not global
\unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}}
%D Here is a more efficient helper for pgf:
@@ -802,9 +859,19 @@
\def\defaulttextcolor {black}
\def\s!themaintextcolor{themaintextcolor}
+\unexpanded\def\inheritmaintextcolor
+ {\ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi}
+
+\unexpanded\def\onlyinheritmaintextcolor
+ {\ifx\maintextcolor\empty
+ \deactivatecolor
+ \else
+ \colo_helpers_activate\maintextcolor
+ \fi}
+
\appendtoks
\deactivatecolor % public?
- \ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi
+ \inheritmaintextcolor
\to \everybeforeoutput
\def\colo_helpers_switch_to_maintextcolor#1%
@@ -961,7 +1028,7 @@
% ignores in attribute handler
%
-% \def\forcecolorhack{\vrule\!!width\zeropoint\!!height\zeropoint\!!depth\zeropoint}
+% \def\forcecolorhack{\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\zeropoint}
% \normal added else fails in metafun manual (leaders do a hard scan)