diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-05 00:48:46 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-05 00:48:46 +0000 |
commit | f210bce174e1f2f05305ab03e88e120a1cbfc4da (patch) | |
tree | 5c4e2ad096b5c745e859516ac3196fa0864292d5 /Master/texmf-dist/tex/context/base/mkiv/colo-ini.mkiv | |
parent | 35fd641a3546acc0c62e0aa7f134888e36da30d4 (diff) |
context (from cont-tmf.zip of Feb 17 16:00, size 116339406)
git-svn-id: svn://tug.org/texlive/trunk@54086 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/colo-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/colo-ini.mkiv | 297 |
1 files changed, 142 insertions, 155 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/colo-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/colo-ini.mkiv index 7079322f7a2..c489635deca 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/colo-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/colo-ini.mkiv @@ -37,16 +37,15 @@ \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). 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 In \MKIV\ we have independent color, colorspace and transparency but I'm still +%D not sure if I keep it that way as it's probably more efficient to combine them +%D (less attributes and finalizing). If it becomes a bottleneck we can set up a more +%D complex system with one shared attribute for colorspace, color and transparency. %D -%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 When typesetting for paper, we prefer using the \CMYK\ color space, but for +%D on||screen viewing we prefer \RGB\ (the previous implementation supported only +%D this scheme). Independant of such specifications, we support some automatic +%D conversions: %D %D \startitemize[packed] %D \item convert all colors to \RGB @@ -108,11 +107,18 @@ \unexpanded\def\definetransparency {\dodoubleargument\colo_basics_define_transpancy} \unexpanded\def\defineglobaltransparency{\dodoubleargument\colo_basics_define_transpancy_global} +\unexpanded\def\loadfoundcolorsetfile#1#2% name foundname / not a user command + {\startreadingfile + \startcolorset[#1]% + \input{#2}% + \stopcolorset + \showmessage\m!colors4{#1}% + \stopreadingfile} + %D \macros %D {startcolor,stopcolor,color,graycolor} %D -%D The local and global commands are here just for compatibility -%D with \MKII. +%D The local and global commands are here just for compatibility with \MKII. %D %D \showsetup{startcolor} %D @@ -131,42 +137,6 @@ \unexpanded\def\switchtocolor[#1]{\begincsname#1\endcsname} -% \unexpanded\def\color [#1]{\bgroup -% \def\g_color{\colo_helpers_activate{#1}}% -% \afterassignment\g_color -% \let\nexttoken} -% -% \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\startcolor [#1]{\begingroup -% \colo_helpers_activate{#1}} -% -% \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}} -% -% \afterassignment was a left-over artifact - % transparency \unexpanded\def\transparent[#1]% @@ -259,7 +229,7 @@ \unexpanded\def\directcolored[#1]% {\colo_basics_defined_and_activated{#1}} -\unexpanded\def\fastcolor [#1]#2% +\unexpanded\def\fastcolor[#1]#2% {\begingroup % is this command still needed? \edef\currentcolorname{#1}% \ifx\currentcolorprefix\empty @@ -310,11 +280,11 @@ %D %D \showsetup{usecolors} %D -%D Some default colors are specified in \type {colo-imp-rgb}, -%D which is loaded into the format by default. +%D Some default colors are specified in \type {colo-imp-rgb}, which is loaded into +%D 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 Some demo palets and groups are defined in \type {colo-imp-dem} which can be +%D loaded with: %D %D \starttyping %D \usecolors[dem] @@ -407,33 +377,27 @@ {\attribute\colorattribute \c_colo_saved_attribute_color \attribute\transparencyattribute\c_colo_saved_attribute_transparency} -%D In this documentation we will not go into too much details -%D on palets. Curious users can find more information on this -%D topic in \from[use of color]. +%D In this documentation we will not go into too much details on palets. Curious +%D users can find more information on this topic in \from[use of color]. %D -%D At the moment we implemented color in \CONTEXT\ color -%D printing was not yet on the desktop. In spite of this lack our -%D graphics designer made colorfull illustrations. When printed -%D on a black and white printer, distinctive colors can come -%D out equally gray. We therefore decided to use only colors -%D that were distinctive in colors as well as in black and -%D white print. +%D At the moment we implemented color in \CONTEXT\ color printing was not yet on the +%D desktop. In spite of this lack our graphics designer made colorfull +%D illustrations. When printed on a black and white printer, distinctive colors can +%D come out equally gray. We therefore decided to use only colors that were +%D distinctive in colors as well as in black and white print. %D -%D Although none of the graphic packages we used supported -%D logical colors and global color redefition, we build this -%D support into \CONTEXT. This enabled us to experiment and -%D also prepared us for the future. +%D Although none of the graphic packages we used supported logical colors and global +%D color redefition, we build this support into \CONTEXT. This enabled us to +%D experiment and also prepared us for the future. %D \macros %D {definepalet} %D -%D Colors are grouped in palets. The colors in such a palet can -%D have colorful names, but best is to use names that specify -%D their use, like {\em important} or {\em danger}. As a sort -%D of example \CONTEXT\ has some palets predefined, -%D like:\footnote{At the time I wrote the palet support, I was -%D reading 'A hort history of time' of S.~Hawkins, so that's -%D why we stuck to quarks.} +%D Colors are grouped in palets. The colors in such a palet can have colorful names, +%D but best is to use names that specify their use, like {\em important} or {\em +%D danger}. As a sort of example \CONTEXT\ has some palets predefined, +%D like:\footnote{At the time I wrote the palet support, I was reading 'A hort +%D history of time' of S.~Hawkins, so that's why we stuck to quarks.} %D %D \starttyping %D \definepalet @@ -460,8 +424,8 @@ %D \getbuffer[palet] %D \stoplinecorrection %D -%D This bar shows both the color and gray alternatives of the -%D palet components (not visible in black and white print). +%D This bar shows both the color and gray alternatives of the palet components (not +%D visible in black and white print). %D %D When needed, one can copy a palet by saying: %D @@ -469,8 +433,8 @@ %D \definepalet [TEXcolorpretty] [colorpretty] %D \stoptyping %D -%D This saves us some typing in for instance the modules that -%D deal with pretty verbatim typesetting. +%D This saves us some typing in for instance the modules that deal with pretty +%D verbatim typesetting. \installcorenamespace{paletlist} \installcorenamespace{paletsize} @@ -485,7 +449,7 @@ \def\colo_palet_prepare#1% {\edef\colo_palet_name{#1}% \ifcsname\??paletlist\colo_palet_name\endcsname - \csname\??paletsize#1\endcsname\zerocount + \csname\??paletsize\colo_palet_name\endcsname\zerocount \else \colo_palet_allocate\colo_palet_name \fi @@ -527,14 +491,25 @@ \expandafter\colo_palets_define_a \fi} +% \unexpanded\def\colo_palets_define_a[#1][#2][#3]% +% {\colo_palet_prepare{#1}% +% \doifelseassignment{#2} +% {\setevalue{\??colorpaletspecification#1}{#2}% +% \processcommalist[#2]{\colo_palets_define_one{#1}}} +% {\ifcsname\??colorpaletspecification#2\endcsname +% \normalexpanded{\colo_palets_define[#1][\lastnamedcs]}% +% \fi}} + \unexpanded\def\colo_palets_define_a[#1][#2][#3]% {\colo_palet_prepare{#1}% - \doifelseassignment{#2} - {\setevalue{\??colorpaletspecification#1}{#2}% - \processcommalist[#2]{\colo_palets_define_one{#1}}} - {\ifcsname\??colorpaletspecification#2\endcsname - \normalexpanded{\colo_palets_define[#1][\lastnamedcs]}% - \fi}} + \ifcondition\validassignment{#2}% + \setevalue{\??colorpaletspecification#1}{#2}% + \processcommalist[#2]{\colo_palets_define_one{#1}}% + \else + \ifcsname\??colorpaletspecification#2\endcsname + \normalexpanded{\colo_palets_define[#1][\lastnamedcs]}% + \fi + \fi} \unexpanded\def\colo_palets_define_b[#1][#2][#3]% {\colo_palet_prepare{#1}% @@ -542,10 +517,17 @@ \colo_palet_extend{#2}% \colo_palets_define_assign{#1}{#2}{#3}} +% \def\colo_palets_define_one#1#2% get rid of { } +% {\doifelseassignment{#2} % catch empty entries +% {\colo_palets_define_two{#1}[#2]} +% {\colo_palets_define_three{#1}{#2}}} + \def\colo_palets_define_one#1#2% get rid of { } - {\doifelseassignment{#2} % catch empty entries - {\colo_palets_define_two{#1}[#2]} - {\colo_palets_define_three{#1}{#2}}} + {\ifcondition\validassignment{#2}% catch empty entries + \colo_palets_define_two{#1}[#2]% + \else + \colo_palets_define_three{#1}{#2}% + \fi} \def\colo_palets_define_two#1[#2=#3]% {\colo_palet_extend{#2}% @@ -556,8 +538,7 @@ \processcommacommand[\lastnamedcs]{\colo_palets_define_one{#1}}% \fi} -%D Instead of refering to colors, one can also directly specify -%D a color: +%D Instead of refering to colors, one can also directly specify a color: %D %D \starttyping %D \definepalet[test][xx=green] @@ -567,8 +548,8 @@ %D \macros %D {setuppalet} %D -%D Colors are taken from the current palet, if defined. -%D Setting the current palet is done by: +%D Colors are taken from the current palet, if defined. Setting the current palet is +%D done by: %D %D \showsetup{setuppalet} @@ -660,8 +641,8 @@ %D \macros %D {showcolor} %D -%D But let's not forget that we also have the more traditional -%D non||related colors. These show up after: +%D But let's not forget that we also have the more traditional non||related colors. +%D These show up after: %D %D \starttyping %D \showcolor [name] @@ -673,8 +654,8 @@ \fetchruntimecommand \showcolor \f!colo_run -%D It would make sense to put the following code in \type -%D {colo-mps}, but it it rather low level. +%D It would make sense to put the following code in \type {colo-mps}, but it it +%D rather low level. %D \macros %D {negatecolorcomponent,negatedcolorcomponent} @@ -705,8 +686,8 @@ %D \macros %D {MPcolor} %D -%D A very special macro is \type{\MPcolor}. This one can be -%D used to pass a \CONTEXT\ color to \METAPOST. +%D A very special macro is \type{\MPcolor}. This one can be used to pass a \CONTEXT\ +%D color to \METAPOST. %D %D \starttyping %D \MPcolor{my own red} @@ -715,15 +696,13 @@ %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 For the moment we keep the next downward compatibility switch, i.e.\ expanded +%D colors. However, predefined colors and palets are no longer expanded (which is +%D what I wanted in the first place). %D -%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. +%D In \MKIV\ we don't support color separation as we might now assume that printing +%D houses have the right programs to do it themselves. If it's ever needed in \MKIV\ +%D It is relatively easy to support it in the backend code. % todo: palets in definecolor % todo: {\red xx} vs \red{xx} @@ -773,12 +752,12 @@ \fi \fi} -% 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 -% again in the future. By coupling we are downward compatible. When we decouple we -% need to do more tricky housekeeping (e.g. persist color independent transparencies -% when color bound ones are nil. +%D Currently in mkiv transparency is implemented independent of color. This costs a +%D bit more processing time but gives the possibility to apply transparency +%D independently in the future. Is this useful? If not we may as well combine them +%D again in the future. By coupling we are downward compatible. When we decouple we +%D need to do more tricky housekeeping (e.g. persist color independent +%D transparencies when color bound ones are nil. % Since we couple definitions, we could stick to one test. Todo. Same for mpcolor. @@ -804,21 +783,21 @@ \def\colo_helpers_fast_activate_yes#1% {\ifcsname\??colorsetter\currentcolorprefix#1\endcsname \lastnamedcs - \csname\??transparencysetter\currentcolorprefix#1\endcsname + \begincsname\??transparencysetter\currentcolorprefix#1\endcsname \else\ifcsname\??colorsetter#1\endcsname \lastnamedcs - \csname\??transparencysetter#1\endcsname + \begincsname\??transparencysetter#1\endcsname \fi\fi} \def\colo_helpers_fast_activate_nop#1% {\ifcsname\??colorsetter#1\endcsname \lastnamedcs - \csname\??transparencysetter#1\endcsname + \begincsname\??transparencysetter#1\endcsname \fi} \def\colo_helpers_activate_dummy - {\csname\??colorsetter \v_colo_dummy_name\endcsname - \csname\??transparencysetter\v_colo_dummy_name\endcsname} + {\begincsname\??colorsetter \v_colo_dummy_name\endcsname + \begincsname\??transparencysetter\v_colo_dummy_name\endcsname} \let\dofastcoloractivation\colo_helpers_fast_activate @@ -835,16 +814,16 @@ \def\colo_helpers_activate_yes {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname \lastnamedcs - \csname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname + \begincsname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname \else\ifcsname\??colorsetter\currentcolorname\endcsname \lastnamedcs - \csname\??transparencysetter\currentcolorname\endcsname + \begincsname\??transparencysetter\currentcolorname\endcsname \fi\fi} \def\colo_helpers_activate_nop {\ifcsname\??colorsetter\currentcolorname\endcsname \lastnamedcs - \csname\??transparencysetter\currentcolorname\endcsname + \begincsname\??transparencysetter\currentcolorname\endcsname \fi} \def\colo_helpers_activate_yes_only @@ -870,10 +849,10 @@ {\let\currentcolorname\currentcolorparameter % maybe only when success \ifcsname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname \lastnamedcs - \csname\??transparencysetter\currentcolorprefix\currentcolorparameter\endcsname + \begincsname\??transparencysetter\currentcolorprefix\currentcolorparameter\endcsname \else\ifcsname\??colorsetter\currentcolorparameter\endcsname \lastnamedcs - \csname\??transparencysetter\currentcolorparameter\endcsname + \begincsname\??transparencysetter\currentcolorparameter\endcsname \fi\fi} \let\dosetcolorattribute\dousecolorhashparameter % for a while @@ -888,7 +867,7 @@ % \let\colo_basics_synchronize\gobbleoneargument % used in mp interface % \let\colo_basics_inherit \gobbletwoarguments % used in mp interface -\def\colo_basics_allocate#1% +\def\colo_basics_allocate#1% todo: use a chardef instead {\expandafter\newcount\csname\??colornumber#1\endcsname \clf_synccolorcount{#1}\c_syst_last_allocated_count} @@ -971,10 +950,9 @@ \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 -% at the lua end (true argument) so we keep that if only because -% spot colors often are a document wide property +%D Spotcolors used setxvalue but that messes up currentcolor and probably no global +%D is needed either but they are global at the lua end (true argument) so we keep +%D that if only because spot colors often are a document wide property \def\colo_basics_define_spot[#1][#2][#3]% {\clf_definespotcolorglobal{#1}{#2}{#3}% @@ -1026,8 +1004,8 @@ % % \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: +% 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)] @@ -1111,9 +1089,8 @@ %D \macros %D {doifcolorelse, doifcolor} %D -%D Switching to a color is done by means of the following -%D command. Later on we will explain the use of palets. We -%D define ourselves a color conditional first. +%D Switching to a color is done by means of the following command. Later on we will +%D explain the use of palets. We define ourselves a color conditional first. \def\doifelsecolor#1% {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname @@ -1138,13 +1115,11 @@ %D \macros %D {startregistercolor,stopregistercolor,permitcolormode} %D -%D If you only want to register a color, the switch \type -%D {\ifpermitcolormode} can be used. That way the nested -%D colors know where to go back to. +%D If you only want to register a color, the switch \type {\ifpermitcolormode} can +%D be used. That way the nested colors know where to go back to. %D -%D We use these macros for implementing text colors -%D (actually, the first application was in foreground -%D colors). +%D We use these macros for implementing text colors (actually, the first application +%D was in foreground colors). %D %D \starttyping %D \starttextcolor[red] @@ -1233,16 +1208,28 @@ \fi \to \everysetupcolors +% \def\colo_palets_define_set#1#2#3% +% {\doifelseassignment{#3}% \definepalet[test][xx={y=.4}] +% {\colo_palets_define_assign}% +% {\ifcsname\??colorsetter#3\endcsname +% % \definepalet[test][xx=green] +% \expandafter\colo_palets_define_inherit +% \else +% % not entered when making format +% \expandafter\colo_palets_define_undefine +% \fi}% +% {#1}{#2}{#3}} + \def\colo_palets_define_set#1#2#3% - {\doifelseassignment{#3}% \definepalet[test][xx={y=.4}] - {\colo_palets_define_assign}% - {\ifcsname\??colorsetter#3\endcsname - % \definepalet[test][xx=green] - \expandafter\colo_palets_define_inherit - \else - % not entered when making format - \expandafter\colo_palets_define_undefine - \fi}% + {\ifcondition\validassignment{#3}% \definepalet[test][xx={y=.4}] + \expandafter\colo_palets_define_assign + \else\ifcsname\??colorsetter#3\endcsname + % \definepalet[test][xx=green] + \doubleexpandafter\colo_palets_define_inherit + \else + % not entered when making format + \doubleexpandafter\colo_palets_define_undefine + \fi\fi {#1}{#2}{#3}} \def\colo_palets_define_inherit#1#2#3% @@ -1298,8 +1285,8 @@ %D \macros %D {colorvalue, grayvalue} %D -%D We can typeset the color components using \type{\colorvalue} and -%D \type{\grayvalue}. The commands: +%D We can typeset the color components using \type {\colorvalue} and \type +%D {\grayvalue}. The commands: %D %D \startbuffer %D color value of SomeKindOfRed: \colorvalue{SomeKindOfRed} \crlf @@ -1376,8 +1363,8 @@ %D \macros %D {forcecolorhack} %D -%D We can out this in front of (for instance) a special and so force color -%D to be applied (only glyphs, rules and leaders are handled). +%D We can out this in front of (for instance) a special and so force color to be +%D applied (only glyphs, rules and leaders are handled). %D %D \startbuffer %D \framed @@ -1438,10 +1425,10 @@ \definecolor[trace:g][g=.75,t=.5,a=1] \definecolor[trace:b][b=.75,t=.5,a=1] %definecolor[trace:c][c=.75,t=.5,a=1] -\definecolor[trace:c][g=.75,b=.75,t=.5,a=1] %definecolor[trace:m][m=.75,t=.5,a=1] -\definecolor[trace:m][r=.75,b=.75,t=.5,a=1] %definecolor[trace:y][y=.75,t=.5,a=1] +\definecolor[trace:c][g=.75,b=.75,t=.5,a=1] +\definecolor[trace:m][r=.75,b=.75,t=.5,a=1] \definecolor[trace:y][r=.75,g=.75,t=.5,a=1] \definecolor[trace:s][s=.75,t=.5,a=1] \definecolor[trace:d][s=.25,t=.5,a=1] @@ -1452,11 +1439,11 @@ \definecolor[trace:dg][g=.75,t=.75,a=1] \definecolor[trace:db][b=.75,t=.75,a=1] %definecolor[trace:dc][c=.75,t=.75,a=1] -\definecolor[trace:dc][g=.75,b=.75,t=.75,a=1] %definecolor[trace:dm][m=.75,t=.75,a=1] -\definecolor[trace:dm][r=.75,b=.75,t=.75,a=1] %definecolor[trace:dy][y=.75,t=.75,a=1] -\definecolor[trace:y][r=.75,g=.75,t=.75,a=1] +\definecolor[trace:dc][g=.75,b=.75,t=.75,a=1] +\definecolor[trace:dm][r=.75,b=.75,t=.75,a=1] +\definecolor[trace:dy][r=.75,g=.75,t=.75,a=1] \definecolor[trace:ds][s=.75,t=.75,a=1] \definecolor[trace:dd][s=.25,t=.75,a=1] \definecolor[trace:do][r=1,g=.6,b=.1,t=.75,a=1] |