]> mj.ucw.cz Git - ucwmac.git/blobdiff - ucwmac.tex
A better interface for setting colors
[ucwmac.git] / ucwmac.tex
index 6c7a5dec709091f01ec3e7ebf9c0ff9b65bfe290..d4b4e3d60c93c448f34053da0dea477ed63a1b0e 100644 (file)
 
 %%% Colors %%%
 
+% Use of pdfTeX color stack:
+% \colorpush\rgb{1 0 0} puts a new color on the stack
+% \colorset\rgb{1 0 0} replaces the top color on the stack
+% \colorpop pops the top color
+% \colorlocal\rgb{1 0 0} set a color locally until the end of the current group
 \chardef\colorstk=\pdfcolorstackinit page direct{0 g 0 G}
-\def\colorpush#1{\pdfcolorstack\colorstk push{#1 rg #1 RG}}
-\def\colorpushgray#1{\pdfcolorstack\colorstk push{#1 g #1 G}}
-\def\colorpushcmyk#1{\pdfcolorstack\colorstk push{#1 k #1 K}}
+\def\colorset#1{\pdfcolorstack\colorstk set #1}
+\def\colorpush#1{\pdfcolorstack\colorstk push #1}
 \def\colorpop{\pdfcolorstack\colorstk pop}
+\def\colorlocal{\aftergroup\colorpop\colorpush}
+
+% Different ways of describing colors: \rgb{R G B}, \gray{G}, \cmyk{C M Y K}
+% (all components are real numbers between 0 and 1)
+\def\rgb#1{{#1 rg #1 RG}}
+\def\gray#1{{#1 g #1 G}}
+\def\cmyk#1{{#1 k #1 K}}
 
 %%% Localization %%%