diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
commit | 15995e10bfc68edf79970c4ea4fbb6678566c46e (patch) | |
tree | 2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/colo-ini.mkiv | |
parent | c9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff) |
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/colo-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/colo-ini.mkiv | 1028 |
1 files changed, 440 insertions, 588 deletions
diff --git a/Master/texmf-dist/tex/context/base/colo-ini.mkiv b/Master/texmf-dist/tex/context/base/colo-ini.mkiv index 45fe1463383..164b39262ff 100644 --- a/Master/texmf-dist/tex/context/base/colo-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/colo-ini.mkiv @@ -5,13 +5,13 @@ %D subtitle=Initialization, %D author=Hans Hagen, %D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D We need to clean this up further but first we hav eto make sure that mkiv +%D We need to clean this up further but first we have to make sure that mkiv %D code works ok. \writestatus{loading}{ConTeXt Color Macros / Initialization} @@ -26,72 +26,49 @@ %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 efficient to combine them (less attributes and finalizing). If +%D it becomes a bottleneck we can set up a more complex system +%D with one shared attribute for colorspace, color and transparency. %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 -%D switches on a 1G machine, but the macros will become rather -%D ugly then. To mention one such improvement: no colon -%D after the key character (.25 sec). - -\newcount\colorcount - -%D When typesetting for paper, we prefer using the \cap{CMYK} -%D color space, but for on||screen viewing we prefer \cap{RGB} -%D (the previous implementation supported only this scheme). -%D Independant of such specifications, we support some automatic -%D conversions: +%D When typesetting for paper, we prefer using the \CMYK\ color space, +%D but for on||screen viewing we prefer \RGB\ (the previous +%D implementation supported only this scheme). Independant of such +%D specifications, we support some automatic conversions: %D %D \startitemize[packed] -%D \item convert all colors to \cap{RGB} -%D \item convert all colors to \cap{CMYK} +%D \item convert all colors to \RGB +%D \item convert all colors to \CMYK %D \item convert all colors to gray scales %D \stopitemize %D -%D We also support optimization of colors to gray scales. -%D -%D \startitemize[continue] -%D \item reduce gray colors to gray scales -%D \item reduce \cap{CMY} components to \cap{K} -%D \stopitemize -%D %D These options are communicated by means of: -\newif\ifRGBsupported -\newif\ifCMYKsupported -\newif\ifSPOTsupported -\newif\ifpreferGRAY -\newif\ifGRAYprefered -\newif\ifconvertGRAY \convertGRAYtrue -\newif\ifreduceCMYK -\newif\ifconverttoGRAY -\newif\ifweightGRAY \weightGRAYtrue - -\newif\ifconvertMPcolors -\newif\ifreduceMPcolors -\newif\ifforcegrayMPcolors - -%D The last boolean controls reduction of \cap{CMYK} to -%D \cap{CMY} colors. When set to true, the black component -%D is added to the other ones. -%D -%D Prefering gray is not the same as converting to gray. -%D Conversion treats each color components in a different way, -%D while prefering is just a reduction and thus a -%D space||saving option. - -\newif\iffreezecolors \freezecolorsfalse -\newif\ifincolor % true if colors enabled - -\let\colorlist \empty -\let\currentspotcolor \empty -\let\allspotcolors \empty -\let\usedspotcolors \empty -\let\currentpalet \empty +\newconditional\c_colo_rgb_supported +\newconditional\c_colo_cmyk_supported +\newconditional\c_colo_spot_supported % backend driven +\newconditional\c_colo_weight_gray \settrue\c_colo_weight_gray +\newconditional\c_colo_convert_gray \settrue\c_colo_convert_gray +\newconditional\c_colo_enabled +\newconditional\c_colo_expanded + +\let\currentcolormodel \empty +\let\currentcolorname \empty +\let\currentcolorpalet \empty +\let\currentcolorprefix\empty % \currentcolorpalet: + +\installcorenamespace{color} +\installcorenamespace{colorattribute} +\installcorenamespace{transparencyattribute} +\installcorenamespace{colorsetter} +\installcorenamespace{transparencysetter} +\installcorenamespace{colorpaletspecification} +\installcorenamespace{colorpalet} +\installcorenamespace{colorstack} +\installcorenamespace{colorconversions} %D \macros -%D {definecolor,defineglobalcolor,definenamedcolor,definespotcolor,definemultitonecolor} +%D {definecolor,defineglobalcolor,definenamedcolor,definespotcolor,definemultitonecolor, +%D definetransparency} %D %D \startbuffer %D \definecolor [blue] [c=1,m=.38,y=0,k=.64] % pantone pms 2965 uncoated m @@ -114,83 +91,80 @@ %D %D \getbuffer \typebuffer -\unexpanded\def\definecolor {\dodoubleargument\dodefinecolor} -\unexpanded\def\defineglobalcolor {\dodoubleargument\dodefineglobalcolor} -\unexpanded\def\definenamedcolor {\dodoubleargument\dodefinenamedcolor} -\unexpanded\def\definespotcolor {\dotripleargument\dodefinespotcolor} -\unexpanded\def\definemultitonecolor{\doquadrupleempty\dodefinemultitonecolor} +\unexpanded\def\definecolor {\dodoubleargument\colo_basics_define} +\unexpanded\def\defineglobalcolor {\dodoubleargument\colo_basics_define_global} +\unexpanded\def\definenamedcolor {\dodoubleargument\colo_basics_define_named} +\unexpanded\def\definespotcolor {\dotripleargument\colo_basics_define_spot} +\unexpanded\def\definemultitonecolor{\doquadrupleempty\colo_basics_define_multitone} +\unexpanded\def\definetransparency {\dodoubleargument\colo_basics_define_transpancy} %D \macros -%D {startcolor,stopcolor, -%D faststartcolor,faststopcolor, -%D startraster,stopraster,raster, -%D color,graycolor} +%D {startcolor,stopcolor,color,graycolor} %D -%D The local and global and raster commands are here just -%D for compatibility with \MKII. +%D The local and global commands are here just for compatibility +%D with \MKII. %D %D \showsetup{startcolor} %D -%D \macros -%D {color,graycolor} -%D -%D This leaves the simple color command: -%D -%D \showsetup{color} -%D \showsetup{graycolor} -%D -%D This leaves the simple color command: +%D The simple color commands are: %D %D \showsetup{color} %D \showsetup{graycolor} -\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} -\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}}} +%D We expect sane behaviour in \MKIV\ so we don't used grouped command any +%D longer. -\let\grey\graycolor +% \testfeatureonce{100000}{\color[red]{}} % 1.046 => 0.541 -%D Stacking: +\unexpanded\def\switchtocolor[#1]{\csname#1\endcsname} -% \colormodelattribute \colorattribute \transparencyattribute +\unexpanded\def\color [#1]{\bgroup + \def\g_color{\colo_helpers_activate{#1}}% + \afterassignment\g_color + \let\nexttoken} -\newcount\currentcolornesting +\unexpanded\def\graycolor [#1]{\bgroup + \def\g_color{\colo_helpers_set_model\s!gray\colo_helpers_activate{#1}}% + \afterassignment\g_color + \let\nexttoken} -\unexpanded\def\pushcolor[#1]% - {\global\advance\currentcolornesting\plusone - \expandafter\edef\csname\??cl:s:\number\currentcolornesting\endcsname - {\attribute\colormodelattribute \the\attribute\colormodelattribute - \attribute\colorattribute \the\attribute\colorattribute - \attribute\transparencyattribute\the\attribute\transparencyattribute - \space}% stack - \doactivatecolor{#1}} +\unexpanded\def\startcolor [#1]{\begingroup + \colo_helpers_activate{#1}} -\unexpanded\def\popcolor - {\csname\??cl:s:\number\currentcolornesting\endcsname - \global\advance\currentcolornesting\minusone} +\unexpanded\def\stopcolor {\endgroup} + +\unexpanded\def\colored [#1]{\bgroup + \def\g_color{\colo_basics_defined_and_activated{#1}}% + \afterassignment\g_color + \let\nexttoken} + +\unexpanded\def\fastcolored[#1]#2{\begingroup % is this command still needed? + \colo_basics_defined_and_activated{#1}% + #2% + \endgroup} + +\unexpanded\def\directcolored[#1]{\colo_basics_defined_and_activated{#1}} + +\unexpanded\def\fastcolor [#1]#2{\begingroup % is this command still needed? + \colo_helpers_activate{#1}% + #2% + \endgroup} + +\unexpanded\def\directcolor [#1]{\colo_helpers_activate{#1}} + + +%D The following command is obsolete: + +\unexpanded\def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]} +\unexpanded\def\stopcolorpage {\stopcolor} + +\def\getcolorattributevalue#1#2% obsolete, use \thecolorattribute instead ... + {\begingroup + \colo_helpers_activate{#1}% + \normalexpanded{\endgroup\edef\noexpand#2% + {\ifnum\attribute\colorattribute=\attributeunsetvalue\else\number\attribute\colorattribute\fi}}} + +\let\grey\graycolor % these macros are only used in tracing %D \macros %D {startcurrentcolor,stopcurrentcolor} @@ -204,106 +178,102 @@ %D Color definitions can be grouped in files with the name: %D %D \starttyping -%D \f!colorprefix-identifier.tex +%D colo-imp-tag.tex %D \stoptyping %D -%D where \type{\f!colorprefix} is \unprotect {\tttf \f!colorprefix}. -%D Loading such a file is done by \protect +%D Loading such a file is done by: %D %D \showsetup{usecolors} %D -%D Some default colors are specified in \type{colo-rgb.tex}, -%D which is loaded into the format by: +%D Some default colors are specified in \type {colo-imp-rgb}, +%D which is loaded into the format by default. +%D +%D Some demo palets and groups are defined in \type {colo-imp-dem} +%D which can be loaded with: %D %D \starttyping -%D \usecolors[rgb] +%D \usecolors[dem] %D \stoptyping -\unexpanded\def\usecolors[#1]{\ctxcommand{usecolors(\!!bs#1\!!es)}} +\unexpanded\def\startcolorset[#1]{\ctxcommand{startcolorset("#1")}} +\unexpanded\def\stopcolorset {\ctxcommand{stopcolorset()}} +\unexpanded\def\usecolors [#1]{\ctxcommand{usecolors("#1")}} \let\setupcolor\usecolors -%D \macros -%D {definetransparency} -%D -%D This command numbers to names: +\installsetuponlycommandhandler \??color {colors} -\unexpanded\def\definetransparency - {\dodoubleargument\dodefinetransparency} +\let\colo_helpers_show_message\gobblethreearguments -\unexpanded\def\setupcolors - {\dosingleargument\dosetupcolors} +% \newtoks\everysetupcolors -\let\showcolormessage\gobblethreearguments +\let\v_colo_freeze_state\s!false +\let\v_colo_weight_state\s!false -\newtoks\everysetupcolors +\setvalue{\??colorconversions\v!yes}% + {\settrue \c_colo_convert_gray} -\let\dosetcolorvalue \setvalue -\def\colorfreezestate{false} +\setvalue{\??colorconversions\v!always}% + {\settrue \c_colo_convert_gray + \setfalse\c_colo_rgb_supported + \setfalse\c_colo_cmyk_supported} -\def\dosetupcolors[#1]% some no longer make sense in MkIV - {\getparameters[\??cl][#1]% - \doifelse\@@clspot\v!yes - \SPOTsupportedtrue - \SPOTsupportedfalse - \doifelse\@@clreduction\v!yes - \reduceCMYKtrue - \reduceCMYKfalse - \doifelse\@@clexpansion\v!yes - \freezecolorstrue - \freezecolorsfalse - \iffreezecolors - \let\dosetcolorvalue\setevalue - \def\colorfreezestate{true}% +\appendtoks + % + \doifelse{\directcolorsparameter\c!spot }\v!yes \settrue \setfalse\c_colo_spot_supported + \doifelse{\directcolorsparameter\c!expansion}\v!yes \settrue \setfalse\c_colo_expanded + \doifelse{\directcolorsparameter\c!factor }\v!no \setfalse\settrue \c_colo_weight_gray + \doifelse{\directcolorsparameter\c!rgb }\v!yes \settrue \setfalse\c_colo_rgb_supported + \doifelse{\directcolorsparameter\c!cmyk }\v!yes \settrue \setfalse\c_colo_cmyk_supported + \doifelse{\directcolorsparameter\c!state }\v!start\settrue \setfalse\c_colo_enabled + % + \ifconditional\c_colo_weight_gray + \let\v_colo_weight_state\s!true \else - \let\dosetcolorvalue\setvalue - \def\colorfreezestate{false}% + \let\v_colo_weight_state\s!false \fi - \doifelse\@@clfactor\v!no - \weightGRAYfalse - \weightGRAYtrue - \doifelse\@@clrgb\v!no - {\ifRGBsupported \showcolormessage\m!colors {9}\v!rgb \RGBsupportedfalse \fi} - {\ifRGBsupported \else\showcolormessage\m!colors{10}\v!rgb \RGBsupportedtrue \fi}% - \doifelse\@@clcmyk\v!no - {\ifCMYKsupported \showcolormessage\m!colors {9}\v!cmyk \CMYKsupportedfalse\fi} - {\ifCMYKsupported\else\showcolormessage\m!colors{10}\v!cmyk \CMYKsupportedtrue \fi}% - \doifelse\@@clmpcmyk\v!no - {\ifMPcmykcolors \showcolormessage\m!colors {9}{\v!mp\v!cmyk}\MPcmykcolorsfalse \fi} - {\ifMPcmykcolors \else\showcolormessage\m!colors{10}{\v!mp\v!cmyk}\MPcmykcolorstrue \fi}% - \doifelse\@@clmpspot\v!no - {\ifMPspotcolors \showcolormessage\m!colors {9}{\v!mp\v!spot}\MPspotcolorsfalse \fi} - {\ifMPspotcolors \else\showcolormessage\m!colors{10}{\v!mp\v!spot}\MPspotcolorstrue \fi}% - \preferGRAYfalse - \convertGRAYtrue - \processaction - [\@@clconversion] - [ \v!yes=>\preferGRAYtrue, - \v!no=>\convertGRAYfalse, - \v!never=>\convertGRAYfalse, - \v!always=>\preferGRAYtrue\RGBsupportedfalse\CMYKsupportedfalse]% - \ifRGBsupported - \converttoGRAYfalse - \forcegrayMPcolorsfalse - \else\ifCMYKsupported - \converttoGRAYfalse - \forcegrayMPcolorsfalse - \convertMPcolorstrue - \ifreduceCMYK - \reduceMPcolorstrue - \fi + % + \ifconditional\c_colo_expanded + \let\v_colo_freeze_state\s!true \else - \ifconverttoGRAY\else\showcolormessage\m!colors{11}\empty\fi - \converttoGRAYtrue - \forcegrayMPcolorstrue - \convertMPcolorsfalse - \reduceMPcolorsfalse - \fi\fi - \doifelse\@@clstate\v!stop - {\incolorfalse\forcegrayMPcolorstrue}% - {\incolortrue\let\@@clstate\v!start}% - \dosetupcolormodel - \the\everysetupcolors} + \let\v_colo_freeze_state\s!false + \fi + % + \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 + \colo_helpers_set_current_model + \ifproductionrun + \edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}% + \ctxcommand{synchronizecolormodel("\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 + \let\colo_helpers_show_message\showmessage +\to \everyjob + +%D We provide stacking independent of grouping. + +\newcount\c_colo_nesting + +\unexpanded\def\pushcolor[#1]% + {\global\advance\c_colo_nesting\plusone + \expandafter\edef\csname\??colorstack\number\c_colo_nesting\endcsname + {\attribute\colormodelattribute \the\attribute\colormodelattribute + \attribute\colorattribute \the\attribute\colorattribute + \attribute\transparencyattribute\the\attribute\transparencyattribute + \relax}% stack + \colo_helpers_activate{#1}} + +\unexpanded\def\popcolor + {\csname\??colorstack\number\c_colo_nesting\endcsname + \global\advance\c_colo_nesting\minusone} %D In this documentation we will not go into too much details %D on palets. Curious users can find more information on this @@ -370,29 +340,34 @@ %D This saves us some typing in for instance the modules that %D deal with pretty verbatim typesetting. +\let\m_colo_palets_tmp\empty + \unexpanded\def\definepalet - {\dodoubleargument\dodefinepalet} + {\dodoubleargument\colo_palets_define} -\def\dodefinepalet[#1][#2]% +\unexpanded\def\colo_palets_define[#1][#2]% todo {\doifassignmentelse{#2} - {%\showcolormessage\m!colors6{#1}% - \letvalueempty{\??pa#1}% - \setevalue{\??pa\??pa#1}{#2}% - \def\dodododefinepalet[##1=##2]% - {\doifvaluesomething{\??pa#1} - {\setevalue{\??pa#1}{\csname\??pa#1\endcsname,}}% - \setevalue{\??pa#1}{\csname\??pa#1\endcsname##1}% - \dodefinepaletcolor{#1}{##1}{##2}}% - \def\dododefinepalet##1% - {\dodododefinepalet[##1]}% - \processcommalist[#2]\dododefinepalet} - {\doifdefined{\??pa#2} - {\expanded{\dodefinepalet[#1][\csname\??pa\??pa#2\endcsname]}}}} + {%\colo_helpers_show_message\m!colors6{#1}% + \let\m_colo_palets_tmp\empty + \setevalue{\??colorpaletspecification#1}{#2}% + \processcommalist[#2]{\colo_palets_define_one{#1}}% + \letvalue{\??colorpalet#1}\m_colo_palets_tmp + \let\m_colo_palets_tmp\empty} + {\ifcsname\??colorpaletspecification#2\endcsname + \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_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}}% \let\paletsize\!!zerocount \def\getpaletsize[#1]% - {\getcommacommandsize[\csname\??pa\??pa#1\endcsname]% + {\getcommacommandsize[\csname\??colorpaletspecification#1\endcsname]% \edef\paletsize{\number\commalistsize}} %D Instead of refering to colors, one can also directly specify @@ -411,22 +386,25 @@ %D %D \showsetup{setuppalet} -\let\currentpalet\empty +\newtoks\everysetuppalet \unexpanded\def\setuppalet - {\dosingleempty\dosetuppalet} + {\dosingleempty\colo_palets_setup} -\def\dosetuppalet[#1]% - {\edef\currentpalet{#1}% - \ifx\currentpalet\empty +\def\colo_palets_setup[#1]% + {\edef\currentcolorpalet{#1}% + \ifx\currentcolorpalet\empty % seems to be a reset - \else\ifcsname\??pa\currentpalet\endcsname - \edef\currentpalet{#1:}% + \let\currentcolorprefix\empty + \else\ifcsname\??colorpalet\currentcolorpalet\endcsname + \edef\currentcolorprefix{#1:}% \else - \showcolormessage\m!colors7\currentpalet - \let\currentpalet\empty + \colo_helpers_show_message\m!colors7\currentcolorpalet + \let\currentcolorpalet\empty + \let\currentcolorprefix\empty \fi\fi - \initializemaintextcolor} + \the\everysetuppalet + \colo_helpers_initialize_maintextcolor} %D \macros %D {showpalet} @@ -451,120 +429,6 @@ \fetchruntimecommand \showcolorcomponents {\f!colorprefix\s!run} %D \macros -%D {definecolorgroup} -%D -%D The naming of the colors in this palet suggests some -%D ordening, which in turn is suported by color grouping. -%D -%D \starttyping -%D \definecolorgroup -%D [red] -%D [1.00:0.90:0.90, -%D 1.00:0.80:0.80, -%D 1.00:0.70:0.70, -%D 1.00:0.55:0.55, -%D 1.00:0.40:0.40, -%D 1.00:0.25:0.25, -%D 1.00:0.15:0.15, -%D 0.90:0.00:0.00] -%D \stoptyping -%D -%D In such a color group colors are numbered from~$1$ to~$n$. -%D -%D \showsetup{definecolorgroup} -%D -%D This kind of specification is not only more compact than -%D defining each color separate, it also loads faster and takes -%D less bytes. - -\unexpanded\def\definecolorgroup - {\dotripleempty\dodefinecolorgroup} - -\def\dododefinecolorgroupgray [#1][#2:#3]{\definecolor [#1:\the\colorcount][s=#2]} -\def\dododefinecolorgrouprgb [#1][#2:#3:#4:#5]{\definecolor [#1:\the\colorcount][r=#2,g=#3,b=#4]} -\def\dododefinecolorgroupcmyk[#1][#2:#3:#4:#5:#6]{\definecolor [#1:\the\colorcount][c=#2,m=#3=,y=#4,k=#5]} -\def\dododefinecolorgroupspot [#1][#2:#3:#4]{\definespotcolor[#1:\the\colorcount][#2][p=#3]} - -\def\dododefinecolorgroup#1#2% - {\advance\colorcount\plusone - \getvalue{dododefinecolorgroup\currentcolorspace}[#1][#2:0:0:0:0]} - -\def\dodefinecolorgroup[#1][#2][#3]% obsolete, just use palets - {\ifthirdargument - \doifelsenothing{#2}{\let\currentcolorspace\v!rgb}{\def\currentcolorspace{#2}}% - \colorcount\zerocount - \processcommalist[#3]{\dododefinecolorgroup{#1}}% - \else - \doifinstringelse{:}{#2} - {\definecolorgroup[#1][\v!rgb][#2]} - {\doloop - {\ifcsname\??cr#2:\recurselevel\endcsname - \setevalue{\??cr#1:\recurselevel}{\csname\??cr#2:\recurselevel\endcsname}% - \else - \exitloop - \fi}}% - \fi} - -%D \macros -%D {showcolorgroup} -%D -%D We can show the group by: -%D -%D \startbuffer -%D \showcolorgroup [blue] [horizontal,name,number,value] -%D \stopbuffer -%D -%D \typebuffer -%D -%D or in color: -%D -%D \startlinecorrection -%D \getbuffer -%D \stoplinecorrection -%D -%D which uses: -%D -%D \showsetup{showcolorgroup} - -\fetchruntimecommand \showcolorgroup {\f!colorprefix\s!run} - -%D There are ten predefined color groups, like -%D \color[green]{\em groen}, \color[red]{\em rood}, -%D \color[blue]{\em blauw}, \color[cyan]{\em cyaan}, -%D \color[magenta]{\em magenta} and \color[yellow]{\em geel}. -%D -%D \startlinecorrection -%D \hbox to \hsize -%D {\hss -%D \showcolorgroup [red] [vertical,name,number]\hss -%D \showcolorgroup [green] [vertical,name]\hss -%D \showcolorgroup [blue] [vertical,name]\hss -%D \showcolorgroup [cyan] [vertical,name]\hss -%D \showcolorgroup [magenta][vertical,name]\hss -%D \showcolorgroup [yellow] [vertical,name]\hss} -%D \stoplinecorrection -%D -%D These groups are used to define palets {\em alfa} upto {\em -%D zeta}. As long as we don't use colors from the same row, we -%D get ourselves distinctive palets. By activating such a palet -%D one gains access to its members {\em top} to {\em charm} (of -%D course one should use more suitable names than these). -%D -%D \startlinecorrection -%D \hbox to \hsize -%D {\showpalet [alfa] [vertical,name,number]\hss -%D \showpalet [beta] [vertical,name]\hss -%D \showpalet [gamma] [vertical,name]\hss -%D \showpalet [delta] [vertical,name]\hss -%D \showpalet [epsilon] [vertical,name]\hss -%D \showpalet [zeta] [vertical,name]} -%D \stoplinecorrection -%D -%D By using the keyword \type {value} the individual color -%D components are shown too. When printed in color, these -%D showcases show both the colors and the gray value. - -%D \macros %D {comparepalet} %D %D There are some more testing macros available: @@ -588,29 +452,6 @@ \fetchruntimecommand \comparepalet {\f!colorprefix\s!run} %D \macros -%D {comparecolorgroup} -%D -%D The similar command: -%D -%D \startbuffer -%D \comparecolorgroup [blue] -%D \stopbuffer -%D -%D \typebuffer -%D -%D shows color groups: -%D -%D \startlinecorrection -%D \getbuffer -%D \stoplinecorrection -%D -%D this commands are defined as: -%D -%D \showsetup{comparecolorgroup} - -\fetchruntimecommand \comparecolorgroup {\f!colorprefix\s!run} - -%D \macros %D {showcolor} %D %D But let's not forget that we also have the more traditional @@ -652,7 +493,7 @@ {\edef#1{\negatedcolorcomponent{#1}}} %D \macros -%D {ifMPgraphics, ifMPcmykcolors, MPcolor} +%D {MPcolor} %D %D A very special macro is \type{\MPcolor}. This one can be %D used to pass a \CONTEXT\ color to \METAPOST. @@ -661,53 +502,22 @@ %D \MPcolor{my own red} %D \stoptyping %D -%D This macro returns a \METAPOST\ triplet \type{(R,G,B)}. -%D Unless \CMYK\ color support is turned on with \type -%D {MPcmyk}, only \cap{RGB} colors and gray scales are -%D supported. - -\newif\ifMPcmykcolors % \MPcmykcolorsfalse -\newif\ifMPspotcolors % \MPspotcolorsfalse - -\ifx\MPcolor\undefined - \def\MPcolor#1{(0,0,0)} -\fi - +%D This macro returns \METAPOST\ code that represents the +%D color. +%D %D For the moment we keep the next downward compatibility %D switch, i.e.\ expanded colors. However, predefined colors %D and palets are no longer expanded (which is what I wanted %D in the first place). %D -%D Well, in case we want to do color separation and use CMYK -%D colors only, this is dangerous since unwanted remapping may -%D take place. Especially when we redefine already defined -%D colors in another color space (e.g. darkgreen is -%D predefined in RGB color space, so a redefinition in CMYK -%D coordinates before RGB mode is disabled, would give -%D unexpected results due to the already frozen color spec.) - -%D In \MKIV\ we don't support color separation as we might now assume -%D that printing houses have the right programs to do it themselves. -%D The \MKII\ color separator was implemented as part of a project -%D that needed. If it's ever needed in \MKIV\ i'll do it in the -%D backend. - -\let\doifseparatingcolorselse\secondoftwoarguments -\let\doifcolorchannelelse \secondofthreearguments -\let\resetcolorseparation \relax -\let\colorchannelprefix \empty -\let\colorchannelsuffix \empty - -%D We now define the low level macros: +%D In \MKIV\ we don't support color separation as we might now +%D assume that printing houses have the right programs to do +%D it themselves. If it's ever needed in \MKIV\ It is relatively +%D easy to support it in the backend code. % todo: palets in definecolor % todo: {\red xx} vs \red{xx} -% check: registerusedspotcolors -% check: \currentcolorname -% check: \outercolorname -% check: \startcolormode - % \def\mptexcolor#1{"\dogetattributeid\s!color \somecolorattribute{#1} A"} % % \startMPpage @@ -717,46 +527,42 @@ % draw btex test etex withprescript \mptexcolor{blue} ; % \stopMPpage -% \ifx\currentcolormodel\undefined \newcount\currentcolormodel \fi - -\def\currentcolormodel{\attribute\colormodelattribute} +\unexpanded\def\setcolormodel[#1]% % beware, \setupcolors will overload this, so this one is + {\colo_helpers_set_model{#1}} % only for local usage -\def\dosetcolormodel#1% no message - {\ctxcommand{setcolormodel('#1',\ifweightGRAY true\else false\fi)}} % sets attribute +\def\colo_helpers_set_model#1% direct + {\edef\currentcolormodel{#1}% + \ctxcommand{setcolormodel('\currentcolormodel',\v_colo_weight_state)}} % sets attribute at lua end -\dosetcolormodel{all} +\colo_helpers_set_model\s!all -\def\dosetupcolormodel - {\ifincolor - \ifRGBsupported - \ifCMYKsupported - \dosetcolormodel{all}% +\def\colo_helpers_set_current_model + {\ifconditional\c_colo_enabled + \ifconditional\c_colo_rgb_supported + \ifconditional\c_colo_cmyk_supported + \colo_helpers_set_model\s!all \else - \dosetcolormodel{rgb}% + \colo_helpers_set_model\s!rgb \fi \else - \ifCMYKsupported - \dosetcolormodel{cmyk}% + \ifconditional\c_colo_cmyk_supported + \colo_helpers_set_model\s!cmyk \else - \ifconvertGRAY - \dosetcolormodel{gray}% + \ifconditional\c_colo_convert_gray + \colo_helpers_set_model\s!gray \else - \dosetcolormodel{none}% + \colo_helpers_set_model\s!none \fi \fi \fi \else - \ifconvertGRAY - \dosetcolormodel{gray}% + \ifconditional\c_colo_convert_gray + \colo_helpers_set_model\s!gray \else - \dosetcolormodel{none}% + \colo_helpers_set_model\s!none \fi \fi} -\appendtoks - \dosetupcolormodel -\to \everyjob - % Currently in mkiv transparency is implemented independent of color. This costs % a bit more processing time but gives the possibility to apply transparency % independently in the future. Is this useful? If not we may as well combine them @@ -766,87 +572,135 @@ % Since we couple definitions, we could stick to one test. Todo. Same for mpcolor. -\letvalueempty{(cs:-} -\letvalueempty{(ts:-} - -\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 - \csname(ts:\currentpalet#1)\endcsname - \else\ifcsname(cs:#1)\endcsname - \csname(cs:#1)\endcsname - \csname(ts:#1)\endcsname +\def\v_colo_dummy_name{d_u_m_m_y} + +\letvalue{\??colorsetter-}\empty % used? +\letvalue{\??transparencysetter-}\empty % used? + +\def\colo_helpers_activate % two-step is not that much faster but less tracing + {\ifx\currentcolorprefix\empty + \expandafter\colo_helpers_activate_nop + \else + \expandafter\colo_helpers_activate_yes + \fi} + +\def\colo_helpers_activate_yes#1% + {\edef\currentcolorname{#1}% + \ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname + \csname\??colorsetter\currentcolorprefix\currentcolorname\endcsname + \csname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname + \else\ifcsname\??colorsetter\currentcolorname\endcsname + \csname\??colorsetter\currentcolorname\endcsname + \csname\??transparencysetter\currentcolorname\endcsname \fi\fi} -\let\normaldoactivatecolor\doactivatecolor +\def\colo_helpers_activate_nop#1% + {\edef\currentcolorname{#1}% + \ifcsname\??colorsetter\currentcolorname\endcsname + \csname\??colorsetter\currentcolorname\endcsname + \csname\??transparencysetter\currentcolorname\endcsname + \fi} -% 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\colo_helpers_activate_dummy + {\csname\??colorsetter \v_colo_dummy_name\endcsname + \csname\??transparencysetter\v_colo_dummy_name\endcsname} -\def\doactivatecolor - {\ifproductionrun - \ctxcommand{enablecolor() commands.enabletransparency()}% not that efficient but at least robust - \let\doactivatecolor\normaldoactivatecolor - \expandafter\doactivatecolor - \else - \expandafter\normaldoactivatecolor +\let\dousecolorparameter\colo_helpers_activate + +\unexpanded\def\dousecolorhashparameter#1#2% + {\ifcsname#1#2\endcsname + \expandafter\dousecolorparameter\csname#1#2\endcsname \fi} -\def\deactivatecolor +\unexpanded\def\dousecurrentcolorparameter + {\let\currentcolorname\currentcolorparameter % maybe only when success + \ifcsname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname + \csname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname + \csname\??transparencysetter\currentcolorprefix\currentcolorparameter\endcsname + \else\ifcsname\??colorsetter\currentcolorparameter\endcsname + \csname\??colorsetter\currentcolorparameter\endcsname + \csname\??transparencysetter\currentcolorparameter\endcsname + \fi\fi} + +\let\dosetcolorattribute\dousecolorhashparameter % for a while + +\unexpanded\def\deactivatecolor % sort of public but a bad name {\let\currentcolorname\s!black \attribute\colorattribute\attributeunsetvalue \attribute\transparencyattribute\attributeunsetvalue} -\def\dodefinecolorcommand#1#2% - {\unexpanded#1{#2}{\doactivatecolor{#2}}} +\def\colo_basics_define[#1][#2]% + {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colo_freeze_state)}% + \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} -\let\colorlist\empty % not really used, only for colo-run -\setfalse\collectcolorsinlist -\def\collectcolorinlist#1{\doglobal\addtocommalist{#1}\colorlist} +\def\colo_basics_define_global[#1][#2]% + {\ctxcommand{defineprocesscolor("#1","#2",true,\v_colo_freeze_state)}% + \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}} -\def\doregistercolor#1#2% - {\ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}} +\def\colo_basics_define_named[#1][#2]% + {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colo_freeze_state)}% + \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} -\def\dodefinecolor[#1][#2]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}% - \dodefinecolorcommand\setvalue{#1}} +\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}}} -\def\dodefineglobalcolor[#1][#2]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{defineprocesscolor("#1","#2",true,\colorfreezestate)}% - \dodefinecolorcommand\setgvalue{#1}} +\def\colo_basics_defined_and_activated#1% + {\ctxcommand{defineprocesscolor("\v_colo_dummy_name","#1",false,false)}% + \colo_helpers_activate_dummy} -\def\dodefinenamedcolor[#1][#2]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}% - \dodefinecolorcommand\setvalue{#1}} +% Spotcolors used setxvalue but that messes up currentcolor +% and probably no global is needed either but they are global +% at the lua end (true argument) so we keep that if only because +% spot colors often are a document wide property -\def\dodefinespotcolor[#1][#2][#3]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{definespotcolor("#1","#2","#3",true)}% - \dodefinecolorcommand\setxvalue{#1}} +\def\colo_basics_define_spot[#1][#2][#3]% + {\ctxcommand{definespotcolor("#1","#2","#3",true)}% + \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}} -\def\dodefinemultitonecolor[#1][#2][#3][#4]% +\def\colo_basics_define_multitone[#1][#2][#3][#4]% {\ctxcommand{definemultitonecolor("#1","#2","#3","#4",true)}% - \dodefinecolorcommand\setxvalue{#1}} + \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}} -\def\dodefinetransparency[#1][#2]% +%D Transparencies (only): + +\def\colo_basics_define_transpancy[#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 - \ctxcommand{setrastercolor("_raster_",\@@rastervalue)}} % sets attribute +% A goodie that replaces the startMPcolor hackery -\def\dodefinefastcolor[#1][#2]% still not fast but ok - {\ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}% - \dodefinecolorcommand\setvalue{#1}} +% \definecolor[red-t] [r=1,t=0.5,a=1] +% \definecolor[green-t][g=1,t=0.5,a=1] +% +% \defineintermediatecolor[mycolora][0.5,red,green] +% \defineintermediatecolor[mycolorb][0.5,red-t,green-t] +% +% \definecolor[mycolorc][.5(blue,red)] +% \definecolor[mycolord][.5(blue)] +% +% \enabledirectives[colors.pgf] +% \definecolor[mycolorx][magenta!50!yellow] +% +% \starttext +% test {\mycolora OEPS} test +% test {\mycolorb OEPS} test +% test {\mycolorc OEPS} test +% test {\mycolord OEPS} test +% test {\mycolorx OEPS} test +% \stoptext + +\unexpanded\def\defineintermediatecolor + {\dotripleempty\colo_basics_define_intermediate} + +\def\colo_basics_define_intermediate[#1][#2][#3]% \dotripleempty adds {} inside [] + {\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,\iffreezecolors true\else false\fi)}% not global + \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}} %D \macros %D {doifcolorelse, doifcolor} @@ -856,33 +710,24 @@ %D define ourselves a color conditional first. \def\doifcolorelse#1% - {\ifcsname(ca:\currentpalet#1)\endcsname - \@EA\firstoftwoarguments - \else\ifcsname(ca:#1)\endcsname - \@EAEAEA\firstoftwoarguments + {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname + \expandafter\firstoftwoarguments + \else\ifcsname\??colorattribute#1\endcsname + \doubleexpandafter\firstoftwoarguments \else - \@EAEAEA\secondoftwoarguments + \doubleexpandafter\secondoftwoarguments \fi\fi} \def\doifcolor#1% - {\ifcsname(ca:\currentpalet#1)\endcsname - \@EA\firstofoneargument - \else\ifcsname(ca:#1)\endcsname - \@EAEAEA\firstofoneargument + {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname + \expandafter\firstofoneargument + \else\ifcsname\??colorattribute#1\endcsname + \doubleexpandafter\firstofoneargument \else - \@EAEAEA\gobbleoneargument + \doubleexpandafter\gobbleoneargument \fi\fi} %D \macros -%D {colored} -%D -%D A bit like \type {\definedfont}: - -\unexpanded\def\colored[#1]% - {\ctxcommand{defineprocesscolor("@colored@","#1",false,false)}% - \groupedcommand{\doactivatecolor{@colored@}}{}} - -%D \macros %D {startregistercolor,stopregistercolor,permitcolormode} %D %D If you only want to register a color, the switch \type @@ -908,94 +753,107 @@ %D \stopregistercolor %D \stoptyping -% can be cleaned up - \let\maintextcolor \empty \def\defaulttextcolor {black} -\def\@@themaintextcolor{themaintextcolor} +\def\s!themaintextcolor{themaintextcolor} \appendtoks - \deactivatecolor - \ifx\maintextcolor\empty\else\doactivatecolor\maintextcolor\fi + \deactivatecolor % public? + \ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi \to \everybeforeoutput -\def\registermaintextcolor - {\ctxcommand{registermaintextcolor(\thecolorattribute\maintextcolor)}} +\def\colo_helpers_switch_to_maintextcolor#1% + {\let\maintextcolor\s!themaintextcolor + \definecolor[\maintextcolor][#1]% can be fast one + \colo_helpers_activate\maintextcolor + \ctxcommand{registermaintextcolor(\thecolorattribute\maintextcolor)}} \unexpanded\def\starttextcolor[#1]% {\doifsomething{#1} - {\definecolor[\@@themaintextcolor][#1]% - \let\maintextcolor\@@themaintextcolor - \doactivatecolor\maintextcolor - \registermaintextcolor}} + {\colo_helpers_switch_to_maintextcolor{#1}}} \let\stoptextcolor\relax -\def\initializemaintextcolor - {\doifelsenothing\@@cltextcolor - {\definecolor[\@@themaintextcolor][\defaulttextcolor]} - {\definecolor[\@@themaintextcolor][\@@cltextcolor]}% - \let\maintextcolor\@@themaintextcolor - \doactivatecolor\maintextcolor - \registermaintextcolor} +\let\p_colo_textcolor\empty + +\def\colo_helpers_initialize_maintextcolor + {\edef\p_colo_textcolor{\directcolorsparameter\c!textcolor}% + \ifx\p_colo_textcolor\empty + \colo_helpers_switch_to_maintextcolor\defaulttextcolor + \else + \colo_helpers_switch_to_maintextcolor\p_colo_textcolor + \fi} + +\appendtoks \colo_helpers_initialize_maintextcolor \to \everyjob +\appendtoks \colo_helpers_initialize_maintextcolor \to \everysetupcolors -\appendtoks \initializemaintextcolor \to \everyjob -\appendtoks \initializemaintextcolor \to \everysetupcolors +\def\colo_helpers_inherited_direct_cs#1{\csname\??colorsetter \ifcsname\??colorsetter #1\endcsname#1\fi\endcsname} +\def\colo_helpers_inherited_direct_ca#1{\csname\??colorattribute \ifcsname\??colorattribute #1\endcsname#1\fi\endcsname} +\def\colo_helpers_inherited_direct_ts#1{\csname\??transparencysetter \ifcsname\??transparencysetter #1\endcsname#1\fi\endcsname} +\def\colo_helpers_inherited_direct_ta#1{\csname\??transparencyattribute\ifcsname\??transparencyattribute#1\endcsname#1\fi\endcsname} -\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\colo_helpers_inherited_palet_ca#1#2{\csname\??colorattribute \ifcsname\??colorattribute \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +\def\colo_helpers_inherited_palet_cs#1#2{\csname\??colorsetter \ifcsname\??colorsetter \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +\def\colo_helpers_inherited_palet_ta#1#2{\csname\??transparencyattribute\ifcsname\??transparencyattribute\??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +\def\colo_helpers_inherited_palet_ts#1#2{\csname\??transparencysetter \ifcsname\??transparencysetter \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\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} +\let\colo_helpers_set_value\setvalue + +\appendtoks + \ifconditional\c_colo_expanded + \let\colo_helpers_set_value\setevalue + \else + \let\colo_helpers_set_value\setvalue + \fi +\to \everysetupcolors -\def\dodefinepaletcolor#1#2#3% +\def\colo_palets_define_set#1#2#3% {\doifassignmentelse{#3}% \definepalet[test][xx={y=.4}] - {\definecolor[\??pa#1:#2][#3]% - \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] - \dosetcolorvalue{(cs:#1:#2)}{\doinheritdirectcs{#3}}% - \dosetcolorvalue{(ca:#1:#2)}{\doinheritdirectca{#3}}% - \dosetcolorvalue{(ts:#1:#2)}{\doinheritdirectts{#3}}% - \dosetcolorvalue{(ta:#1:#2)}{\doinheritdirectta{#3}}% + {\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}}% + \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_palet_ta{#1}{#2}}% + \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_palet_ts{#1}{#2}}} + {\ifcsname\??colorsetter#3\endcsname % \definepalet[test][xx=green] + \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{#3}}% + \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{#3}}% + \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{#3}}% + \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{#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 + \localundefine{\??colorsetter #1:#2}% + \localundefine{\??colorattribute #1:#2}% + \localundefine{\??transparencysetter #1:#2}% + \localundefine{\??transparencyattribute#1:#2}% \fi}} -\setvalue{(cs:)}{} \setvalue{(ca:)}{0} -\setvalue{(ts:)}{} \setvalue{(ta:)}{0} +\letvalue{\??colorsetter }\empty \letvalue{\??colorattribute }\!!zerocount +\letvalue{\??transparencysetter}\empty \letvalue{\??transparencyattribute}\!!zerocount + +\setvalue{\??colorattribute currentcolor}{\the\attribute\colorattribute} % for mpcolor +\setvalue{\??transparencyattribute currentcolor}{\the\attribute\transparencyattribute} % for mpcolor -\def\doinheritca#1{\csname(ca:\ifcsname(ca:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ca:#1)\endcsname#1\fi\fi)\endcsname} -\def\doinheritcs#1{\csname(cs:\ifcsname(cs:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(cs:#1)\endcsname#1\fi\fi)\endcsname} -\def\doinheritta#1{\csname(ta:\ifcsname(ta:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ta:#1)\endcsname#1\fi\fi)\endcsname} -\def\doinheritts#1{\csname(ts:\ifcsname(ts:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ts:#1)\endcsname#1\fi\fi)\endcsname} +\def\colo_helpers_inherited_current_ca#1{\csname\??colorattribute \ifcsname\??colorattribute \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorattribute #1\endcsname#1\fi\fi\endcsname} +\def\colo_helpers_inherited_current_cs#1{\csname\??colorsetter \ifcsname\??colorsetter \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorsetter #1\endcsname#1\fi\fi\endcsname} +\def\colo_helpers_inherited_current_ta#1{\csname\??transparencyattribute\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencyattribute#1\endcsname#1\fi\fi\endcsname} +\def\colo_helpers_inherited_current_ts#1{\csname\??transparencysetter \ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencysetter #1\endcsname#1\fi\fi\endcsname} %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}\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 }} +\unexpanded\def\colordefalc#1#2{\setevalue{\??colorattribute #1}{#2}\setvalue {\??colorsetter #1}{\attribute\colorattribute #2 }} +\unexpanded\def\colordefagc#1#2{\setxvalue{\??colorattribute #1}{#2}\setgvalue{\??colorsetter #1}{\attribute\colorattribute #2 }} % was not g +\unexpanded\def\colordefalt#1#2{\setevalue{\??transparencyattribute#1}{#2}\setvalue {\??transparencysetter#1}{\attribute\transparencyattribute#2 }} +\unexpanded\def\colordefagt#1#2{\setxvalue{\??transparencyattribute#1}{#2}\setgvalue{\??transparencysetter#1}{\attribute\transparencyattribute#2 }} -\def\colordefflc#1#2{\setvalue {(ca:#1)}{\doinheritca{#2}}\setvalue {(cs:#1)}{\doinheritcs{#2}}} -\def\colordeffgc#1#2{\setgvalue{(ca:#1)}{\doinheritca{#2}}\setvalue {(cs:#1)}{\doinheritcs{#2}}} -\def\colordefflt#1#2{\setvalue {(ta:#1)}{\doinheritta{#2}}\setvalue {(ts:#1)}{\doinheritts{#2}}} -\def\colordeffgt#1#2{\setgvalue{(ta:#1)}{\doinheritta{#2}}\setgvalue{(ts:#1)}{\doinheritts{#2}}} +\unexpanded\def\colordefflc#1#2{\setvalue {\??colorattribute #1}{\colo_helpers_inherited_current_ca{#2}}\setvalue {\??colorsetter #1}{\colo_helpers_inherited_current_cs{#2}}} +\unexpanded\def\colordeffgc#1#2{\setgvalue{\??colorattribute #1}{\colo_helpers_inherited_current_ca{#2}}\setvalue {\??colorsetter #1}{\colo_helpers_inherited_current_cs{#2}}} +\unexpanded\def\colordefflt#1#2{\setvalue {\??transparencyattribute#1}{\colo_helpers_inherited_current_ta{#2}}\setvalue {\??transparencysetter#1}{\colo_helpers_inherited_current_ts{#2}}} +\unexpanded\def\colordeffgt#1#2{\setgvalue{\??transparencyattribute#1}{\colo_helpers_inherited_current_ta{#2}}\setgvalue{\??transparencysetter#1}{\colo_helpers_inherited_current_ts{#2}}} -\def\colordefrlc #1{\localundefine {(ca:#1)}\localundefine {(cs:#1)}} -\def\colordefrgc #1{\globalundefine{(ca:#1)}\globalundefine{(cs:#1)}} -\def\colordefrlt #1{\localundefine {(ta:#1)}\localundefine {(ts:#1)}} -\def\colordefrgt #1{\globalundefine{(ta:#1)}\globalundefine{(ts:#1)}} +\unexpanded\def\colordefrlc #1{\localundefine {\??colorattribute #1}\localundefine {\??colorsetter #1}} +\unexpanded\def\colordefrgc #1{\globalundefine{\??colorattribute #1}\globalundefine{\??colorsetter #1}} +\unexpanded\def\colordefrlt #1{\localundefine {\??transparencyattribute#1}\localundefine {\??transparencysetter#1}} +\unexpanded\def\colordefrgt #1{\globalundefine{\??transparencyattribute#1}\globalundefine{\??transparencysetter#1}} %D \macros %D {colorvalue, grayvalue} @@ -1012,19 +870,22 @@ %D %D show us: %D -%D \startvoorbeeld +%D \startexample %D \getbuffer -%D \stopvoorbeeld +%D \stopexample \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\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\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\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})}} @@ -1059,12 +920,11 @@ % \normal added else fails in metafun manual (leaders do a hard scan) -\unexpanded\def\forcecolorhack{\leaders\hrule\normalhskip\zeropoint} +\unexpanded\def\forcecolorhack{\leaders\hrule\hskip\zeropoint} -%D We default to the colors defined in \module{colo-rgb} and -%D support both \cap{RGB} and \cap{CMYK} output. As you can -%D see, color support is turned off by default. Reduction of -%D gray colors to gray scales is turned on. +%D We default to the colors defined in \type {colo-imp-rgb} and +%D support both \RGB\ and \CMYK\ output. Transparencies are defined +%D here: \definecolor[black][s=0] \definecolor[white][s=1] @@ -1082,29 +942,21 @@ \definetransparency [lighten] [10] \definetransparency [difference] [11] \definetransparency [exclusion] [12] +\definetransparency [hue] [13] +\definetransparency [saturation] [14] +\definetransparency [color] [15] +\definetransparency [luminosity] [16] \setupcolors - [\c!state=\v!stop, % will be enabled later on + [\c!state=\v!stop, % color will be enabled later on \c!conversion=\v!yes, - \c!reduction=\v!no, \c!rgb=\v!yes, \c!cmyk=\v!yes, \c!spot=\v!yes, - \c!mp\c!cmyk=\@@clcmyk, - \c!mp\c!spot=\@@clspot, + \c!pagecolormodel=\v!none, \c!expansion=\v!no, \c!textcolor=, - \c!split=\v!no, % obsolete - \c!factor=\v!yes, - \c!criterium=\v!all] % obsolete - -\appendtoks - \setupcolors[\c!state=\v!start]% later direct -\to \everyjob - -\appendtoks - \let\showcolormessage\showmessage -\to \everyjob + \c!factor=\v!yes] \setupcolor [\v!rgb] |