diff options
Diffstat (limited to 'tex/context/base/colo-ini.mkiv')
-rw-r--r-- | tex/context/base/colo-ini.mkiv | 151 |
1 files changed, 101 insertions, 50 deletions
diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 6aa51b218..1eb3d8d7e 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -203,9 +203,9 @@ %D \usecolors[dem] %D \stoptyping -\unexpanded\def\startcolorset[#1]{\ctxcommand{startcolorset("#1")}} -\unexpanded\def\stopcolorset {\ctxcommand{stopcolorset()}} -\unexpanded\def\usecolors [#1]{\ctxcommand{usecolors("#1")}} +\unexpanded\def\startcolorset[#1]{\clf_startcolorset{#1}} +\unexpanded\def\stopcolorset {\clf_stopcolorset} +\unexpanded\def\usecolors [#1]{\clf_usecolors{#1}} \let\setupcolor\usecolors @@ -255,14 +255,14 @@ \colo_helpers_set_current_model \ifproductionrun \edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}% - \ctxcommand{synchronizecolormodel("\ifx\p_pagecolormodel\v!auto \currentcolormodel \else \p_pagecolormodel \fi")}% + \clf_setpagecolormodel{\ifx\p_pagecolormodel\v!auto\currentcolormodel\else\p_pagecolormodel\fi}% \fi \to \everysetupcolors \appendtoks \setupcolors[\c!state=\v!start]% - \ctxcommand{enablecolor()}% % this can as well happen when - \ctxcommand{enabletransparency()}% % the handler is defined in lua + \clf_enablecolor % this can as well happen when + \clf_enabletransparency % the handler is defined in lua \let\colo_helpers_show_message\showmessage \to \everyjob @@ -367,7 +367,7 @@ {\dodoubleargument\colo_palets_define} \unexpanded\def\colo_palets_define[#1][#2]% todo - {\doifassignmentelse{#2} + {\doifelseassignment{#2} {%\colo_helpers_show_message\m!colors6{#1}% \let\m_colo_palets_tmp\empty \setevalue{\??colorpaletspecification#1}{#2}% @@ -382,7 +382,7 @@ % {\colo_palets_define_two{#1}[#2]}% \def\colo_palets_define_one#1#2% get rid of { } - {\doifassignmentelse{#2} % catch empty entries + {\doifelseassignment{#2} % catch empty entries {\colo_palets_define_two{#1}[#2]} {\colo_palets_define_three{#1}{#2}}} @@ -563,7 +563,7 @@ \def\colo_helpers_set_model#1% direct {\edef\currentcolormodel{#1}% - \ctxcommand{setcolormodel('\currentcolormodel',\v_colo_weight_state)}} % sets attribute at lua end + \clf_setcolormodel{\currentcolormodel}\v_colo_weight_state\relax} % sets attribute at lua end \colo_helpers_set_model\s!all @@ -688,24 +688,42 @@ \attribute\colorattribute\attributeunsetvalue \attribute\transparencyattribute\attributeunsetvalue} +% todo: check if color is overloading a non-color command + +\newcount\c_colo_protection + +\unexpanded\def\startprotectedcolors + {\advance\c_colo_protection\plusone} + +\unexpanded\def\stopprotectedcolors + {\advance\c_colo_protection\minusone} + \def\colo_basics_define[#1][#2]% - {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colo_freeze_state)}% - \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} + {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax + \ifcase\c_colo_protection + \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}% + \fi} \def\colo_basics_define_global[#1][#2]% - {\ctxcommand{defineprocesscolor("#1","#2",true,\v_colo_freeze_state)}% - \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}} + {\clf_defineprocesscolorglobal{#1}{#2}\v_colo_freeze_state\relax + \ifcase\c_colo_protection + \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}% + \fi} \def\colo_basics_define_named[#1][#2]% currently same as define - {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colo_freeze_state)}% - \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} + {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax + \ifcase\c_colo_protection + \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}% + \fi} \def\dodefinefastcolor[#1][#2]% still not fast but ok (might change) - {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colo_freeze_state)}% - \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} + {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax + \ifcase\c_colo_protection + \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}% + \fi} \def\colo_basics_defined_and_activated#1% - {\ctxcommand{defineprocesscolor("\v_colo_dummy_name","#1",false,false)}% + {\clf_defineprocesscolordummy{#1}% \colo_helpers_activate_dummy} \def\colo_basics_define_process @@ -716,12 +734,16 @@ \fi} \def\colo_basics_define_process_yes[#1][#2][#3]% - {\ctxcommand{defineprocesscolor("#1","\processcolorcomponents{#2},#3",false,\v_colo_freeze_state)}% - \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} + {\clf_defineprocesscolorlocal{#1}{\processcolorcomponents{#2},#3}\v_colo_freeze_state\relax + \ifcase\c_colo_protection + \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}% + \fi} \def\colo_basics_define_process_nop[#1][#2][#3]% - {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colo_freeze_state)}% - \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} + {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax + \ifcase\c_colo_protection + \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}% + \fi} % Spotcolors used setxvalue but that messes up currentcolor % and probably no global is needed either but they are global @@ -729,17 +751,21 @@ % spot colors often are a document wide property \def\colo_basics_define_spot[#1][#2][#3]% - {\ctxcommand{definespotcolor("#1","#2","#3",true)}% - \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}} + {\clf_definespotcolorglobal{#1}{#2}{#3}% + \ifcase\c_colo_protection + \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}% + \fi} \def\colo_basics_define_multitone[#1][#2][#3][#4]% - {\ctxcommand{definemultitonecolor("#1","#2","#3","#4",true)}% - \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}} + {\clf_definemultitonecolorglobal{#1}{#2}{#3}{#4}% + \ifcase\c_colo_protection + \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}% + \fi} %D Transparencies (only): \def\colo_basics_define_transpancy[#1][#2]% - {\ctxcommand{definetransparency("#1",#2)}} + {\clf_definetransparency{#1}#2\relax} % A goodie that replaces the startMPcolor hackery @@ -791,10 +817,15 @@ {\colo_basics_define_intermediate_indeed[#1][#2][#3]} \def\colo_basics_define_intermediate_indeed[#1][#2,#3,#4][#5]% - {\ctxcommand{defineintermediatecolor("#1","#2", - \thecolorattribute{#3},\thecolorattribute{#4}, - \thetransparencyattribute{#3},\thetransparencyattribute{#4}, - "#5",false,\v_colo_freeze_state)}% not global + {\clf_defineintermediatecolor % not global + {#1}{#2}% + \thecolorattribute{#3} % + \thecolorattribute{#4} % + \thetransparencyattribute{#3} % + \thetransparencyattribute{#4} % + {#5}% + \v_colo_freeze_state + \relax \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} %D Here is a more efficient helper for pgf: @@ -833,8 +864,10 @@ %D %D \stopmode -\def\pgf@context@registercolor#1% bonus macro - {\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\ctxcommand{pgfxcolorspec(\thecolorattribute{#1})}}} +\def\pgf@context@registercolor#1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\zerocount\thecolorattribute{#1}}} +\def\pgf@context@registergray #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plustwo \thecolorattribute{#1}}} +\def\pgf@context@registerrgb #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusthree\thecolorattribute{#1}}} +\def\pgf@context@registercmyk #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusfour \thecolorattribute{#1}}} %D \starttyping %D \ifdefined\pgf@context@registercolor @@ -849,7 +882,7 @@ %D command. Later on we will explain the use of palets. We %D define ourselves a color conditional first. -\def\doifcolorelse#1% +\def\doifelsecolor#1% {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname \expandafter\firstoftwoarguments \else\ifcsname\??colorattribute#1\endcsname @@ -858,6 +891,8 @@ \doubleexpandafter\secondoftwoarguments \fi\fi} +\let\doifcolorelse\doifelsecolor + \def\doifcolor#1% {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname \expandafter\firstofoneargument @@ -916,7 +951,7 @@ {\let\maintextcolor\s!themaintextcolor \definecolor[\maintextcolor][#1]% can be fast one \colo_helpers_activate\maintextcolor - \ctxcommand{registermaintextcolor(\thecolorattribute\maintextcolor)}} + \clf_registermaintextcolor\thecolorattribute\maintextcolor\relax} \unexpanded\def\starttextcolor[#1]% {\doifsomething{#1} @@ -958,7 +993,7 @@ \to \everysetupcolors \def\colo_palets_define_set#1#2#3% - {\doifassignmentelse{#3}% \definepalet[test][xx={y=.4}] + {\doifelseassignment{#3}% \definepalet[test][xx={y=.4}] {\definecolor[\??colorpalet#1:#2][#3]% \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_palet_ca{#1}{#2}}% \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_palet_cs{#1}{#2}}% @@ -1029,27 +1064,43 @@ \let\colorformatseparator\space -\def\MPcolor #1{\ctxcommand{mpcolor(\number\attribute\colormodelattribute,\number\colo_helpers_inherited_current_ca{#1},\number\colo_helpers_inherited_current_ta{#1})}} -\def\MPoptions #1{\ctxcommand{mpoptions(\number\attribute\colormodelattribute,\number\colo_helpers_inherited_current_ca{#1},\number\colo_helpers_inherited_current_ta{#1})}} +\def\MPcolor#1% + {\clf_mpcolor + \attribute\colormodelattribute + \colo_helpers_inherited_current_ca{#1} % + \colo_helpers_inherited_current_ta{#1} } + + +\def\MPoptions#1% + {\clf_mpoptions + \attribute\colormodelattribute + \colo_helpers_inherited_current_ca{#1} % + \colo_helpers_inherited_current_ta{#1} } + \def\thecolorattribute #1{\number\csname\??colorattribute \ifcsname\??colorattribute \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorattribute #1\endcsname#1\fi\fi\endcsname} \def\thetransparencyattribute#1{\number\csname\??transparencyattribute\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencyattribute#1\endcsname#1\fi\fi\endcsname} - \def\thecolormodelattribute {\the\attribute\colormodelattribute} -\def\internalspotcolorname #1{\ctxcommand{spotcolorname(\thecolorattribute{#1})}} -\def\internalspotcolorparent #1{\ctxcommand{spotcolorparent(\thecolorattribute{#1})}} -\def\internalspotcolorsize #1{\ctxcommand{spotcolorvalue(\thecolorattribute{#1})}} +\def\internalspotcolorname #1{\clf_spotcolorname \thecolorattribute{#1} } +\def\internalspotcolorparent #1{\clf_spotcolorparent\thecolorattribute{#1} } +\def\internalspotcolorsize #1{\clf_spotcolorvalue \thecolorattribute{#1} } + +\def\colorcomponents #1{\clf_colorcomponents \thecolorattribute {#1} } +\def\transparencycomponents #1{\clf_transparencycomponents\thetransparencyattribute{#1} } +\def\processcolorcomponents #1{\clf_processcolorcomponents\thecolorattribute {#1} } + +\def\colorvalue #1{\clf_formatcolor\thecolorattribute{#1}{\colorformatseparator}} +\def\grayvalue #1{\clf_formatgray \thecolorattribute{#1}{\colorformatseparator}} -\def\colorcomponents #1{\ctxcommand{colorcomponents(\thecolorattribute{#1})}} -\def\transparencycomponents #1{\ctxcommand{transparencycomponents(\thetransparencyattribute{#1})}} -\def\processcolorcomponents #1{\ctxcommand{processcolorcomponents(\thecolorattribute{#1},",")}} +\def\doifelseblack #1{\clf_doifelseblack\thecolorattribute{#1} } +\def\doifelsedrawingblack {\clf_doifelsedrawingblack} -\def\colorvalue #1{\ctxcommand{formatcolor(\thecolorattribute{#1},"\colorformatseparator")}} -\def\grayvalue #1{\ctxcommand{formatgray (\thecolorattribute{#1},"\colorformatseparator")}} +\let\doifblackelse \doifelseblack +\let\doifdrawingblackelse \doifelsedrawingblack -\def\doifblackelse #1{\ctxcommand{doifblackelse(\thecolorattribute{#1})}} -\def\doifdrawingblackelse {\ctxcommand{doifdrawingblackelse()}} +\let\doifblackelse \doifelseblack +\let\doifdrawingblackelse\doifelsedrawingblack %D \macros %D {forcecolorhack} @@ -1071,7 +1122,7 @@ % \normal added else fails in metafun manual (leaders do a hard scan) -\unexpanded\def\forcecolorhack{\leaders\hrule\hskip\zeropoint} +\unexpanded\def\forcecolorhack{\leaders\hrule\hskip\zeropoint\relax} % relax is needed ! %D We default to the colors defined in \type {colo-imp-rgb} and %D support both \RGB\ and \CMYK\ output. Transparencies are defined |