summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/context/manuals/reference/en/co-backgrounds.tex
blob: 77857670da578d6e7259c32a9afd5ff15b92c4a9 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
\startcomponent co-backgrounds

\environment contextref-env
\product contextref

\chapter[backgrounds]{Backgrounds and Overlays}

\section[background text]{Text backgrounds}
\index{screens}
\index{backgrounds+text}
\macro{\tex{setupscreens}}
\macro{\tex{setupbackground}}
\macro{\tex{background}}
\macro{\tex{startbackground}}
\macro{\tex{startraster}}

In a number of commands, for example \type {\framed}, you
can use backgrounds. A background may have a color or a
screen (pure gray). By default the \type {backgroundscreen} is
set at \type {0.95}. Usable values lie between ~0.70
and~1.00.

Building screens in \TEX\ is memory consuming and may cause
error messages. The screens are therefore build up
externally by means of \POSTSCRIPT\ or \PDF\ instructions.
This is set up with:

\showsetup{setupscreens}

The parameter \type {factor} makes only sense when the
method \type {line} or \type {dot} is chosen. The parameter
\type {screen} determines the \quote {grid} of the screen.
Text on a screen of 0.95 is still readable.

Visually the \TEX\ screens are comparable with \POSTSCRIPT\
screens. When memory and time are non issues \TEX\ screens
come out more beautiful than postscript screens. There are
many ways to implement screens but only the mentioned
methods are implemented.

\startbackground
Behind the text in the pagebody screens can be typeset.
This is done by enclosing the text with the commands:

\startexample
\starttyping
\startbackground
\stopbackground
\stoptyping
\stopexample

We have done so in this text. Backgrounds can cross page
boundaries when necessary. Extra vertical whitespace is
added around the text for reasons of readability.
\stopbackground

\showsetup{startbackground}

The background can be set up with:

\showsetup{setupbackground}

The command \type {\background} can be used in combination
with for example placeblocks:

\startexample
\starttyping
\placetable
  {Just a table.}
  \background
  \starttable[|c|c|c|]
  \HL
  \VL red  \VL green   \VL blue   \VL \AR
  \VL cyan \VL magenta \VL yellow \VL \AR
  \HL
  \stoptable
\stoptyping
\stopexample

The command  \type{\background} expects an argument.
Because a table is \quote {grouped} it will generate
\argchars\ by itself and no extra braces are necessary.

\showsetup{background}

A fundamental difference between colors and screens is that
screens are never converted. There is a command \type
{\startraster} that acts like \type {\startcolor}, but in
contrast to the color command, \CONTEXT\ does not keep track
of screens across page boundaries. This makes sense,
because screens nearly always are used as simple backgrounds.

\section[backgrounds layout]{Layout backgrounds}
\index{screens}
\index{backgrounds+layout}
\macro{\tex{setupbackgrounds}}

In interactive or screen documents the different screen
areas may have different functions. Therefore the systematic
use of backgrounds may seem obvious. It is possible to
indicate all areas or compartments of the pagebody
(screenbody). This is done with:

\showsetup{setupbackgrounds}

Don't confuse this command with \type {\setupbackground}
(singular). A background is only calculated when something
has changed. This is more efficient while generating a
document. When you want to calculate each background
separately you should set the parameter \type {state} at
\type {repeat}. The page background is always recalculated,
since it provides an excellent place for page dependent
buttons.

After \type {\setupbackgrounds} without any
arguments the backgrounds are also re||calculated.

A specific part of the layout is identified by means of
an axis (see \in{figure}[fig:axis]).

\placefigure
  [hier][fig:axis]
  {The coordinates in \tex{setupbackgrounds}.}
  {\getbuffer[colo-5]}

You are allowed to provide more than one coordinate at a
time, for example:

\startexample
\starttyping
\setupbackgrounds
  [header,text,footer]
  [text]
  [background=screen]
\stoptyping
\stopexample

or

\startexample
\starttyping
\setupbackgrounds
  [text]
  [text,rightedge]
  [background=color,backgroundcolor=MyColor]
\stoptyping
\stopexample

Some values of the paremeter \type{page}, like \type{offset}
and \type{corner} also apply to other compartments, for
example:

\startexample
\starttyping
\setupbackgrounds
  [page]
  [offset=.5\bodyfontsize
   depth=.5\bodyfontsize]
\stoptyping
\stopexample

When you use menus in an interactive or screen document
alignment is automatically adjusted for offset and|/|or depth.
It is also possible to set the parameter \type{page} to the
standard colors and screens.

If for some reason an adjustment is not generated you can
use \type{\setupbackgrounds} (without an argument). In
that case \CONTEXT\ will calculate a new background.

\section[overlays]{Overlays}
\index{overlays}
\macro{\tex{defineoverlay}}

\TEX\ has only limited possibilities to enhance the layout
with specific features. In \CONTEXT\ we have the possibility
to \quote{add something to a text element}. You can think of
a drawing made in some package or other ornaments. What we
technically do is lay one piece of text over another piece
text. That is why we speak of \quote {overlays}.

When we described the backgrounds you saw the paremeters
\type {color} and \type {screen}. These are both examples of
an overlay. You can also define your own background:

\startbuffer
\defineoverlay[gimmick][\green a green text on a background]

\framed
  [height=2cm,background=gimmick,align=middle]
  {at\\the\\foreground}
\stopbuffer

\typebuffer

This would look like this:

\startlinecorrection
\getbuffer
\stoplinecorrection

An overlay can be anything:

\startbuffer
\defineoverlay
  [gimmick]
  [{\externalfigure[cow][width=\overlaywidth,height=\overlayheight]}]
\framed
  [height=2cm,width=5cm,background=gimmick,align=right]
  {\vfill this is a cow}
\stopbuffer

\typebuffer

We can see that in designing an overlay the width and height
are available in macros. This enables us to scale the
figure.

\startlinecorrection
\getbuffer
\stoplinecorrection

We can combine overlays with one another or with a screen and
color.

\startbuffer
\defineoverlay
  [gimmick]
  [{\externalfigure[cow][width=\overlaywidth,height=\overlayheight]}]
\defineoverlay
  [nextgimmick]
  [\red A Cow]
\framed
  [height=2cm,width=.5\textwidth,
   background={screen,gimmick,nextgimmick},align=right]
  {\vfill this is a cow}
\stopbuffer

\startlinecorrection
\getbuffer
\stoplinecorrection

The \TEX\ definitions look like this:

\typebuffer

\stopcomponent