summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/modules/mkii/s-pre-09.mkii
blob: a20b9f31acd3fe01b780bfcc93152fd56c8197e3 (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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
%D \module
%D   [      file=s-pre-09,
%D        version=unknown,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment 9,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D I made this style when I had to give a presentation on
%D the \MAPS\ bibliography production for several user group
%D meetings. This style is rather tuned for combinations of
%D examples and explanations. The colors match the \MAPS\
%D bibliography colors.

\startmode[asintended] \setupbodyfont[lbr] \stopmode

\setupbodyfont[14.4pt]

%D A couple of years later, in 2001 this style was documented
%D and made public. While documenting, I also changed box
%D building on top of overlays into the now available layer
%D positioning. So, this styles demonstrates quite some
%D tricks.

\setuppapersize
  [S6][S6]

\setuplayout
  [topspace=0cm,
   backspace=0cm,
   header=0pt,
   footer=0pt,
   width=middle,
   height=middle]

%D Local environments can be set by using the setups commands.
%D For downward compatibility, we keep supporting the \type
%D {\...Settings} hooks. Using local environments is seldom
%D needed.

\let\TextSettings  \empty
\let\SampleSettings\empty

\startsetups [text]   \TextSettings   \stopsetups
\startsetups [sample] \SampleSettings \stopsetups

%D The dimensions are kind of fixed.

\def\FrameWidth  {448pt}
\def\FrameHeight {348pt}
\def\FrameOffset {24pt}
\def\FrameSkip   {12pt}

%D But they {\em can} and {\em will} be changed.

\def\FrameWidth  {408pt}
\def\FrameHeight {318pt}

%D The funny values come from the $3:4$ display aspect
%D ratio.

\setupcolors
  [state=start]

\definecolor[PageColor]       [s=.40]
\definecolor[TextColor]       [s=.90]
\definecolor[InteractionColor][r=.40]
\definecolor[LineColor]       [r=.60,g=.60]

%D Of course we go interactive and since we will probably
%D open other documents, we make sure that the viewer opens a
%D new window.

\setupinteraction
  [color=InteractionColor,
   contrastcolor=LineColor,
   display=new,
   state=start]

\setupinteractionscreen
  [option=max]

%D Before we come to the real macros, we do a little bit of
%D tuning.

\setupitemize
  [1][packed]

\setuptyping
  [blank=medium]

%D Apart from the titlepage, the page gets a simple colored
%D background. Later we will activate the background.

\setupbackgrounds
  [page]
  [backgroundcolor=PageColor]

%D Everything gets frames by a nice \METAPOST\ frame.

\defineoverlay [background] [\uniqueMPgraphic{background}]

\startuniqueMPgraphic{background}
  path p ; color c, w, d ;
  c := \MPcolor{PageColor} ;
  w := \MPcolor{TextColor} ;
  d := \MPcolor{LineColor} ;
  p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ;
  pickup pencircle scaled (1.5*\FrameSkip) ;
  draw p withcolor c ;
  pickup pencircle scaled \FrameSkip ;
  fill p withcolor w ;
  draw p withcolor d ;
\stopuniqueMPgraphic

%D We will present samples and explanation pair||wise, so
%D we need a hyperlink that skips a page.

\defineoverlay [nextpage]     [\overlaybutton{nextpage}]
\defineoverlay [previouspage] [\overlaybutton{previouspage}]
\defineoverlay [skippage]     [\overlaybutton{page(+2)}]

%D Layers are normally used to position multiple content on
%D a specific overlay. Here we will use them to position
%D only and since the samples and text will swap place, we
%D will use quite a few layers.

\defineoverlay [text]   [\composedlayer{text}]
\defineoverlay [sample] [\composedlayer{sample}]
\defineoverlay [common] [\composedlayer{common}]

%D There are three positions. When combined, the sample and
%D text windows overlap, otherwise the lone window is
%D centered. We could have used one layer and reversed the
%D order by setting the \type {direction} parameter, but
%D this approach is more readable.

\definelayer
  [text]
  [x=\makeupwidth,y=\makeupheight,location=lt,
   hoffset=-\FrameSkip,voffset=-\FrameSkip]

\definelayer
  [sample]
  [hoffset=\FrameSkip,voffset=\FrameSkip]

\definelayer
  [common]
  [x=.5\makeupwidth,y=.5\makeupheight,location=c]

%D The topic is put in the lower right corner of the text
%D window.

\defineoverlay [topic] [\composedlayer{topic}]

\definelayer
  [topic]
  [x=\FrameWidth,y=\FrameHeight,location=lt,
   hoffset=-\FrameOffset,voffset=-\FrameSkip]

%D The topic is put in a framed box. That way we can make
%D sure that it gets a background, which looks better when
%D it covers something else. Otherwise we could have stuct
%D to:
%D
%D \starttyping
%D \def\Topic#1%
%D   {\setlayer[topic]{\color[PageColor]{\bfb\setstrut#1}}}
%D \stoptyping
%D
%D But, we go for the nice alternative:

\def\Topic#1%
  {\doifsomething{#1}
     {\setlayer [topic]
        {\bfb\setstrut
         \inframed
           [frame=off,foregroundcolor=PageColor,offset=0pt,
            background=color,backgroundcolor=TextColor]
           {#1}}}}

%D The sample as well as the explanation will be collected in
%D a buffer. That way we can reuse the content. We could
%D have used a box instead, but can we be sure that the content
%D is not adapting itself? So, buffers we use.

\resetbuffer[sample]
\resetbuffer[text]

%D Both the sample and explanation are kind of windowed.

\defineframedtext
  [SampleText]
  [width=\FrameWidth,height=\FrameHeight,offset=\FrameOffset,
   frame=off,align=normal,strut=no,before=,after=,
   background={background,nextpage}]

%D We safe some keying in by combining things in one macro.

\def\DoSampleText#1#2#3% kind layer overlays
  {\setupframedtexts[SampleText][background={background,#3}]
   \setlayer[#2]
     {\startSampleText[none]
        \setups[#1]
        \getbuffer[#1]
      \stopSampleText}}

\def\StartSample{\dostartbuffer[sample][StartSample][StopSample]}
\def\StartText  {\dostartbuffer[text]  [StartText]  [StopText]}

%D The following definitions apply at the outer level.

\def\StopSample
  {\startstandardmakeup
     \DoSampleText{sample}{common}{nextpage}
   \stopstandardmakeup
   \resetbuffer[sample]}

\def\StopText
  {\startstandardmakeup
     \DoSampleText{text}{common}{topic,nextpage}
   \stopstandardmakeup
   \resetbuffer[text]}

\setupbackgrounds[page][background={color,nextpage}]
\setupbackgrounds[text][background=common]

%D When we combine sample and text, we get slightly
%D different definitions. As you can see we generate two
%D pages. Watch how we manipulate the order of the
%D overlays and teh nature of the buttons. Here data
%D abstraction really pays off.

\def\StartIdea
  {\bgroup
   \let\StopSample\relax
   \let\StopText  \relax}

\def\StopIdea%
  {\setupbackgrounds[page][background={color,skippage}]
   \setupbackgrounds[text][background={text,sample}]
   \startstandardmakeup
     \DoSampleText{sample}{sample}{previouspage}
     \DoSampleText{text}  {text}  {topic,nextpage}
   \stopstandardmakeup
   \setupbackgrounds[page][background={color,nextpage}]
   \setupbackgrounds[text][background={sample,text}]
   \startstandardmakeup
     \DoSampleText{sample}{sample}{previouspage}
     \DoSampleText{text}  {text}  {topic,nextpage}
   \stopstandardmakeup
   \egroup}

%D The rest of the definitions takes care of the title page.
%D Please don't steal this one for your own documents.

\defineoverlay[joke] [\useMPgraphic{joke}{n=0}] % not to be changed!

\startuseMPgraphic{joke}{n}
  StartPage ;
  path p, q ; numeric w ; pair xy ;
  set_grid(OverlayWidth,OverlayHeight,OverlayWidth/8,OverlayHeight/8) ;
  if \MPvar{n}=1 :
    p := fulldiamond ; fill Page withcolor \MPcolor{TextColor} ;
  else :
    p := fullsquare  ; fill Page withcolor \MPcolor{PageColor} ;
  fi ;
  forever :
    xy := center Page randomized (OverlayWidth,OverlayHeight) ;
    if new_on_grid(xpart xy, ypart xy) :
      q := (p xyscaled (OverlayWidth/5,OverlayHeight/5))
           randomized (\FrameSkip,\FrameSkip)
           shifted xy ;
      w := (\FrameSkip) randomized (\FrameSkip/2) ;
      draw q withcolor \MPcolor{PageColor} withpen pencircle scaled (1.5w) ;
      fill q withcolor \MPcolor{TextColor} ;
      draw q withcolor \MPcolor{LineColor} withpen pencircle scaled (   w) ;
    fi ;
    exitif grid_full ;
  endfor ;
  StopPage ;
\stopuseMPgraphic

\defineoverlay[fuzzy][\useMPgraphic{fuzzy}]

\startuseMPgraphic{fuzzy}
  path p ; numeric w ;
  p := (fullsquare xyscaled (OverlayWidth,OverlayHeight))
       randomized (\FrameSkip,\FrameSkip) ;
  w := (\FrameSkip) randomized (\FrameSkip/2) ;
  draw p withcolor \MPcolor{PageColor} withpen pencircle scaled (1.5w) ;
  fill p withcolor \MPcolor{TextColor} ;
  draw p withcolor \MPcolor{LineColor} withpen pencircle scaled (   w) ;
\stopuseMPgraphic

%D This time we use a fit window, but with a slightly randomized
%D frame, our trademark so to say.

\def\StartTitlePage
  {\bgroup
   \setupbackgrounds[page][background={joke,nextpage}]
   \startstandardmakeup
   \switchtobodyfont[big]
   \setupframedtexts
     [SampleText]
     [background=fuzzy,
      foregroundcolor=PageColor,
      width=fit,
      height=fit,
      align=middle]
   \startSampleText[middle]
   \bfd\setupinterlinespace
   \def\\{\bfb\setupinterlinespace\vfil\def\\{\vfil}}}

\def\StopTitlePage
  {\stopSampleText
   \stopstandardmakeup
   \egroup}

\def\TitlePage#1%
  {\StartTitlePage#1\StopTitlePage}

%D Let's nill some error prone presentation macros.

\let\Subject  \Topic
\let\Topics   \gobbleoneargument
\let\Subjects \relax

%D We will avoid \quote {overfull} messages.

\dontcomplain

\doifnotmode{demo}{\endinput}

%D The (rather silly) demo section.

\starttext

\setupbodyfont[12pt]

\TitlePage{Quotes, Quotes\\and more quotes}

\StartIdea
  \StartSample
    \input knuth \par
  \StopSample
  \StartText
    \Topic{Tufte}
    \input tufte \par
  \StopText
 \StopIdea

\StartIdea
  \StartSample
    \input materie \par
  \StopSample
  \StartText
    \input reich   \par
  \StopText
\StopIdea

\StartText
  \input tufte \par
\StopText

\StartIdea
  \StartSample
    \input knuth \par
  \StopSample
  \StartText
    \input tufte \par
  \StopText
\StopIdea

\stoptext