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.mkiv171
1 files changed, 96 insertions, 75 deletions
diff --git a/Master/texmf-dist/tex/context/base/colo-ini.mkiv b/Master/texmf-dist/tex/context/base/colo-ini.mkiv
index 1bceb5aa70a..45fe1463383 100644
--- a/Master/texmf-dist/tex/context/base/colo-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/colo-ini.mkiv
@@ -20,10 +20,14 @@
%D different approach, this module only implements a few generic mechanisms.
\registerctxluafile{colo-ini}{1.000}
-\registerctxluafile{lpdf-col}{1.000}
+\registerctxluafile{colo-icc}{1.000}
\unprotect
+%D In \MKIV\ we have independent color, colorspace and transparency
+%D but I'm still not sure if I keep it that way as it's probably more
+%D efficient to combine them (less attributes and finalizing).
+%D
%D We use a couple of local registers. That way we don't have
%D to group when converting colors. By the way, this is not
%D really faster. We can sqeeze half a second runtime for 50K
@@ -140,24 +144,33 @@
%D \showsetup{color}
%D \showsetup{graycolor}
- \def\switchtocolor [#1]{\getvalue{#1}}
+\unexpanded\def\switchtocolor [#1]{\csname#1\endcsname}
\unexpanded\def\color [#1]{\groupedcommand{\doactivatecolor{#1}}{}}
\unexpanded\def\startcolor [#1]{\begingroup\doactivatecolor{#1}}
\unexpanded\def\stopcolor {\endgroup}
\unexpanded\def\graycolor [#1]{\groupedcommand{\dosetcolormodel{gray}\getvalue{#1}}{}}
\unexpanded\def\colored [#1]{\groupedcommand{\definecolor[@colored@][#1]\doactivatecolor{@colored@}}{}}
\unexpanded\def\fastcolored [#1]#2{\begingroup\dodefinefastcolor[@colored@][#1]\doactivatecolor{@colored@}#2\endgroup}
- \def\predefinecolor [#1]{\flushatshipout{\hbox{\color[#1]{}}}}
- \def\predefineindexcolor[#1]{\flushatshipout{\hbox{\color[#1]{}}}}
- \unexpanded\def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]}
- \unexpanded\def\stopcolorpage {\stopcolor}
- \unexpanded\def\startraster [#1]{\dosetrastercolor{#1}}
- \unexpanded\def\stopraster {}
- \def\raster [#1]{\groupedcommand{\dosetrastercolor{#1}}{}}
- \def\faststartcolor [#1]{\doactivatecolor{#1}}
- \def\faststopcolor {}
+\unexpanded\def\predefinecolor [#1]{\flushatshipout{\hbox{\color[#1]{}}}}
+\unexpanded\def\predefineindexcolor[#1]{\flushatshipout{\hbox{\color[#1]{}}}}
+
+% some of this will go away
+
+\unexpanded\def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]}
+\unexpanded\def\stopcolorpage {\stopcolor}
+\unexpanded\def\startraster [#1]{\dosetrastercolor{#1}}
+\unexpanded\def\stopraster {}
+\unexpanded\def\raster [#1]{\groupedcommand{\dosetrastercolor{#1}}{}}
+\unexpanded\def\faststartcolor [#1]{\doactivatecolor{#1}}
+\unexpanded\def\faststopcolor {}
\unexpanded\def\dosetcolorattribute#1#2{\ifcsname#1#2\endcsname\doactivatecolor{\csname#1#2\endcsname}\fi}
+\def\getcolorattributevalue#1#2% color macro (obsolete again, we have a better method)
+ {\begingroup
+ \doactivatecolor{#1}%
+ \normalexpanded{\endgroup\edef\noexpand#2%
+ {\ifnum\attribute\colorattribute=\attributeunsetvalue\else\number\attribute\colorattribute\fi}}}
+
\let\grey\graycolor
%D Stacking:
@@ -197,36 +210,18 @@
%D where \type{\f!colorprefix} is \unprotect {\tttf \f!colorprefix}.
%D Loading such a file is done by \protect
%D
-%D \showsetup{setupcolor}
+%D \showsetup{usecolors}
%D
%D Some default colors are specified in \type{colo-rgb.tex},
%D which is loaded into the format by:
%D
%D \starttyping
-%D \setupcolor[rgb]
+%D \usecolors[rgb]
%D \stoptyping
-\let\colorstyle\empty
-
-\unexpanded\def\setupcolor
- {\dosingleargument\dosetupcolor}
-
-\def\dosetupcolor[#1]%
- {\doifnot{#1}\colorstyle
- {\def\colorstyle{#1}%
- \processcommalist[#1]\dodosetupcolor}}
-
-\def\dodosetupcolor#1%
- {\makeshortfilename[\truefilename{\f!colorprefix#1}]%
- \startreadingfile
- \readsysfile\shortfilename
- {\showcolormessage\m!colors4\colorstyle}
- {\showcolormessage\m!colors5\colorstyle}%
- \stopreadingfile}
+\unexpanded\def\usecolors[#1]{\ctxcommand{usecolors(\!!bs#1\!!es)}}
-\let\usecolors\setupcolor
-
-% check: \startcolormode
+\let\setupcolor\usecolors
%D \macros
%D {definetransparency}
@@ -243,6 +238,9 @@
\newtoks\everysetupcolors
+\let\dosetcolorvalue \setvalue
+\def\colorfreezestate{false}
+
\def\dosetupcolors[#1]% some no longer make sense in MkIV
{\getparameters[\??cl][#1]%
\doifelse\@@clspot\v!yes
@@ -254,6 +252,13 @@
\doifelse\@@clexpansion\v!yes
\freezecolorstrue
\freezecolorsfalse
+ \iffreezecolors
+ \let\dosetcolorvalue\setevalue
+ \def\colorfreezestate{true}%
+ \else
+ \let\dosetcolorvalue\setvalue
+ \def\colorfreezestate{false}%
+ \fi
\doifelse\@@clfactor\v!no
\weightGRAYfalse
\weightGRAYtrue
@@ -296,7 +301,7 @@
\fi\fi
\doifelse\@@clstate\v!stop
{\incolorfalse\forcegrayMPcolorstrue}%
- {\ifincolor\else\showcolormessage\m!colors1\colorstyle\fi\incolortrue\let\@@clstate\v!start}%
+ {\incolortrue\let\@@clstate\v!start}%
\dosetupcolormodel
\the\everysetupcolors}
@@ -371,7 +376,7 @@
\def\dodefinepalet[#1][#2]%
{\doifassignmentelse{#2}
{%\showcolormessage\m!colors6{#1}%
- \letvalue{\??pa#1}\empty
+ \letvalueempty{\??pa#1}%
\setevalue{\??pa\??pa#1}{#2}%
\def\dodododefinepalet[##1=##2]%
{\doifvaluesomething{\??pa#1}
@@ -712,19 +717,15 @@
% draw btex test etex withprescript \mptexcolor{blue} ;
% \stopMPpage
-\ifx\currentcolormodel\undefined \newcount\currentcolormodel \fi
+% \ifx\currentcolormodel\undefined \newcount\currentcolormodel \fi
-% \def\setcolormodel#1%
-% {\showcolormessage\m!colors1{#1}%
-% \dosetcolormodel{#1}}
+\def\currentcolormodel{\attribute\colormodelattribute}
\def\dosetcolormodel#1% no message
- {\currentcolormodel\ctxlua{tex.print(colors.setmodel('#1',\ifweightGRAY true\else false\fi))}%
- \attribute\colormodelattribute\currentcolormodel}
+ {\ctxcommand{setcolormodel('#1',\ifweightGRAY true\else false\fi)}} % sets attribute
\dosetcolormodel{all}
-
\def\dosetupcolormodel
{\ifincolor
\ifRGBsupported
@@ -765,10 +766,10 @@
% Since we couple definitions, we could stick to one test. Todo. Same for mpcolor.
-\letvalue{(cs:-}\empty
-\letvalue{(ts:-}\empty
+\letvalueempty{(cs:-}
+\letvalueempty{(ts:-}
-\def\doactivatecolor#1% : in currentpalet, maybe not, ugly
+\def\doactivatecolor#1% : in currentpalet, maybe not, ugly (some day at the lua end)
{\def\currentcolorname{#1}%
\ifcsname(cs:\currentpalet#1)\endcsname
\csname(cs:\currentpalet#1)\endcsname
@@ -782,10 +783,12 @@
% if it becomes a bottleneck we can set up a more complex system with one shared
% attribute for colorspace, color and transparency
+%
+% maybe always on
\def\doactivatecolor
{\ifproductionrun
- \ctxlua{colors.enable() transparencies.enable()}% not that efficient but at least robust
+ \ctxcommand{enablecolor() commands.enabletransparency()}% not that efficient but at least robust
\let\doactivatecolor\normaldoactivatecolor
\expandafter\doactivatecolor
\else
@@ -804,44 +807,45 @@
\setfalse\collectcolorsinlist
\def\collectcolorinlist#1{\doglobal\addtocommalist{#1}\colorlist}
-\def\doregistercolor#1#2{\ctxlua{colors.defineprocesscolor("#1","#2",false,\iffreezecolors true\else false\fi)}}
+\def\doregistercolor#1#2%
+ {\ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}}
\def\dodefinecolor[#1][#2]%
{\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi
- \ctxlua{colors.defineprocesscolor("#1","#2",false,\iffreezecolors true\else false\fi)}%
+ \ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}%
\dodefinecolorcommand\setvalue{#1}}
\def\dodefineglobalcolor[#1][#2]%
{\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi
- \ctxlua{colors.defineprocesscolor("#1","#2",true,\iffreezecolors true\else false\fi)}%
+ \ctxcommand{defineprocesscolor("#1","#2",true,\colorfreezestate)}%
\dodefinecolorcommand\setgvalue{#1}}
\def\dodefinenamedcolor[#1][#2]%
{\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi
- \ctxlua{colors.defineprocesscolor("#1","#2",false,\iffreezecolors true\else false\fi)}%
+ \ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}%
\dodefinecolorcommand\setvalue{#1}}
\def\dodefinespotcolor[#1][#2][#3]%
{\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi
- \ctxlua{colors.definespotcolor("#1","#2","#3",true)}%
+ \ctxcommand{definespotcolor("#1","#2","#3",true)}%
\dodefinecolorcommand\setxvalue{#1}}
\def\dodefinemultitonecolor[#1][#2][#3][#4]%
- {\ctxlua{colors.definemultitonecolor("#1","#2","#3","#4",true)}%
+ {\ctxcommand{definemultitonecolor("#1","#2","#3","#4",true)}%
\dodefinecolorcommand\setxvalue{#1}}
\def\dodefinetransparency[#1][#2]%
- {\ctxlua{colors.definetransparency("#1",#2)}}
+ {\ctxcommand{definetransparency("#1",#2)}}
\def\dosetrastercolor#1% slow, we need a fast one
{\edef\@@rastervalue{#1}%
\ifx\@@rastervalue\empty
\let\@@rastervalue\@@rsscreen
\fi
- \attribute\colorattribute\ctxlua{tex.sprint(colors.definesimplegray("_raster_",\@@rastervalue))}\relax}
+ \ctxcommand{setrastercolor("_raster_",\@@rastervalue)}} % sets attribute
\def\dodefinefastcolor[#1][#2]% still not fast but ok
- {\ctxlua{colors.defineprocesscolor("#1","#2",false,\iffreezecolors true\else false\fi)}%
+ {\ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}%
\dodefinecolorcommand\setvalue{#1}}
%D \macros
@@ -875,7 +879,7 @@
%D A bit like \type {\definedfont}:
\unexpanded\def\colored[#1]%
- {\ctxlua{colors.defineprocesscolor("@colored@","#1",false,false)}%
+ {\ctxcommand{defineprocesscolor("@colored@","#1",false,false)}%
\groupedcommand{\doactivatecolor{@colored@}}{}}
%D \macros
@@ -915,7 +919,8 @@
\ifx\maintextcolor\empty\else\doactivatecolor\maintextcolor\fi
\to \everybeforeoutput
-\def\registermaintextcolor{\ctxlua{colors.main = \thecolorattribute\maintextcolor}}
+\def\registermaintextcolor
+ {\ctxcommand{registermaintextcolor(\thecolorattribute\maintextcolor)}}
\unexpanded\def\starttextcolor[#1]%
{\doifsomething{#1}
@@ -937,18 +942,34 @@
\appendtoks \initializemaintextcolor \to \everyjob
\appendtoks \initializemaintextcolor \to \everysetupcolors
+\def\doinheritdirectcs#1{\csname(cs:\ifcsname(cs:#1)\endcsname#1\fi)\endcsname}
+\def\doinheritdirectca#1{\csname(ca:\ifcsname(ca:#1)\endcsname#1\fi)\endcsname}
+\def\doinheritdirectts#1{\csname(ts:\ifcsname(ts:#1)\endcsname#1\fi)\endcsname}
+\def\doinheritdirectta#1{\csname(ta:\ifcsname(ta:#1)\endcsname#1\fi)\endcsname}
+
+\def\doinheritpaletca#1#2{\csname(ca:\ifcsname(ca:\??pa#1:#2)\endcsname\??pa#1:#2\fi)\endcsname}
+\def\doinheritpaletcs#1#2{\csname(cs:\ifcsname(cs:\??pa#1:#2)\endcsname\??pa#1:#2\fi)\endcsname}
+\def\doinheritpaletta#1#2{\csname(ta:\ifcsname(ta:\??pa#1:#2)\endcsname\??pa#1:#2\fi)\endcsname}
+\def\doinheritpaletts#1#2{\csname(ts:\ifcsname(ts:\??pa#1:#2)\endcsname\??pa#1:#2\fi)\endcsname}
+
\def\dodefinepaletcolor#1#2#3%
{\doifassignmentelse{#3}% \definepalet[test][xx={y=.4}]
{\definecolor[\??pa#1:#2][#3]%
- \iffreezecolors\@EA\setevalue\else\@EA\setvalue\fi{(cs:#1:#2)}{\csname(cs:\??pa#1:#2)\endcsname}%
- \iffreezecolors\@EA\setevalue\else\@EA\setvalue\fi{(ca:#1:#2)}{\csname(ca:\??pa#1:#2)\endcsname}}
+ \dosetcolorvalue{(cs:#1:#2)}{\doinheritpaletca{#1}{#2}}%
+ \dosetcolorvalue{(ca:#1:#2)}{\doinheritpaletcs{#1}{#2}}%
+ \dosetcolorvalue{(ts:#1:#2)}{\doinheritpaletta{#1}{#2}}%
+ \dosetcolorvalue{(ta:#1:#2)}{\doinheritpaletts{#1}{#2}}}
{\ifcsname(cs:#3)\endcsname % \definepalet[test][xx=green]
- \iffreezecolors\@EA\setevalue\else\@EA\setvalue\fi{(cs:#1:#2)}{\csname(cs:#3)\endcsname}%
- \iffreezecolors\@EA\setevalue\else\@EA\setvalue\fi{(ca:#1:#2)}{\csname(ca:#3)\endcsname}%
+ \dosetcolorvalue{(cs:#1:#2)}{\doinheritdirectcs{#3}}%
+ \dosetcolorvalue{(ca:#1:#2)}{\doinheritdirectca{#3}}%
+ \dosetcolorvalue{(ts:#1:#2)}{\doinheritdirectts{#3}}%
+ \dosetcolorvalue{(ta:#1:#2)}{\doinheritdirectta{#3}}%
\else
% not entered when making format
\localundefine{(cs:#1:#2)}% \letvalue{(cs:#1:#2)}\undefined
\localundefine{(ca:#1:#2)}% \letvalue{(ca:#1:#2)}\undefined
+ \localundefine{(ts:#1:#2)}% \letvalue{(cs:#1:#2)}\undefined
+ \localundefine{(ta:#1:#2)}% \letvalue{(ca:#1:#2)}\undefined
\fi}}
\setvalue{(cs:)}{} \setvalue{(ca:)}{0}
@@ -962,7 +983,7 @@
%D Low level defs:
\def\colordefalc#1#2{\setevalue{(ca:#1)}{#2}\setvalue {(cs:#1)}{\attribute\colorattribute #2 }}
-\def\colordefagc#1#2{\setxvalue{(ca:#1)}{#2}\setvalue {(cs:#1)}{\attribute\colorattribute #2 }}
+\def\colordefagc#1#2{\setxvalue{(ca:#1)}{#2}\setgvalue{(cs:#1)}{\attribute\colorattribute #2 }} % was not g
\def\colordefalt#1#2{\setevalue{(ta:#1)}{#2}\setvalue {(ts:#1)}{\attribute\transparencyattribute#2 }}
\def\colordefagt#1#2{\setxvalue{(ta:#1)}{#2}\setgvalue{(ts:#1)}{\attribute\transparencyattribute#2 }}
@@ -995,28 +1016,28 @@
%D \getbuffer
%D \stopvoorbeeld
-\def\colorformatseparator{ }
-
-\def\MPcolor#1{\ctxlua{tex.sprint(colors.mp(\number\currentcolormodel,\number\doinheritca{#1},\number\doinheritta{#1}))}}
-
\let\currentcolorname\s!black % todo
\let\outercolorname \s!black % todo
+\let\colorformatseparator\space
+
+\def\MPcolor #1{\ctxcommand{mpcolor(\number\currentcolormodel,\number\doinheritca{#1},\number\doinheritta{#1})}}
+
\def\thecolorattribute #1{\number\csname(ca:\ifcsname(ca:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ca:#1)\endcsname#1\fi\fi)\endcsname}
\def\thetransparencyattribute#1{\number\csname(ta:\ifcsname(ta:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ta:#1)\endcsname#1\fi\fi)\endcsname}
-\def\internalspotcolorname #1{\ctxlua{tex.sprint(colors.spotcolorname (\thecolorattribute{#1}))}}
-\def\internalspotcolorparent#1{\ctxlua{tex.sprint(colors.spotcolorparent(\thecolorattribute{#1}))}}
-\def\internalspotcolorsize #1{\ctxlua{tex.sprint(colors.spotcolorvalue (\thecolorattribute{#1}))}}
+\def\internalspotcolorname #1{\ctxcommand{spotcolorname(\thecolorattribute{#1})}}
+\def\internalspotcolorparent #1{\ctxcommand{spotcolorparent(\thecolorattribute{#1})}}
+\def\internalspotcolorsize #1{\ctxcommand{spotcolorvalue(\thecolorattribute{#1})}}
-\def\colorcomponents #1{\ctxlua{tex.sprint(colors.colorcomponents (\thecolorattribute {#1}))}}
-\def\transparencycomponents#1{\ctxlua{tex.sprint(colors.transparencycomponents(\thetransparencyattribute{#1}))}}
+\def\colorcomponents #1{\ctxcommand{colorcomponents(\thecolorattribute{#1})}}
+\def\transparencycomponents #1{\ctxcommand{transparencycomponents(\thetransparencyattribute{#1})}}
-\def\colorvalue#1{\ctxlua{tex.sprint(colors.formatcolor(\thecolorattribute{#1},"\colorformatseparator"))}}
-\def\grayvalue #1{\ctxlua{tex.sprint(colors.formatgray (\thecolorattribute{#1},"\colorformatseparator"))}}
+\def\colorvalue #1{\ctxcommand{formatcolor(\thecolorattribute{#1},"\colorformatseparator")}}
+\def\grayvalue #1{\ctxcommand{formatgray (\thecolorattribute{#1},"\colorformatseparator")}}
-\def\doifblackelse #1{\ctxlua{commands.doifelse(colors.isblack(\thecolorattribute{#1}))}}
-\def\doifdrawingblackelse {\ctxlua{commands.doifelse(colors.isblack(tex.attribute[attributes.numbers['color']]))}}
+\def\doifblackelse #1{\ctxcommand{doifblackelse(\thecolorattribute{#1})}}
+\def\doifdrawingblackelse {\ctxcommand{doifdrawingblackelse()}}
%D \macros
%D {forcecolorhack}