diff options
Diffstat (limited to 'tex/context/base/colo-hex.tex')
-rw-r--r-- | tex/context/base/colo-hex.tex | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/tex/context/base/colo-hex.tex b/tex/context/base/colo-hex.tex index 76423ada0..25f4d22e0 100644 --- a/tex/context/base/colo-hex.tex +++ b/tex/context/base/colo-hex.tex @@ -11,6 +11,12 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +\ifx\dodododefinecolor\undefined + \beginTEX \endinput \endTEX +\else + \endinput +\fi + \writestatus{loading}{Context Color Macros / hexadecimal} % \edef\testcolor{\string#FFC0C0} @@ -41,23 +47,25 @@ \def\hexcolorspec #1{\expandafter\dohexcolorspec #1\empty\empty\empty\empty\relax} \def\hexcolorpattern#1{\expandafter\dohexcolorpattern#1\empty\empty\empty\empty\relax} -\def\hexcolorcomponent#1% - {\ifnum"#1=\zerocount0\else\ifnum"#1=\plusone1\else - \expandafter\withoutpt\the\dimexpr("#1\hexcolorfraction)% +\ifx\dohexstringtonumber\undefined \def\dohexstringtonumber{"} \fi + +\def\hexcolorcomponent#1#2% + {\ifnum\dohexstringtonumber#1#2=\zerocount0\else\ifnum\dohexstringtonumber#1#2=\plusone1\else + \expandafter\withoutpt\the\dimexpr(\dohexstringtonumber#1#2\hexcolorfraction)% \fi\fi} \def\dohexcolorspec#1#2#3#4#5#6#7#8\relax {\ifx#4\empty - s=\hexcolorcomponent{#2#3}% + s=\hexcolorcomponent#2#3% \else - r=\hexcolorcomponent{#2#3},g=\hexcolorcomponent{#4#5},b=\hexcolorcomponent{#6#7}% + r=\hexcolorcomponent#2#3,g=\hexcolorcomponent#4#5,b=\hexcolorcomponent#6#7% \fi} \def\dohexcolorpattern#1#2#3#4#5#6#7#8\relax {0\ifx#4\empty - S:\hexcolorcomponent{#2#3}% + S:\hexcolorcomponent#2#3% \else - R:\hexcolorcomponent{#2#3}:\hexcolorcomponent{#4#5}:\hexcolorcomponent{#6#7}% + R:\hexcolorcomponent#2#3:\hexcolorcomponent#4#5:\hexcolorcomponent#6#7% \fi:0:0} \def\doifhexcolorelse#1% @@ -70,15 +78,19 @@ \expandafter\secondoftwoarguments \fi} +\def\docheckhexcolor#1% + {\doifhexcolorelse{#1}{\doifundefined{#1}{\setxvalue{\??cr#1}{\hexcolorpattern{#1}}}}\donothing} + \def\checkhexcolor[#1]% - {\doifhexcolorelse{#1}{\doifundefined{#1}% - {\expanded{\setxvalue{\??cr#1}{\hexcolorpattern#1}}}}\donothing} + {\expanded{\docheckhexcolor{#1}}} + +\def\colorHpattern{\@EA\hexcolorpattern\@EA{\@EA*\@@cl@@h}} % * == dummy placeholder \let\dodododefinecolor\dododefinecolor % we will overload this one \def\dododefinecolor#1#2#3#4[#5][#6]% {\doifhexcolorelse{#6} - {\setxvalue{\??cr#5}{\hexcolorpattern#6}} + {\setxvalue{\??cr#5}{\hexcolorpattern{#6}}} {\dodododefinecolor#1#2#3#4[#5][#6]}} \protect \endinput
\ No newline at end of file |