s-present-organic.mkiv /size: 10 Kb    last modification: 2021-10-28 13:51
1%D \module
2%D   [      file=s-present-organic, % s-pre-19,
3%D        version=2000.07.31,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Presentation Environment Organic,
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\startmodule[present-organic]
15
16%D This style is made in the process or writing the \METAFUN\ manual. It exploits a
17%D few tricks, like graphics calculated using positional information. It also uses
18%D the (at that moment) new menu list placement alternative. If you forget about the
19%D definition of the button shapes, which is complicated in any system, this style
20%D is not even that hard to follow. Watch how the left side of the buttons follow
21%D the right side of the text graphic.
22%D
23%D While playing bit with this style, the random alternative made me think of those
24%D organic building with non equal windows (we have a few in The Netherlands), so I
25%D decided to label this style as \type {pre-organic}.
26%D
27%D At the end of this file, there is a small test file, so when you process this
28%D file with \TEXEXEC\ and the options \type {--mode=demo} and \type {--pdf}, you
29%D will get a demo document.
30%D
31%D We use one of the standard screen \quote {paper} sizes, and map it onto the same
32%D size, so that we get a nicely cropped page.
33
34\setuppapersize
35  [S6][S6]
36
37%D Like in the \METAFUN\ manual, we use the Palatino as main bodyfont. This font is
38%D quite readable on even low resolution screens, although I admit that this style
39%D is developed using an $1400\times1050$ pixel LCD screen, so I may be biased.
40
41\setupbodyfont[pagella]
42
43%D The layout specification sets up a text area and a right edge area where the
44%D menus will go. Watch the rather large edge distance. By setting the header and
45%D footer dimensions to zero, we automatically get rid of page body ornaments, like
46%D the pagenumber.
47
48\setuplayout
49  [topspace=48pt,
50   backspace=48pt,
51   cutspace=12pt,
52   width=400pt,
53   margin=0cm,
54   rightedge=88pt,
55   rightedgedistance=48pt,
56   header=0cm,
57   footer=0cm,
58   height=middle]
59
60%D We use a moderate, about a line height, interparagraph white space.
61
62\setupwhitespace
63  [big]
64
65%D Of course we use colors, since on computer displays they come for free.
66
67\definecolor [red]              [r=.75]
68\definecolor [yellow]           [r=.75,g=.75]
69\definecolor [gray]             [s=.50]
70\definecolor [white]            [s=.85]
71
72\definecolor [PageColor]        [yellow]
73\definecolor [TextColor]        [white]
74\definecolor [OrnamentColor]    [red]
75\definecolor [InteractionColor] [red]
76\definecolor [ContrastColor]    [gray]
77
78%D This is an interactive document, so we enable interaction. In this style, we
79%D disable the viewer's \quote {highlight a hyperlink when it's clicked on} feature.
80%D We will use a menu, so we enable menus. Later we will see the contract color
81%D |<|hyperlinks gets that color when we are already on the location|>| in action.
82
83\setupinteraction
84  [state=start,
85   click=off,
86   color=InteractionColor,
87   contrastcolor=ContrastColor,
88   menu=on]
89
90%D The menu itself is set up as follows. Because we will calculate menubuttons based
91%D on their position on the page, we have to keep track of the positions. Therefore,
92%D we set the \type {position} variable to \type {yes}.
93
94\setupinteractionmenu
95  [right]
96  [frame=off,
97   position=yes,
98   align=middle,
99   topoffset=.75cm,    % watch out, these are negative in mkii
100   bottomoffset=.75cm, % watch out, these are negative in mkii
101   color=gray,
102   contrastcolor=gray,
103   style=bold,
104   before=,
105   after=]
106
107%D The menu content is rather sober: a list of topics (later we will define the
108%D command that generates topic entries), and a close button.
109
110\startinteractionmenu[right]
111    \placelist[Topic][alternative=right]
112    \vfill
113    \but [CloseDocument] close \\
114\stopinteractionmenu
115
116%D We have now arived at the more interesting part of the style definition: the
117%D graphic that goes in the page background. Because this graphic will change, we
118%D define a usable \METAPOST\ graphic. Page backgrounds are recalculated each page,
119%D opposite to the other backgrounds that are calculated when a new background is
120%D defined, or when repetitive calculation is turned on.
121
122\setupbackgrounds
123  [page]
124  [background=page]
125
126\defineoverlay
127  [page]
128  [\useMPgraphic{page}]
129
130\setupMPvariables
131  [page]
132  [alternative=3]
133
134\startuseMPgraphic{page}
135
136    \includeMPgraphic{rightsuperbutton}
137
138    StartPage ;
139
140        path p, q ; pickup pencircle scaled 3pt ;
141
142        p := Field[Text][Text] enlarged 36pt superellipsed .90 ;
143
144        fill Page withcolor \MPcolor{PageColor} ;
145        fill p    withcolor \MPcolor{TextColor} ;
146        draw p    withcolor \MPcolor{OrnamentColor} ;
147
148        p := Field[Text][Text] enlarged 48pt superellipsed .90 ;
149
150        def right_menu_button (expr nn, rr, pp, xx, yy, ww, hh, dd) =
151            if (pp>0) and (rr>0) :
152                q := rightsuperbutton(p,xx,yy,RightEdgeWidth,hh) ;
153                fill q withcolor \MPcolor{TextColor} ;
154                draw q withcolor if rr=2 : \MPcolor{ContrastColor}
155                                    else : \MPcolor{InteractionColor} fi ;
156            fi ;
157        enddef ;
158
159        \MPmenubuttons{right}
160
161    StopPage ;
162\stopuseMPgraphic
163
164\startuseMPgraphic{page}
165
166    \includeMPgraphic{rightsuperbutton}
167
168    StartPage ;
169
170        numeric alternative, seed, superness, squeezeness, randomness ;
171        path p, q ; transform t ;
172
173        alternative := \MPvar{alternative} ;
174        seed        := uniformdeviate 100 ;
175
176        if alternative > 10 :
177            superness   := .85  + ((\realfolio-1)/max(\lastpage,1)) * .15 ;
178            squeezeness := 12pt - ((\realfolio-1)/max(\lastpage,1)) * 10pt ;
179        else :
180            superness   := .90 ;
181            squeezeness := 12pt ;
182        fi ;
183
184        randomness := squeezeness ;
185
186        alternative := alternative mod 10 ;
187
188        t := identity if alternative=3: shifted (9pt,-9pt) fi ;
189
190        % first we draw the shape that surrounds the text
191
192        randomseed := seed ;
193
194        p := Field[Text][Text] enlarged if
195            alternative = 1 : 36pt superellipsed superness   elseif
196            alternative = 2 : 36pt squeezed      squeezeness elseif
197            alternative = 3 : 36pt randomized    randomness  else
198                            : 36pt                           fi ;
199
200        pickup pencircle scaled 3pt ;
201
202        fill Page withcolor \MPcolor{PageColor} ;
203        fill p    withcolor \MPcolor{TextColor} ;
204        draw p    withcolor \MPcolor{OrnamentColor} ;
205
206        % we set p to the wider shape from which we will chip off pieces
207
208        randomseed := seed ;
209
210        p := ( Field[Text][Text] enlarged if
211            alternative = 1 : 48pt superellipsed superness   elseif
212            alternative = 2 : 48pt squeezed      squeezeness elseif
213            alternative = 3 : 36pt randomized    randomness  else
214                            : 48pt                           fi ) transformed t ;
215
216        % calls to *_menu_button are generated automatically ...
217
218        vardef right_menu_button (expr nn, rr, pp, xx, yy, ww, hh, dd) =
219            save q ; path q ;
220            if (pp>0) and (rr>0) :
221                q := rightsuperbutton(p,xx,yy,RightEdgeWidth,hh) ; % \MPw{menu:right:\realfolio}
222                fill q withcolor \MPcolor{TextColor} ;
223                draw q withcolor if rr=2 : \MPcolor{ContrastColor}
224                                    else : \MPcolor{InteractionColor} fi ;
225            fi ;
226        enddef ;
227
228        % ... and inserted when the graphic data is flushed here ...
229
230        \MPmenubuttons{right}
231
232  StopPage ;
233\stopuseMPgraphic
234
235\startuseMPgraphic{rightsuperbutton}
236
237    vardef rightsuperbutton (expr pat, xpos, ypos, wid, hei) =
238
239        save p, ptop, pbot, t, b, edge, shift, width, height ;
240        path p, ptop, pbot ; pair t, b ; numeric edge, shift, width, height ;
241
242        edge  := xpos + wid ; shift := ypos + hei ;
243
244        p := rightpath pat ;
245
246        ptop := ((-infinity,shift)--(edge,shift)) ;
247        pbot := ((-infinity,shift-hei)--(edge,shift-hei)) ;
248
249        t := p intersection_point ptop ;
250        b := p intersection_point pbot ;
251
252        p := subpath(0,xpart (p intersectiontimes ptop)) of p ;
253        p := subpath(xpart (p intersectiontimes pbot),length(p)) of p ;
254
255        (p --               t -- point 1 of ptop &
256              point 1 of ptop -- point 1 of pbot &
257              point 1 of pbot -- b
258           -- cycle)
259
260    enddef ;
261
262\stopuseMPgraphic
263
264%D Topics are identified with \type {\Topic}, which is an instance of chapter
265%D headings. The number is made invisible. Since it still is a numbered section
266%D header, \CONTEXT\ will write the header to the table of contents.
267
268\definehead
269  [Topic]
270  [chapter]
271
272\setuphead
273  [Topic]
274  [number=no]
275
276%D We will use a bold font in the table of contents. We also force a complete
277%D list.
278
279\setuplist
280  [Topic]
281  [criterium=all,
282   style=bold,
283   before=,
284   after=]
285
286%D The \type {\TitlePage} macro looks horrible, because we want to keep the
287%D interface simple: a list of small sentences, separated by \type {\\}.
288
289\unexpanded\def\StartTitlePage
290  {\startstandardmakeup
291     \switchtobodyfont[big]
292     \enforced\protected\def\\{\vfill\bfb\enforced\let\\\par}%
293     \bfd\setupinterlinespace\gray
294     \vskip.5cm\relax}
295
296\unexpanded\def\StopTitlePage
297  {\\ % the \\ is really needed
298   \vskip.5cm\relax
299   \stopstandardmakeup}
300
301\unexpanded\def\TitlePage#1%
302  {\StartTitlePage#1\StopTitlePage}
303
304%D A couple of goodies:
305
306\unexpanded\def\Subject   {\Topic}
307\unexpanded\def\Topics  #1{}
308\unexpanded\def\Subjects  {}
309
310\startsetups document:start
311    \StartTitlePage
312        \documentvariable{title}
313        \doifsomething {\documentvariable{subtitle}} {
314            \\
315            \documentvariable{subtitle}
316        }
317        \doifsomething {\documentvariable{location}} {
318            \\
319            \documentvariable{location}
320        }
321    \StopTitlePage
322\stopsetups
323
324\startsetups document:stop
325    %
326\stopsetups
327
328\stopmodule
329
330\continueifinputfile{s-present-organic.mkiv}
331
332\usemodule[present-common]
333
334\inputpresentationfile{examples/present-organic-001.tex}
335
336