summaryrefslogtreecommitdiff
path: root/tex/context/base/colo-ext.tex
blob: 182c438fa5a6a2386d9e47b3d676e88170a7cf9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
%D \module
%D   [       file=colo-ext, % mostof thsi code used to be in colo-ini.tex
%D        version=1997.04.01,
%D          title=\CONTEXT\ Color Macros,
%D       subtitle=Extras,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{Context Color Macros / extras}

\unprotect

%D \macros
%D   {negatecolorcomponent, negativecolorbox}
%D
%D Sometimes, especially when we deal with typesetting
%D devices, we want to reverse the color scheme. Instead of
%D recalculating all those colors, we use a quick and dirty
%D approach:
%D
%D \starttyping
%D \negativecolorbox0
%D \stoptyping
%D
%D will negate the colors in box zero.

\def\negatecolorcomponent#1% #1 = \macro
  {\scratchdimen\onepoint\advance\scratchdimen-#1\onepoint
   \ifdim\scratchdimen<\zeropoint\scratchdimen\zeropoint\fi
   \edef#1{\withoutpt\the\scratchdimen}}

\def\negatecolorbox#1%
  {\setbox#1\hbox
     {\dostartnegative
      \localstartcolor[white]\vrule\!!height\ht#1\!!depth\dp#1\!!width\wd#1\localstopcolor
      \hskip-\wd#1%
      \box#1%
      \dostopnegative}}

%D There are in principle two ways to handle overprint: bound to colors
%D or independent. For the moment we only support independent overprint
%D handling. Here we deal with a per-document setting.

\setupcolors
  [\c!overprint=\v!no]

\def\starttextoverprint
  {\doifelse\@@cloverprint\v!yes
     {\let\stoptextoverprint\dostopoverprint\dostartoverprint}
     {\let\stoptextoverprint\donothing}}

\let\stoptextoverprint\donothing

\appendtoks \starttextoverprint \to \everystarttextproperties
\appendtoks \stoptextoverprint  \to \everystoptextproperties

\protect \endinput