s-present-wobbling.mkiv /size: 9668 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=s-prent-wobbling,
3
%D version=2010.04.28,
4
%D title=\CONTEXT\ Style File,
5
%D subtitle=Presentation Environment Wobbling,
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 a bit old stuyls and I should adapt it a bit but as it sort of works ok I'll
15
%D not do that now.
16 17
\startmodule
[
present
-
wobbling
]
18 19
%setuppapersize[S6][S6]
20
\setuppapersize
[
SM
][
SM
]
21 22
\setupinteraction
23
[
state
=
start
,
24
contrastcolor
=
white
,
25
color
=
white
,
26
click
=
no
]
27 28
\setuplayout
29
[
location
=
middle
,
30
topspace
=
6
0
pt
,
31
bottomspace
=
8
0
pt
,
32
backspace
=
8
0
pt
,
33
header
=
0
pt
,
34
footer
=
0
pt
,
35
width
=
middle
,
36
height
=
middle
]
37 38
\setupcolors
39
[
textcolor
=
white
]
40 41
\setupbodyfont
[
pagella
]
42 43
\definecolor
[
maincolor
]
[
blue
]
44
\definecolor
[
extracolor
][
green
]
45 46
% \definecolor[maincolor] [red]
47
% \definecolor[extracolor][blue]
48 49
\startMPdefinitions
50
picture
MySoFar
;
MySoFar
:
=
nullpicture
;
51
path
MyLastOne
;
MyLastOne
:
=
origin
--
cycle
;
52
path
MyLeftSteps
,
MyRightSteps
;
53
boolean
MyPageDone
;
MyPageDone
:
=
false
;
54 55
vardef
MySmallShape
(
expr
parent
)
=
56
path
p
;
p
:
=
boundingbox
parent
;
57
numeric
w
,
h
;
w
:
=
bbwidth
(
p
)
;
h
:
=
bbheight
(
p
)
;
58
urcorner
p
shifted
(
-
uniformdeviate
w
/
4
,
0
)
--
59
lrcorner
p
shifted
(
0
,
uniformdeviate
h
/
4
)
--
60
llcorner
p
shifted
(
uniformdeviate
w
/
4
,
0
)
--
61
ulcorner
p
shifted
(
0
,
-
uniformdeviate
h
/
4
)
--
cycle
62
enddef
;
63 64
vardef
MyShape
(
expr
parent
)
=
65
path
p
;
p
:
=
boundingbox
parent
;
66
if
MyPageDone
:
67
MyPageDone
:
=
false
;
68
urcorner
p
shifted
(
-
EmWidth
+
-
uniformdeviate
CutSpace
/
2
,
0
)
--
69
lrcorner
p
shifted
(
0
,
EmWidth
+
uniformdeviate
BottomSpace
/
2
)
--
70
llcorner
p
shifted
(
EmWidth
+
uniformdeviate
BackSpace
/
2
,
0
)
--
71
ulcorner
p
shifted
(
0
,
-
EmWidth
+
-
uniformdeviate
TopSpace
/
2
)
--
cycle
72
else
:
73
MyPageDone
:
=
true
;
74
urcorner
p
shifted
(
0
,
-
EmWidth
+
-
uniformdeviate
TopSpace
/
2
)
--
75
lrcorner
p
shifted
(
-
EmWidth
+
-
uniformdeviate
CutSpace
/
2
,
0
)
--
76
llcorner
p
shifted
(
0
,
EmWidth
+
uniformdeviate
BottomSpace
/
2
)
--
77
ulcorner
p
shifted
(
EmWidth
+
uniformdeviate
BackSpace
/
2
,
0
)
--
cycle
78
fi
79
enddef
;
80 81
vardef
MyMakeOne
=
82
MyLastOne
:
=
MyShape
(
Page
)
;
83
enddef
;
84 85
vardef
MyAddOne
=
86
addto
MySoFar
also
image
(
fill
MyLastOne
withcolor
"
maincolor
"
withtransparency
(
1
,
.25
)
;
)
;
87
enddef
;
88 89
vardef
MyDrawOne
=
90
fill
MyLastOne
withcolor
black
;
91
fill
MyLastOne
withcolor
"
maincolor
"
withtransparency
(
1
,
.25
)
;
92
enddef
;
93 94
vardef
MyDrawPage
=
95
draw
MySoFar
;
96
enddef
;
97 98
vardef
MySetSteps
=
99
path
l
,
r
;
numeric
s
;
path
ll
[
]
,
rr
[
]
;
path
t
;
100
l
:
=
point
2
of
MyLastOne
--
point
3
of
MyLastOne
;
101
r
:
=
point
0
of
MyLastOne
--
point
1
of
MyLastOne
;
102
t
:
=
topboundary
Field
[
Text
]
[
Text
]
rightenlarged
TextWidth
leftenlarged
TextWidth
;
103
s
:
=
bbheight
(
Field
[
Text
]
[
Text
]
)
/
LineHeight
+
2
;
104
t
:
=
t
shifted
(
0
,
-
TopSkip
)
;
105
for
i
=
1
upto
s
:
106
ll
[
i
]
:
=
t
intersectionpoint
l
;
107
rr
[
i
]
:
=
t
intersectionpoint
r
;
108
t
:
=
t
shifted
(
0
,
-
LineHeight
)
;
109
endfor
;
110
MyLeftSteps
:
=
for
i
=
1
upto
s
:
ll
[
i
]
--
endfor
cycle
;
111
MyRightSteps
:
=
for
i
=
1
upto
s
:
rr
[
i
]
--
endfor
cycle
;
112
enddef
;
113 114
vardef
MyDrawText
(
expr
txt
)
=
115
pair
a
;
a
:
=
(
point
1
of
MyLastOne
)
-
(
point
2
of
MyLastOne
)
;
116
picture
p
;
p
:
=
txt
;
117
p
:
=
p
118
shifted
(
-
EmWidth
,
EmWidth
)
119
shifted
ulcorner
txt
120
shifted
point
1
of
MyLastOne
;
121
p
:
=
p
rotatedaround
(
lrcorner
p
,
radian
*
tan
(
ypart
a
/
xpart
a
)
)
;
122
setbounds
p
to
origin
--
cycle
;
123
draw
p
;
124
enddef
;
125 126
vardef
MyDrawTitle
(
expr
txt
)
=
127
% pair a ; a := (point 2 of MyLastOne) - (point 3 of MyLastOne) ;
128
pair
a
;
a
:
=
(
point
3
of
MyLastOne
)
-
(
point
4
of
MyLastOne
)
;
129
picture
p
;
130
if
bbheight
(
txt
)
>
bbwidth
(
txt
)
:
131
p
:
=
txt
ysized
(
0.8
*
TextHeight
)
;
132
else
:
133
p
:
=
txt
xsized
(
0.8
*
TextWidth
)
;
134
fi
;
135
numeric
d
;
d
:
=
arclength
(
point
2
of
MyLastOne
--
point
3
of
MyLastOne
)
-
bbheight
(
p
)
;
136
p
:
=
p
137
shifted
(
BackSpace
,
-
d
/
2
)
138
shifted
-
ulcorner
p
139
shifted
point
3
of
MyLastOne
;
140
% p := p rotatedaround(ulcorner p, - radian * tan(xpart a/ypart a)) ;
141
% p := p rotatedaround(ulcorner p, radian * tan(ypart a/xpart a)) ;
142
setbounds
p
to
origin
--
cycle
;
143
draw
p
;
144
enddef
;
145 146
vardef
MyDrawSteps
=
147
s
:
=
bbheight
(
Field
[
Text
]
[
Text
]
)
/
LineHeight
+
2
;
148
for
i
=
1
upto
s
:
149
draw
ll
[
i
]
withpen
pencircle
scaled
1
mm
;
150
draw
rr
[
i
]
withpen
pencircle
scaled
1
mm
;
151
draw
ll
[
i
]
--
rr
[
i
]
;
152
endfor
;
153
draw
Field
[
Text
]
[
Text
]
;
154
enddef
;
155 156
\stopMPdefinitions
157 158
\startuseMPgraphic
{
initialization
}
159
StartPage
;
160
MySoFar
:
=
image
(
fill
Page
enlarged
12
pt
withcolor
"
maincolor
"
withtransparency
(
1
,
.25
)
;
)
;
161
MyMakeOne
;
162
MySetSteps
;
163
StopPage
;
164
\stopuseMPgraphic
165 166
\appendtoks
167
\startnointerference
168
\useMPgraphic
{
initialization
}
169
\stopnointerference
170
\to
\everystarttext
171 172
\unexpanded
\def
\TitleCommand
#
1
%
173
{
\framed
174
[
frame
=
off
,
175
offset
=
overlay
,
176
align
=
flushleft
,
177
foregroundcolor
=
white
,
178
foregroundstyle
=
{
\tfd
}
,
179
bottom
=
\vskip
2
\lineheight
]
180
{
\setupinterlinespace
181
\setupwhitespace
[
halfline
]
%
182
%\showstruts
183
\begstrut
184
#
1
%
185
\endstrut
}}
186 187
\unexpanded
\def
\TopicCommand
#
1
%
188
{
\color
[
white
]
{
\tfb
#
1
}}
189 190
\startuseMPgraphic
{
page
}
191
StartPage
;
192
MyDrawPage
;
193
MyDrawOne
;
194
MySetSteps
;
195
if
RealPageNumber
=
=
1
:
196
MyDrawTitle
(
textext
(
"
\TitleCommand{\documentvariable{title}}
"
)
)
;
197
MyDrawText
(
textext
(
"
\TopicCommand{\documentvariable{topic}}
"
)
)
;
198
fi
;
199
%
200
% we have multiple runs when we have text
201
%
202
% MyDrawSteps ;
203
% MyMakeOne ;
204
% MySetSteps ;
205
StopPage
;
206
\stopuseMPgraphic
207 208
\appendtoks
209
\startnointerference
210
\startMPcode
211
MyAddOne
;
212
MyMakeOne
;
213
MySetSteps
;
214
\stopMPcode
215
\stopnointerference
216
\to
\everyshipout
217 218
\defineoverlay
[
page
][
\useMPgraphic
{
page
}
]
219 220
\startuseMPgraphic
{
symbol
}
221
path
p
;
p
:
=
MySmallShape
(
unitsquare
scaled
(
.6
*
LineHeight
)
)
;
222
fill
p
withcolor
white
;
223
fill
p
withcolor
"
extracolor
"
withtransparency
(
1
,
.25
)
;
224
\stopuseMPgraphic
225 226
\definesymbol
[
mysymbol
][
\struttedbox
{
\useMPgraphic
{
symbol
}
}
]
227 228
\setupitemgroup
229
[
itemize
]
[
1
]
230
[
symbol
=
mysymbol
]
231 232
\setupbackgrounds
233
[
page
]
234
[
background
=
page
]
235 236
\startluacode
237
local
texdimen
=
tex
.
dimen
238
function
document
.
SetParShape
(
)
239
local
leftpath
=
metapost
.
getclippath
{
mpx
=
"
metafun
"
,
data
=
"
clip currentpicture to MyLeftSteps ;
"
}
240
local
rightpath
=
metapost
.
getclippath
{
mpx
=
"
metafun
"
,
data
=
"
clip currentpicture to MyRightSteps ;
"
}
241
local
shape
=
{
}
242
for
i
=
1
,
#
leftpath
do
243
local
left
=
leftpath
[
i
]
.
x_coord
244
local
right
=
rightpath
[
i
]
.
x_coord
245
local
hsize
=
right
-
left
-
(
texdimen
.
backspace
+
texdimen
.
cutspace
)
*
number
.
dimenfactors
.
bp
246
shape
[
#
shape
+
1
]
=
string
.
format
(
"
%sbp %sbp
"
,
left
,
hsize
)
247
end
248
-- print(table.serialize(shape))
249
-- context.parshape(string.format("%s %s ",#shape,table.concat(shape," ")))
250
context
(
"
\\parshape %s %s
"
,
#
shape
,
table
.
concat
(
shape
,
"
"
)
)
251
end
252
\stopluacode
253 254
\nopenalties
\dontcomplain
255 256
\setupwhitespace
[
none
]
257 258
\startsetups
document
:
start
259
\bgroup
260
\let
\crlf\endgraf
% \par in a mp textext doesn't work well
261
\startstandardmakeup
262
% dummy page
263
\stopstandardmakeup
264
\egroup
265
\stopsetups
266 267
\unexpanded
\def
\StartText
#
1
#
2
% for old times sake
268
{
\startdocument
[
title
=
{
#
1
}
,
subtitle
=
{
#
2
}
]
}
269 270
\unexpanded
\def
\StopText
271
{
\stopdocument
272
\setupdocument
[
title
=
,
topic
=]
}
273 274
\unexpanded
\def
\StartItems
#
1
%
275
{
\setupdocument
[
topic
=
{
#
1
}
]
276
\startstandardmakeup
[
top
=
,
bottom
=
\vss
]
277
\startelement
[
items
][
title
=
{
#
1
}
]
%
278
\ctxlua{
document
.
SetParShape
(
)
}
279
\StartSteps
}
280 281
\unexpanded
\def
\StopItems
282
{
\StopSteps
283
\stopelement
284
\stopstandardmakeup
}
285 286
\unexpanded
\def
\StartItem
287
{
\dontleavehmode
288
\startelement
[
item
]
%
289
\llap
{
\symbol
[
mysymbol
]
\quad
}
% graphic
290
\ignorespaces
}
291 292
\unexpanded
\def
\StopItem
293
{
\removeunwantedspaces
294
\nobreak
295
\crlf
296
\stopelement
297
\crlf
298
\FlushStep
}
299 300
\unexpanded
\def
\ShapeParagraph
301
{
\ctxlua{
document
.
SetParShape
(
)
}
}
302 303
% no parshape yet
304 305
\unexpanded
\def
\StartParagraphs
#
1
%
306
{
\setupdocument
[
topic
=
{
#
1
}
]
307
\startstandardmakeup
[
top
=
,
bottom
=
\vss
]
308
%\ctxlua{document.SetParShape()}
309
\startelement
[
paragraphs
]
%
310
\StartSteps
}
311 312
\unexpanded
\def
\StopParagraphs
313
{
\StopSteps
314
\stopelement
315
\stopstandardmakeup
}
316 317
\unexpanded
\def
\StartParagraph
318
{
\startelement
[
paragraph
]
}
319 320
\unexpanded
\def
\StopParagraph
321
{
\par
322
\stopelement
323
\FlushStep
}
324 325
% experiment .. likely to change
326 327
\setelementexporttag
[
items
]
[
nature
][
display
]
328
\setelementexporttag
[
item
]
[
nature
][
mixed
]
329
\setelementexporttag
[
paragraphs
][
nature
][
display
]
330
\setelementexporttag
[
paragraph
]
[
nature
][
mixed
]
331 332
\stopmodule
333 334
\continueifinputfile
{
s
-
present
-
wobbling
.
mkiv
}
335 336
\usemodule
[
present
-
common
]
337 338
%inputpresentationfile{bachotex/2010/bachotex-2010-clash.tex}
339
\inputpresentationfile
{
bachotex
/
2
0
1
0
/
bachotex
-
2
0
1
0
-
move
.
tex
}
340