summaryrefslogtreecommitdiff
path: root/tex/context/modules/common/s-pre-08.tex
blob: b545bef2386cc2fa122382cd4102050ccad26c21 (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
%D \module
%D   [      file=s-pre-08,
%D        version=1999.09.01,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment 8,
%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 This is one of the 6 styles made for the \NTS\ presentation
%D at \EUROTEX\ 1999. The idea was to demonstrate a couple of
%D nasty things that one can do with \PDFTEX, being an example
%D of an extension. Afterwards it was provded that this could
%D also be done using traditional \TEX.
%D
%D This version is nearly the same as the original, although
%D since then the \METAPOST\ related macro have become more
%D smooth. The original used a couple of boxes, skipt and
%D fills, while this version uses the layer mechanism that
%D came available in fall 2000. This style is actually more a
%D demonstration gimmick than a real useful one.

%D You may want to turn on layer tracing:
%D
%D \starttyping
%D \tracelayerstrue
%D \stoptyping

\setuppapersize
  [S6][S6]

\setupbodyfont
  [pos,10pt]

%D We use the whole page and have no margins.

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

\setupcolors
  [state=start]

\definecolor[TextColor][s=.9]
\definecolor[PageColor][r=.5,g=.4,b=.3]
\definecolor[LineColor][r=.7,g=.6,b=.5]

\definecolor[ColorPage][r=.5,g=.6,b=.7]
\definecolor[ColorLine][r=.3,g=.4,b=.5]

\setupinteraction
  [state=start,
   display=new]

\setupinteractionscreen
  [option=max]

%D The page, sample text and pagenumber will have a background 
%D graphic. 

\defineoverlay [page]         [\uniqueMPgraphic{page}]
\defineoverlay [graphic]      [\uniqueMPgraphic{graphic}]
\defineoverlay [number]       [\uniqueMPgraphic{number}]

%D Each element will also be a button. 

\defineoverlay [nextpage]     [\overlaybutton{nextpage}]
\defineoverlay [previouspage] [\overlaybutton{previouspage}]
\defineoverlay [forward]      [\overlaybutton{forward}]

%D We are going to put all three elements on a layer. 

\definelayer   [main]
\defineoverlay [main] [\composedlayer{main}]

%D The page backgrounds are as follows: 

\setupbackgrounds
  [page]
  [background={previouspage,page}]

%D We could have put the main layer on the page overlay, but
%D the next solution makes us independent of the back and top
%D margins. The \type {idea} layer is for user purposes. 

\setupbackgrounds
  [text]
  [background={main,idea}]

%D The page number, sample text and explanation all have 
%D associated framed texts. The two overlays \type {sample} 
%D and \type {text} and there for special (user) purposes. 

\defineframedtext
  [PageText]
  [width=fit,offset=.5cm,
   before=,after=,frame=off,background={number,forward}]

\defineframedtext
  [SampleText]
  [width=.6\makeupwidth,height=fit,offset=2cm,align=middle,
   before=,after=,frame=off,background={graphic,sample,nextpage}]

\defineframedtext
  [TextText]
  [width=.6\makeupwidth,height=fit,offset=2cm,align=middle,
   before=,after=,frame=off,background={text,nextpage}]

%D Nothing goes on the page directly, since we use layers. The
%D \type {\null} command makes sure that at least something is
%D on the page so that the page is flushed. Here we also take 
%D care of placing the page number. 

\def\StartIdea
  {\null \dontcomplain}

\def\StopIdea
  {\setlayer
     [main]
     [x=\makeupwidth,y=.5cm,hoffset=-.5cm,location=lb]
     {\PageText{\pagenumber}}
   \page}

%D Both texts get their position registered. 

\def\StartSample
  {\setlayer
     [main]
     [hoffset=.75cm,voffset=.75cm]
     \bgroup \hpos {SampText:\realfolio} \bgroup \startSampleText [none]}

\def\StopSample
  {\stopSampleText \egroup \egroup}

%D Here the position of the sample text and explanationary 
%D text are passed on to the graphic that concerns the latter. 

% use setlayertext instead 

\def\StartText
  {\setMPpositiongraphic
     {TextText:\realfolio}{text}{other=SampText:\realfolio} 
   \setlayer
     [main]
     [x=\makeupwidth,y=\makeupheight,
      hoffset=-.75cm,voffset=-.75cm,
      location=lt]
     \bgroup \noindent \hpos {TextText:\realfolio} \bgroup \startTextText [none]}

\def\StopText
  {\stopTextText \egroup \egroup}

%D The graphics that encircle the two texts are related to
%D their position. This is because when they overlay, a shine
%D through is shown. This only shows up when there is enough
%D text to make them overlap.

\startuniqueMPgraphic{page}
  StartPage ; 
    pickup pencircle scaled .5cm ;
    fill Page withcolor \MPcolor{PageColor} ;
    draw Page withcolor \MPcolor{LineColor} ;
  StopPage ;
\stopuniqueMPgraphic

\startuniqueMPgraphic{number}
  path p ; p := fullcircle xscaled OverlayWidth yscaled OverlayHeight;
  pickup pencircle scaled .25cm ;
  fill p withcolor \MPcolor{TextColor} ;
  draw p withcolor (white-\MPcolor{PageColor}) ;
\stopuniqueMPgraphic

\startuniqueMPgraphic{graphic}
  path p ; p := fullcircle xscaled OverlayWidth yscaled OverlayHeight;
  pickup pencircle scaled .5cm ;
  fill p withcolor \MPcolor{TextColor} ;
  draw p withcolor \MPcolor{LineColor} ;
\stopuniqueMPgraphic

%D This graphic is calculated when a position is flushed that 
%D has this graphics as attached. The \type {self} reference 
%D is provided by \CONTEXT\ itself. 

\startMPpositiongraphic{text}
  initialize_box(\MPpos{\MPvar{other}}) ;
  path p ; p := fullcircle xscaled wxy yscaled hxy shifted cxy ;
  initialize_box(\MPpos{\MPvar{self}}) ;
  path q ; q := fullcircle xscaled wxy yscaled hxy shifted cxy ;
  pickup pencircle scaled .5cm ;
  fill q withcolor \MPcolor{TextColor} ;
  draw p withcolor (white-\MPcolor{PageColor}) ;
  clip currentpicture to q ;
  draw q withcolor \MPcolor{LineColor} ;
  anchor_box(\MPanchor{\MPvar{self}}) ;
\stopMPpositiongraphic

%D In order to be complete, we also define a title page. 
%D Here suddenly the text background shows up. 

\def\StartTitlePage
  {\startstandardmakeup
   \dontcomplain
   \setupframedtexts[TextText][width=fit]
   \StartText
   \bfd\setupinterlinespace
   \def\\{\blank\bfc\setupinterlinespace\def\\{\blank}}}

\def\StopTitlePage
  {\StopText
   \stopstandardmakeup}

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

%D For this purpose, we redefine the position graphic to 
%D handle a text only case: 

\startMPpositiongraphic{text}
  if box_found(\MPpos{\MPvar{other}}) :   
    initialize_box(\MPpos{\MPvar{other}}) ;
    path p ; p := fullcircle xscaled wxy yscaled hxy shifted cxy ;
  fi ; 
  initialize_box(\MPpos{\MPvar{self}}) ;
  path q ; q := fullcircle xscaled wxy yscaled hxy shifted cxy ;
  pickup pencircle scaled .5cm ;
  fill q withcolor \MPcolor{TextColor} ;
  if box_found(\MPpos{\MPvar{other}}) :   
    draw p withcolor (white-\MPcolor{PageColor}) ;
    clip currentpicture to q ;
    draw q withcolor \MPcolor{LineColor} ;
  else : 
    draw q withcolor (white-\MPcolor{PageColor}) ;
  fi ; 
  anchor_box(\MPanchor{\MPvar{self}}) ;
% setbounds currentpicture to boundingbox origin ;
\stopMPpositiongraphic

\doifnotmode{demo}{\endinput}

\starttext

\TitlePage 
  {Fancy Styles:\\layers}

\StartIdea
  \StartSample
    \input tufte
  \StopSample
  \StartText
    \input reich
  \StopText
\StopIdea

\StartIdea
  \StartSample
    \input knuth
  \StopSample
  \StartText
    \input reich
  \StopText
\StopIdea

\stoptext