s-present-colorful.mkiv /size: 10 Kb    last modification: 2021-10-28 13:51
1%D \module
2%D   [      file=s-present-colorful, % was s-pre-04
3%D        version=1998.09.06,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Presentation Environment Colorful,
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\usemodule[present-general]
15
16\startmodule[present-colorful]
17
18%D \macros
19%D   {setupbodyfont}
20%D
21%D This is just another environment for typesetting interactive presentations. I
22%D wrote this module on behalf of a course I gave for the United Kingdom \TeX\ users
23%D group.
24
25\setupbodyfont[postscript,14.4pt]
26
27%D \macros
28%D   {setupcolors,definecolor}
29%D
30%D I started using dark blue for the navigational elements. In that context, dark
31%D red is a logical choice for the contrast color. While playing around with the
32%D navigational elements I decided to use the not so dominant color yellow for the
33%D status bar.
34%D
35%D A few days before I wrote this style, the recent acquisition of Mondriaans last
36%D painting by the Dutch governement was a hot topic in the Dutch news scenary.
37%D Therefore I decided to replace the rather dull title page by something more
38%D colorful, in mondriaan colors, but far more random than any of his paintings. For
39%D consistence we remap the already defined primary colors.
40%D
41%D The \MKIV\ version is adapted abit so that the title is better visible.
42
43\setupcolors [state=start]
44
45\definecolor [NoneColor] [s=.6]
46\definecolor [GotoColor] [b=.6]        \definecolor[blue]  [GotoColor]
47\definecolor [ExitColor] [r=.6]        \definecolor[red]   [ExitColor]
48\definecolor [JumpColor] [s=.6]
49\definecolor [UserColor] [g=.6]        \definecolor[green] [UserColor]
50%definecolor [StepColor] [r=.6,g=.6]   \definecolor[yellow][StepColor]
51\definecolor [StepColor] [y=.8]        \definecolor[yellow][StepColor]
52
53\definecolor [PageColor] [s=.80]       \definecolor[gray]  [PageColor]
54\definecolor [TextColor] [s=.90]
55\definecolor [TitleColor][s=.90]
56
57%D \macros
58%D   {setuppapersize}
59%D
60%D As usual, we take a screen oriented paper size:
61
62\setuppapersize
63  [S6][S6]
64
65%D \macros
66%D   {setuplayout,setupinteractionscreen}
67%D
68%D The layout definition fits into this $600\times450$ point area, but the
69%D dimensions are somewhat diffused by the text background offset.
70
71\setuplayout
72  [width=530pt,
73   height=400pt,
74   header=0pt,
75   footer=0pt,
76   backspace=15pt,
77   topspace=15pt,
78   bottomdistance=15pt,
79   bottom=10pt,
80   margin=0pt,
81   rightedgedistance=15pt,
82   rightedge=30pt]
83
84\setupinteractionscreen
85  [option=max]
86
87%D \macros
88%D   {setupbackgrounds}
89%D
90%D Both the page and the text area have a gray background. The \type {[text,text]}
91%D area also has an offset. Later we will see that we have to compensate for that in
92%D the navigational areas.
93
94\setupbackgrounds
95  [page]
96  [background=color,
97   backgroundcolor=PageColor]
98
99\setupbackgrounds
100  [text][text]
101  [background=color,
102   backgroundcolor=TextColor,
103   backgroundoffset=5pt]
104
105%D \macros
106%D   {setupinteraction}
107%D
108%D For convenient navigation, we turn on interaction.
109
110\setupinteraction
111  [state=start,
112   menu=on,
113   color=UserColor,
114   contrastcolor=NoneColor]
115
116%D \macros
117%D   {setupsubpagenumber}
118%D
119%D When navigating the document, we keep the title page out of sight, therefore we
120%D use sub page numbers.
121
122\setupsubpagenumber
123  [state=start,
124   way=bytext]
125
126%D \macros
127%D   {setupinteractionmenu}
128%D
129%D There is only one interaction menu, located in the right edge of the screen. Both
130%D offsets enlarge the edge by the same amount as the text background offset.
131
132\setupinteractionmenu
133  [right]
134  [state=start,
135   frame=off,
136   strut=no,
137   offset=0pt,
138   inbetween=,
139   bottomoffset=-5pt,
140   topoffset=-5pt]
141
142%D \macros
143%D   {startinteractionmenu}
144%D
145%D The menu itself is not that spectacular. We use the start||stop alternative for
146%D setting the content. The macro \type {\interactioncolor} expands into either the
147%D interaction color or the contrast color, the latter only when no jump is
148%D possible.
149
150\startinteractionmenu[right]
151    \setupinteraction[color=GotoColor]
152    \but [previoussubpage] \Triangle {90}\hsize\interactioncolor \\
153    \vskip10pt
154    \but [nextsubpage]     \Triangle{270}\hsize\interactioncolor \\
155    \vfill
156    \but [PreviousJump]    \Triangle{180}\hsize{NoneColor}       \\
157    \vskip-5pt
158    \but [NextJump]        \Triangle  {0}\hsize{NoneColor}       \\
159\stopinteractionmenu
160
161%D \macros
162%D   {setupinteractionbar}
163%D
164%D The interaction bar at the bottom is also larger than the normal width of the
165%D bottom area.
166
167\setupinteractionbar
168  [width=\textwidth,
169   height=\bottomheight,
170   distance=10pt,
171   color=NoneColor,
172   contrastcolor=StepColor]
173
174%D \macros
175%D   {setupbottomtexts}
176%D
177%D The bar is centered in the middle.
178
179\setupbottomtexts
180  [{\interactionbar[alternative=f]}]
181
182%D We can exit viewing with a close button, located on the rightmost bottom area.
183
184\unexpanded\def\CloseButton
185  {\ifnum\realpageno>\plusone
186     \button
187       [width=\rightedgewidth,
188        height=\bottomheight,
189        offset=overlay,
190        background=color,
191        backgroundcolor=ExitColor,
192        frame=off]
193       {}%
194       [CloseDocument]%
195  \fi}
196
197\setupbottomtexts
198  [edge][][\CloseButton]
199
200%D \macros
201%D   {definesymbol,setupitemize}
202%D
203%D Because some prominent things are rectangular or triangular, we prefer some
204%D different symbols in itemizations:
205
206\definesymbol[1][\blacktriangleright]
207\definesymbol[2][\blacktriangledown]
208\definesymbol[3][\blacktriangleright]
209\definesymbol[4][\blacktriangledown]
210
211\setupitemize[each][color=NoneColor]
212
213%D \macros
214%D   {TitlePage,defineoverlay,button,setupalign,
215%D    setupbackgrounds,setupinteraction,setupinteractionbar,
216%D    startstandardmakeup,switchtobodyfont,setupinterlinespace}
217%D
218%D Now the main layout and navigational definitions are done, it makes sense to
219%D define and tune some structuring commands. First we build the titlepage.
220
221\defineoverlay [TitleGraphic] [\useMPgraphic{title}]
222\defineoverlay [NextPage]     [\overlaybutton{nextpage}]
223
224\unexpanded\def\StartTitlePage
225  {\setupbackgrounds[page][background={color,TitleGraphic,NextPage}]
226   \setupbackgrounds[text][text][background=]
227   \setupinteraction[menu=off]
228   \setupinteractionbar[state=stop]
229   \startpagemakeup
230   \switchtobodyfont[24pt]
231   \bfd\setupinterlinespace
232   \setupalign[middle]
233   \vfil
234   \enforced\let\\\vfil
235   \scale
236     [factor=max]\bgroup
237       \framed
238         [frame=off,
239          align=middle,
240          foregroundcolor=TitleColor,
241          offset=.05\textwidth]
242         \bgroup}
243
244\unexpanded\def\StopTitlePage
245  {\egroup
246   \egroup
247   \vfil\vfil\vfil
248   \stoppagemakeup
249   \setupinteraction[menu=on]
250   \setupinteractionbar[state=start]
251   \setupbackgrounds[page][background=color]
252   \setupbackgrounds[text][text][background=color]}
253
254\unexpanded\def\TitlePage#1%
255  {\StartTitlePage#1\StopTitlePage}
256
257%D \macros
258%D   {Topic, Nopic, Subject,
259%D    definehead, setuphead}
260%D
261%D We use \type {\Topic} and \type {\Subject} instead of chapters and sections. The
262%D \type {\Nopic} alternative is meant for internal use.
263
264\definehead [Topic]   [chapter]
265\definehead [Nopic]   [title]
266\definehead [Subject] [section]
267
268\setuphead
269  [Topic,Nopic]
270  [after={\blank[3*medium]},
271   number=no,
272   style=\bfb,
273   page=yes,
274   alternative=middle]
275
276\setuphead
277  [Subject]
278  [after=\blank,
279   number=no,
280   page=yes,
281   continue=no,
282   style=\bfa]
283
284%D \macros
285%D   {Topics, Subjects,
286%D    setuplist, placelist, startcolumns}
287%D
288%D This style is meant for the more large presentations, and therefore provided for
289%D a list of topics as well as local lists of subjects. When many topics are
290%D introduces, the list is typeset in columns.
291
292\setuplist
293  [Topic,Subject]
294  [alternative=g,
295   interaction=all,
296   before=,
297   after=]
298
299\setuplist
300  [Topic]
301  [criterium=all]
302
303\unexpanded\def\Topics#1%
304  {\determinelistcharacteristics[Topic]
305   \ifnum\utilitylistlength>0
306     \Nopic[Topics]{#1}
307     \ifnum\utilitylistlength>12
308       \startcolumns
309         \placelist[Topic]
310       \stopcolumns
311     \else
312       \placelist[Topic]
313     \fi
314   \fi}
315
316\unexpanded\def\Subjects%
317  {\placelist[Subject]}
318
319%D Last we define the overlays. Look at the way colors are linked into the macros.
320
321\setupMPvariables
322  [triangle]
323  [width=1cm,
324   rotation=0,
325   color=black]
326
327\startuniqueMPgraphic{triangle}{width,rotation,color}
328    fill triangle xsized \MPvar{width} rotated \MPvar{rotation} withcolor \MPvar{color} ;
329\stopuniqueMPgraphic
330
331\unexpanded\def\Triangle#1#2#3%
332  {\uniqueMPgraphic{triangle}{rotation=#1,width=#2,c:color=#3}}
333
334% \startuseMPgraphic{title}
335%     path p ; numeric sx, sy, cc ;
336%     for i=1 upto 250 :
337%         sx := uniformdeviate 30 ;
338%         sy := uniformdeviate 30 ;
339%         cc := round(uniformdeviate 2) ;
340%         if round(uniformdeviate 1) = 0 :
341%             p := unitsquare xscaled sx yscaled sy ;
342%         else :
343%             p := unittriangle scaled sx rotated (round(uniformdeviate 3) * 90) ;
344%         fi ;
345%         p := p shifted (uniformdeviate OverlayWidth,uniformdeviate OverlayHeight) ;
346%         fill p
347%             withcolor
348%                 if     cc = 0 : "GotoColor"
349%                 elseif cc = 1 : "ExitColor"
350%                 elseif cc = 2 : "StepColor" fi ;
351%     endfor ;
352% \stopuseMPgraphic
353
354\startuseMPgraphic{title}
355    path p ; numeric sx, sy, cc ;
356    fill Page withcolor "StepColor" ;
357    for i=1 upto 1000 :
358        sx := 50 + uniformdeviate 50 ;
359        sy := 50 + uniformdeviate 50 ;
360        cc := round(uniformdeviate 2) ;
361        if round(uniformdeviate 1) = 0 :
362            p := unitsquare xscaled sx yscaled sy ;
363        else :
364            p := unittriangle scaled sx rotated (round(uniformdeviate 3) * 90) ;
365        fi ;
366        p := p shifted (uniformdeviate OverlayWidth,uniformdeviate OverlayHeight) ;
367        fill p
368            withcolor
369                if     cc = 0 : "GotoColor"
370                elseif cc = 1 : "ExitColor"
371                elseif cc = 2 : "StepColor" fi ;
372        draw p
373            withpen pencircle scaled 1/2
374            withcolor white ;
375    endfor ;
376\stopuseMPgraphic
377
378\stopmodule
379
380\continueifinputfile{s-present-colorful.mkiv}
381
382\usemodule[present-common]
383
384\inputpresentationfile{examples/present-colorful-001.tex}
385