s-pre-08.tex /size: 7493 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [      file=s-pre-08,
3%D        version=1999.09.01,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Presentation Environment 8,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D This is one of the 6 styles made for the \NTS\ presentation
15%D at \EUROTEX\ 1999. The idea was to demonstrate a couple of
16%D nasty things that one can do with \PDFTEX, being an example
17%D of an extension. Afterwards it was provded that this could
18%D also be done using traditional \TEX.
19%D
20%D This version is nearly the same as the original, although
21%D since then the \METAPOST\ related macro have become more
22%D smooth. The original used a couple of boxes, skipt and
23%D fills, while this version uses the layer mechanism that
24%D came available in fall 2000. This style is actually more a
25%D demonstration gimmick than a real useful one.
26
27%D You may want to turn on layer tracing:
28%D
29%D \starttyping
30%D \tracelayerstrue
31%D \stoptyping
32
33\setuppapersize
34  [S6][S6]
35
36\setupbodyfont
37  [pos,10pt]
38
39%D We use the whole page and have no margins.
40
41\setuplayout
42  [topspace=0cm,
43   backspace=0cm,
44   header=0pt,
45   footer=0pt,
46   width=middle,
47   height=middle]
48
49\setupcolors
50  [state=start]
51
52\definecolor[TextColor][s=.9]
53\definecolor[PageColor][r=.5,g=.4,b=.3]
54\definecolor[LineColor][r=.7,g=.6,b=.5]
55
56\definecolor[ColorPage][r=.5,g=.6,b=.7]
57\definecolor[ColorLine][r=.3,g=.4,b=.5]
58
59\setupinteraction
60  [state=start,
61   display=new]
62
63\setupinteractionscreen
64  [option=max]
65
66%D The page, sample text and pagenumber will have a background 
67%D graphic. 
68
69\defineoverlay [page]         [\uniqueMPgraphic{page}]
70\defineoverlay [graphic]      [\uniqueMPgraphic{graphic}]
71\defineoverlay [number]       [\uniqueMPgraphic{number}]
72
73%D Each element will also be a button. 
74
75\defineoverlay [nextpage]     [\overlaybutton{nextpage}]
76\defineoverlay [previouspage] [\overlaybutton{previouspage}]
77\defineoverlay [forward]      [\overlaybutton{forward}]
78
79%D We are going to put all three elements on a layer. 
80
81\definelayer   [main]
82\defineoverlay [main] [\composedlayer{main}]
83
84%D The page backgrounds are as follows: 
85
86\setupbackgrounds
87  [page]
88  [background={previouspage,page}]
89
90%D We could have put the main layer on the page overlay, but
91%D the next solution makes us independent of the back and top
92%D margins. The \type {idea} layer is for user purposes. 
93
94\setupbackgrounds
95  [text]
96  [background={main,idea}]
97
98%D The page number, sample text and explanation all have 
99%D associated framed texts. The two overlays \type {sample} 
100%D and \type {text} and there for special (user) purposes. 
101
102\defineframedtext
103  [PageText]
104  [width=fit,offset=.5cm,
105   before=,after=,frame=off,background={number,forward}]
106
107\defineframedtext
108  [SampleText]
109  [width=.6\makeupwidth,height=fit,offset=2cm,align=middle,
110   before=,after=,frame=off,background={graphic,sample,nextpage}]
111
112\defineframedtext
113  [TextText]
114  [width=.6\makeupwidth,height=fit,offset=2cm,align=middle,
115   before=,after=,frame=off,background={text,nextpage}]
116
117%D Nothing goes on the page directly, since we use layers. The
118%D \type {\null} command makes sure that at least something is
119%D on the page so that the page is flushed. Here we also take 
120%D care of placing the page number. 
121
122\def\StartIdea
123  {\null \dontcomplain}
124
125\def\StopIdea
126  {\setlayer
127     [main]
128     [x=\makeupwidth,y=.5cm,hoffset=-.5cm,location=lb]
129     {\PageText{\pagenumber}}
130   \page}
131
132%D Both texts get their position registered. 
133
134\def\StartSample
135  {\setlayer
136     [main]
137     [hoffset=.75cm,voffset=.75cm]
138     \bgroup \hpos {SampText:\realfolio} \bgroup \startSampleText [none]}
139
140\def\StopSample
141  {\stopSampleText \egroup \egroup}
142
143%D Here the position of the sample text and explanationary 
144%D text are passed on to the graphic that concerns the latter. 
145
146% use setlayertext instead 
147
148\def\StartText
149  {\setMPpositiongraphic
150     {TextText:\realfolio}{text}{other=SampText:\realfolio} 
151   \setlayer
152     [main]
153     [x=\makeupwidth,y=\makeupheight,
154      hoffset=-.75cm,voffset=-.75cm,
155      location=lt]
156     \bgroup \noindent \hpos {TextText:\realfolio} \bgroup \startTextText [none]}
157
158\def\StopText
159  {\stopTextText \egroup \egroup}
160
161%D The graphics that encircle the two texts are related to
162%D their position. This is because when they overlay, a shine
163%D through is shown. This only shows up when there is enough
164%D text to make them overlap.
165
166\startuniqueMPgraphic{page}
167  StartPage ; 
168    pickup pencircle scaled .5cm ;
169    fill Page withcolor \MPcolor{PageColor} ;
170    draw Page withcolor \MPcolor{LineColor} ;
171  StopPage ;
172\stopuniqueMPgraphic
173
174\startuniqueMPgraphic{number}
175  path p ; p := fullcircle xscaled OverlayWidth yscaled OverlayHeight;
176  pickup pencircle scaled .25cm ;
177  fill p withcolor \MPcolor{TextColor} ;
178  draw p withcolor (white-\MPcolor{PageColor}) ;
179\stopuniqueMPgraphic
180
181\startuniqueMPgraphic{graphic}
182  path p ; p := fullcircle xscaled OverlayWidth yscaled OverlayHeight;
183  pickup pencircle scaled .5cm ;
184  fill p withcolor \MPcolor{TextColor} ;
185  draw p withcolor \MPcolor{LineColor} ;
186\stopuniqueMPgraphic
187
188%D This graphic is calculated when a position is flushed that 
189%D has this graphics as attached. The \type {self} reference 
190%D is provided by \CONTEXT\ itself. 
191
192\startMPpositiongraphic{text}
193  initialize_box(\MPpos{\MPvar{other}}) ;
194  path p ; p := fullcircle xscaled wxy yscaled hxy shifted cxy ;
195  initialize_box(\MPpos{\MPvar{self}}) ;
196  path q ; q := fullcircle xscaled wxy yscaled hxy shifted cxy ;
197  pickup pencircle scaled .5cm ;
198  fill q withcolor \MPcolor{TextColor} ;
199  draw p withcolor (white-\MPcolor{PageColor}) ;
200  clip currentpicture to q ;
201  draw q withcolor \MPcolor{LineColor} ;
202  anchor_box(\MPanchor{\MPvar{self}}) ;
203\stopMPpositiongraphic
204
205%D In order to be complete, we also define a title page. 
206%D Here suddenly the text background shows up. 
207
208\def\StartTitlePage
209  {\startstandardmakeup
210   \dontcomplain
211   \setupframedtexts[TextText][width=fit]
212   \StartText
213   \bfd\setupinterlinespace
214   \def\\{\blank\bfc\setupinterlinespace\def\\{\blank}}}
215
216\def\StopTitlePage
217  {\StopText
218   \stopstandardmakeup}
219
220\def\TitlePage#1%
221  {\StartTitlePage#1\StopTitlePage}
222
223%D For this purpose, we redefine the position graphic to 
224%D handle a text only case: 
225
226\startMPpositiongraphic{text}
227  if box_found(\MPpos{\MPvar{other}}) :   
228    initialize_box(\MPpos{\MPvar{other}}) ;
229    path p ; p := fullcircle xscaled wxy yscaled hxy shifted cxy ;
230  fi ; 
231  initialize_box(\MPpos{\MPvar{self}}) ;
232  path q ; q := fullcircle xscaled wxy yscaled hxy shifted cxy ;
233  pickup pencircle scaled .5cm ;
234  fill q withcolor \MPcolor{TextColor} ;
235  if box_found(\MPpos{\MPvar{other}}) :   
236    draw p withcolor (white-\MPcolor{PageColor}) ;
237    clip currentpicture to q ;
238    draw q withcolor \MPcolor{LineColor} ;
239  else : 
240    draw q withcolor (white-\MPcolor{PageColor}) ;
241  fi ; 
242  anchor_box(\MPanchor{\MPvar{self}}) ;
243% setbounds currentpicture to boundingbox origin ;
244\stopMPpositiongraphic
245
246\doifnotmode{demo}{\endinput}
247
248\starttext
249
250\TitlePage 
251  {Fancy Styles:\\layers}
252
253\StartIdea
254  \StartSample
255    \input tufte
256  \StopSample
257  \StartText
258    \input reich
259  \StopText
260\StopIdea
261
262\StartIdea
263  \StartSample
264    \input knuth
265  \StopSample
266  \StartText
267    \input reich
268  \StopText
269\StopIdea
270
271\stoptext
272