mp-page.mpiv /size: 19 Kb    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=mp-page.mpiv,
3
%D version=1999.03.10,
4
%D title=\CONTEXT\ \METAPOST\ graphics,
5
%D subtitle=page enhancements,
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 module is rather preliminary and subjected to changes.
15 16
if
known
context_page
:
endinput
;
fi
;
17 18
boolean
context_page
;
context_page
:
=
true
;
19 20
% def LoadPageState =
21
% % now always set
22
% enddef ;
23
%
24
% if unknown PageStateAvailable :
25
% boolean PageStateAvailable ;
26
% PageStateAvailable := false ;
27
% fi ;
28
%
29
% if unknown OnRightPage :
30
% boolean OnRightPage ;
31
% OnRightPage := true ;
32
% fi ;
33
%
34
% if unknown OnOddPage :
35
% boolean OnOddPage ;
36
% OnOddPage := true ;
37
% fi ;
38
%
39
% if unknown InPageBody :
40
% boolean InPageBody ;
41
% InPageBody := false ;
42
% fi ;
43
%
44
% string CurrentLayout ;
45
%
46
% CurrentLayout := "default" ;
47
%
48
% PageNumber := 0 ;
49
% PaperHeight := 845.04684pt ;
50
% PaperWidth := 597.50787pt ;
51
% PrintPaperHeight := 845.04684pt ;
52
% PrintPaperWidth := 597.50787pt ;
53
% TopSpace := 71.12546pt ;
54
% BottomSpace := 0.0pt ;
55
% BackSpace := 71.13275pt ;
56
% CutSpace := 0.0pt ;
57
% MakeupHeight := 711.3191pt ;
58
% MakeupWidth := 426.78743pt ;
59
% TopHeight := 0.0pt ;
60
% TopDistance := 0.0pt ;
61
% HeaderHeight := 56.90294pt ;
62
% HeaderDistance := 0.0pt ;
63
% TextHeight := 597.51323pt ;
64
% FooterDistance := 0.0pt ;
65
% FooterHeight := 56.90294pt ;
66
% BottomDistance := 0.0pt ;
67
% BottomHeight := 0.0pt ;
68
% LeftEdgeWidth := 0.0pt ;
69
% LeftEdgeDistance := 0.0pt ;
70
% LeftMarginWidth := 75.58197pt ;
71
% LeftMarginDistance := 11.99829pt ;
72
% TextWidth := 426.78743pt ;
73
% RightMarginDistance := 11.99829pt ;
74
% RightMarginWidth := 75.58197pt ;
75
% RightEdgeDistance := 0.0pt ;
76
% RightEdgeWidth := 0.0pt ;
77
%
78
% PageOffset := 0.0pt ;
79
% PageDepth := 0.0pt ;
80
%
81
% LayoutColumns := 0 ;
82
% LayoutColumnDistance:= 0.0pt ;
83
% LayoutColumnWidth := 0.0pt ;
84
%
85
% LeftEdge := -4 ; Top := -40 ;
86
% LeftEdgeSeparator := -3 ; TopSeparator := -30 ;
87
% LeftMargin := -2 ; Header := -20 ;
88
% LeftMarginSeparator := -1 ; HeaderSeparator := -10 ;
89
% Text := 0 ; Text := 0 ;
90
% RightMarginSeparator := +1 ; FooterSeparator := +10 ;
91
% RightMargin := +2 ; Footer := +20 ;
92
% RightEdgeSeparator := +3 ; BottomSeparator := +30 ;
93
% RightEdge := +4 ; Bottom := +40 ;
94
%
95
% Margin := LeftMargin ; % obsolete
96
% Edge := LeftEdge ; % obsolete
97
% InnerMargin := RightMargin ; % obsolete
98
% InnerEdge := RightEdge ; % obsolete
99
% OuterMargin := LeftMargin ; % obsolete
100
% OuterEdge := LeftEdge ; % obsolete
101
%
102
% InnerMarginWidth := 0pt ;
103
% OuterMarginWidth := 0pt ;
104
% InnerMarginDistance := 0pt ;
105
% OuterMarginDistance := 0pt ;
106
%
107
% InnerEdgeWidth := 0pt ;
108
% OuterEdgeWidth := 0pt ;
109
% InnerEdgeDistance := 0pt ;
110
% OuterEdgeDistance := 0pt ;
111
%
112
% % path Area[][] ;
113
% % pair Location[][] ;
114
% % path Field[][] ;
115
%
116
% % numeric Hstep[] ;
117
% % numeric Hsize[] ;
118
% % numeric Vstep[] ;
119
% % numeric Vsize[] ;
120
%
121
% path Page ;
122
%
123
% numeric HorPos ;
124
% numeric VerPos ;
125
%
126
% % for VerPos=Top step 10 until Bottom:
127
% % for HorPos=LeftEdge step 1 until RightEdge:
128
% % Area[HorPos][VerPos] := origin--cycle ;
129
% % Area[VerPos][HorPos] := Area[HorPos][VerPos] ;
130
% % Location[HorPos][VerPos] := origin ;
131
% % Location[VerPos][HorPos] := Location[HorPos][VerPos] ;
132
% % Field[HorPos][VerPos] := origin--cycle ;
133
% % Field[VerPos][HorPos] := Field[HorPos][VerPos] ;
134
% % endfor ;
135
% % endfor ;
136
%
137
% % def LoadPageState =
138
% % scantokens "input mp-state.tmp" ;
139
% % enddef ;
140
%
141
% numeric mfun_temp ;
142
%
143
% def SwapPageState =
144
% if not OnRightPage :
145
% BackSpace := PaperWidth-MakeupWidth-BackSpace ;
146
% CutSpace := PaperWidth-MakeupWidth-CutSpace ;
147
% mfun_temp := LeftMarginWidth ;
148
% LeftMarginWidth := RightMarginWidth ;
149
% RightMarginWidth := mfun_temp ;
150
% mfun_temp := LeftMarginDistance ;
151
% LeftMarginDistance := RightMarginDistance ;
152
% RightMarginDistance := mfun_temp ;
153
% mfun_temp := LeftEdgeWidth ;
154
% LeftEdgeWidth := RightEdgeWidth ;
155
% RightEdgeWidth := mfun_temp ;
156
% mfun_temp := LeftEdgeDistance ;
157
% LeftEdgeDistance := RightEdgeDistance ;
158
% RightEdgeDistance := mfun_temp ;
159
%
160
% % these are now available as ..Width and ..Distance
161
%
162
% Margin := LeftMargin ;
163
% Edge := LeftEdge ;
164
% InnerMargin := RightMargin ;
165
% InnerEdge := RightEdge ;
166
% OuterMargin := LeftMargin ;
167
% OuterEdge := LeftEdge ;
168
% else :
169
% Margin := RightMargin ;
170
% Edge := RightEdge ;
171
% InnerMargin := LeftMargin ;
172
% InnerEdge := LeftEdge ;
173
% OuterMargin := RightMargin ;
174
% OuterEdge := RightEdge ;
175
% fi ;
176
% enddef ;
177 178
% the new way:
179 180
def
LoadPageState
=
enddef
;
% now always set
181
def
SwapPageState
=
enddef
;
% dynamic
182 183
% if unknown PageStateAvailable :
184
% boolean PageStateAvailable ;
185
% PageStateAvailable := false ;
186
% fi ;
187 188
% Next we implement the the page area model. First some constants.
189 190
LeftEdge
:
=
-4
;
Top
:
=
-40
;
191
LeftEdgeSeparator
:
=
-3
;
TopSeparator
:
=
-30
;
192
LeftMargin
:
=
-2
;
Header
:
=
-20
;
193
LeftMarginSeparator
:
=
-1
;
HeaderSeparator
:
=
-10
;
194
Text
:
=
0
;
Text
:
=
0
;
195
RightMarginSeparator
:
=
+1
;
FooterSeparator
:
=
+10
;
196
RightMargin
:
=
+2
;
Footer
:
=
+20
;
197
RightEdgeSeparator
:
=
+3
;
BottomSeparator
:
=
+30
;
198
RightEdge
:
=
+4
;
Bottom
:
=
+40
;
199 200
% Margin := LeftMargin ; % obsolete
201
% Edge := LeftEdge ; % obsolete
202
% InnerMargin := RightMargin ; % obsolete
203
% InnerEdge := RightEdge ; % obsolete
204
% OuterMargin := LeftMargin ; % obsolete
205
% OuterEdge := LeftEdge ; % obsolete
206 207
numeric
HorPos
;
HorPos
:
=
0
;
208
numeric
VerPos
;
VerPos
:
=
0
;
209 210
% We used to initialize these variables each (sub)run but at some point MP
211
% became too slow for this. See later.
212 213
% path Area[][] ;
214
% pair Location[][] ;
215
% path Field[][] ;
216
%
217
% numeric Hstep[] ;
218
% numeric Hsize[] ;
219
% numeric Vstep[] ;
220
% numeric Vsize[] ;
221
%
222
% for VerPos=Top step 10 until Bottom:
223
% for HorPos=LeftEdge step 1 until RightEdge:
224
% Area[HorPos][VerPos] := origin--cycle ;
225
% Area[VerPos][HorPos] := Area[HorPos][VerPos] ;
226
% Location[HorPos][VerPos] := origin ;
227
% Location[VerPos][HorPos] := Location[HorPos][VerPos] ;
228
% Field[HorPos][VerPos] := origin--cycle ;
229
% Field[VerPos][HorPos] := Field[HorPos][VerPos] ;
230
% endfor ;
231
% endfor ;
232
%
233
%
234
% def SetPageAreas =
235
%
236
% numeric Vsize[], Hsize[], Vstep[], Hstep[] ;
237
%
238
% Vsize[Top] = TopHeight ;
239
% Vsize[TopSeparator] = TopDistance ;
240
% Vsize[Header] = HeaderHeight ;
241
% Vsize[HeaderSeparator] = HeaderDistance ;
242
% Vsize[Text] = TextHeight ;
243
% Vsize[FooterSeparator] = FooterDistance ;
244
% Vsize[Footer] = FooterHeight ;
245
% Vsize[BottomSeparator] = BottomDistance ;
246
% Vsize[Bottom] = BottomHeight ;
247
%
248
% Vstep[Top] = Vstep[TopSeparator] +Vsize[TopSeparator] ;
249
% Vstep[TopSeparator] = PaperHeight-TopSpace ;
250
% Vstep[Header] = Vstep[TopSeparator] -Vsize[Header] ;
251
% Vstep[HeaderSeparator] = Vstep[Header] -Vsize[HeaderSeparator] ;
252
% Vstep[Text] = Vstep[HeaderSeparator]-Vsize[Text] ;
253
% Vstep[FooterSeparator] = Vstep[Text] -Vsize[FooterSeparator] ;
254
% Vstep[Footer] = Vstep[FooterSeparator]-Vsize[Footer] ;
255
% Vstep[BottomSeparator] = Vstep[Footer] -Vsize[BottomSeparator] ;
256
% Vstep[Bottom] = Vstep[BottomSeparator]-Vsize[Bottom] ;
257
%
258
% Hsize[LeftEdge] = LeftEdgeWidth ;
259
% Hsize[LeftEdgeSeparator] = LeftEdgeDistance ;
260
% Hsize[LeftMargin] = LeftMarginWidth ;
261
% Hsize[LeftMarginSeparator] = LeftMarginDistance ;
262
% Hsize[Text] = MakeupWidth ;
263
% Hsize[RightMarginSeparator] = RightMarginDistance ;
264
% Hsize[RightMargin] = RightMarginWidth ;
265
% Hsize[RightEdgeSeparator] = RightEdgeDistance ;
266
% Hsize[RightEdge] = RightEdgeWidth ;
267
%
268
% Hstep[LeftEdge] = Hstep[LeftEdgeSeparator] -Hsize[LeftEdge] ;
269
% Hstep[LeftEdgeSeparator] = Hstep[LeftMargin] -Hsize[LeftEdgeSeparator] ;
270
% Hstep[LeftMargin] = Hstep[LeftMarginSeparator] -Hsize[LeftMargin] ;
271
% Hstep[LeftMarginSeparator] = Hstep[Text] -Hsize[LeftMarginSeparator] ;
272
% Hstep[Text] = BackSpace ;
273
% Hstep[RightMarginSeparator] = Hstep[Text] +Hsize[Text] ;
274
% Hstep[RightMargin] = Hstep[RightMarginSeparator]+Hsize[RightMarginSeparator] ;
275
% Hstep[RightEdgeSeparator] = Hstep[RightMargin] +Hsize[RightMargin] ;
276
% Hstep[RightEdge] = Hstep[RightEdgeSeparator] +Hsize[RightEdgeSeparator] ;
277
%
278
% for VerPos=Top step 10 until Bottom:
279
% for HorPos=LeftEdge step 1 until RightEdge:
280
% Area[HorPos][VerPos] := unitsquare xscaled Hsize[HorPos] yscaled Vsize[VerPos] ;
281
% Area[VerPos][HorPos] := Area[HorPos][VerPos] ;
282
% Location[HorPos][VerPos] := (Hstep[HorPos],Vstep[VerPos]) ;
283
% Location[VerPos][HorPos] := Location[HorPos][VerPos] ;
284
% Field[HorPos][VerPos] := Area[HorPos][VerPos] shifted Location[HorPos][VerPos] ;
285
% Field[VerPos][HorPos] := Field[HorPos][VerPos] ;
286
% endfor ;
287
% endfor ;
288
%
289
% Page := unitsquare xscaled PaperWidth yscaled PaperHeight ;
290
%
291
% enddef ;
292
%
293
% def BoundPageAreas =
294
% % pickup pencircle scaled 0pt ;
295
% bboxmargin := 0 ; setbounds currentpicture to Page ;
296
% enddef ;
297
%
298
% def StartPage =
299
% begingroup ;
300
% if PageStateAvailable :
301
% LoadPageState ;
302
% SwapPageState ;
303
% fi ;
304
% SetPageAreas ;
305
% BoundPageAreas ;
306
% enddef ;
307
%
308
% def StopPage =
309
% BoundPageAreas ;
310
% endgroup ;
311
% enddef ;
312 313
% Because metapost > 1.50 has dynamic memory management and is less
314
% efficient than before we now delay calculations ... (on a document
315
% with 150 pages the time spent in mp was close to 5 seconds which was
316
% only due to initialising the page related areas, something that was
317
% hardly noticeable before. At least now we're back to half a second
318
% for such a case.
319 320
def
SetPageVsize
=
321
numeric
Vsize
[
]
;
322
Vsize
[
Top
]
=
TopHeight
;
323
Vsize
[
TopSeparator
]
=
TopDistance
;
324
Vsize
[
Header
]
=
HeaderHeight
;
325
Vsize
[
HeaderSeparator
]
=
HeaderDistance
;
326
Vsize
[
Text
]
=
TextHeight
;
327
Vsize
[
FooterSeparator
]
=
FooterDistance
;
328
Vsize
[
Footer
]
=
FooterHeight
;
329
Vsize
[
BottomSeparator
]
=
BottomDistance
;
330
Vsize
[
Bottom
]
=
BottomHeight
;
331
enddef
;
332 333
def
SetPageHsize
=
334
numeric
Hsize
[
]
;
335
Hsize
[
LeftEdge
]
=
LeftEdgeWidth
;
336
Hsize
[
LeftEdgeSeparator
]
=
LeftEdgeDistance
;
337
Hsize
[
LeftMargin
]
=
LeftMarginWidth
;
338
Hsize
[
LeftMarginSeparator
]
=
LeftMarginDistance
;
339
Hsize
[
Text
]
=
MakeupWidth
;
340
Hsize
[
RightMarginSeparator
]
=
RightMarginDistance
;
341
Hsize
[
RightMargin
]
=
RightMarginWidth
;
342
Hsize
[
RightEdgeSeparator
]
=
RightEdgeDistance
;
343
Hsize
[
RightEdge
]
=
RightEdgeWidth
;
344
enddef
;
345 346
def
SetPageVstep
=
347
numeric
Vstep
[
]
;
348
Vstep
[
Top
]
=
Vstep
[
TopSeparator
]
+
Vsize
[
TopSeparator
]
;
349
Vstep
[
TopSeparator
]
=
PaperHeight
-
TopSpace
;
350
Vstep
[
Header
]
=
Vstep
[
TopSeparator
]
-
Vsize
[
Header
]
;
351
Vstep
[
HeaderSeparator
]
=
Vstep
[
Header
]
-
Vsize
[
HeaderSeparator
]
;
352
Vstep
[
Text
]
=
Vstep
[
HeaderSeparator
]
-
Vsize
[
Text
]
;
353
Vstep
[
FooterSeparator
]
=
Vstep
[
Text
]
-
Vsize
[
FooterSeparator
]
;
354
Vstep
[
Footer
]
=
Vstep
[
FooterSeparator
]
-
Vsize
[
Footer
]
;
355
Vstep
[
BottomSeparator
]
=
Vstep
[
Footer
]
-
Vsize
[
BottomSeparator
]
;
356
Vstep
[
Bottom
]
=
Vstep
[
BottomSeparator
]
-
Vsize
[
Bottom
]
;
357
enddef
;
358 359
def
SetPageHstep
=
360
numeric
Hstep
[
]
;
361
Hstep
[
LeftEdge
]
=
Hstep
[
LeftEdgeSeparator
]
-
Hsize
[
LeftEdge
]
;
362
Hstep
[
LeftEdgeSeparator
]
=
Hstep
[
LeftMargin
]
-
Hsize
[
LeftEdgeSeparator
]
;
363
Hstep
[
LeftMargin
]
=
Hstep
[
LeftMarginSeparator
]
-
Hsize
[
LeftMargin
]
;
364
Hstep
[
LeftMarginSeparator
]
=
Hstep
[
Text
]
-
Hsize
[
LeftMarginSeparator
]
;
365
Hstep
[
Text
]
=
BackSpace
;
366
Hstep
[
RightMarginSeparator
]
=
Hstep
[
Text
]
+
Hsize
[
Text
]
;
367
Hstep
[
RightMargin
]
=
Hstep
[
RightMarginSeparator
]
+
Hsize
[
RightMarginSeparator
]
;
368
Hstep
[
RightEdgeSeparator
]
=
Hstep
[
RightMargin
]
+
Hsize
[
RightMargin
]
;
369
Hstep
[
RightEdge
]
=
Hstep
[
RightEdgeSeparator
]
+
Hsize
[
RightEdgeSeparator
]
;
370
enddef
;
371 372
def
SetPageArea
=
373
path
Area
[
]
[
]
;
374
for
VerPos
=
Top
step
10
until
Bottom
:
375
for
HorPos
=
LeftEdge
step
1
until
RightEdge
:
376
Area
[
HorPos
]
[
VerPos
]
:
=
unitsquare
xscaled
Hsize
[
HorPos
]
yscaled
Vsize
[
VerPos
]
;
377
Area
[
VerPos
]
[
HorPos
]
:
=
Area
[
HorPos
]
[
VerPos
]
;
378
endfor
;
379
endfor
;
380
enddef
;
381 382
def
SetPageLocation
=
383
pair
Location
[
]
[
]
;
384
for
VerPos
=
Top
step
10
until
Bottom
:
385
for
HorPos
=
LeftEdge
step
1
until
RightEdge
:
386
Location
[
HorPos
]
[
VerPos
]
:
=
(
Hstep
[
HorPos
]
,
Vstep
[
VerPos
]
)
;
387
Location
[
VerPos
]
[
HorPos
]
:
=
Location
[
HorPos
]
[
VerPos
]
;
388
endfor
;
389
endfor
;
390
enddef
;
391 392
def
SetPageField
=
393
path
Field
[
]
[
]
;
394
for
VerPos
=
Top
step
10
until
Bottom
:
395
for
HorPos
=
LeftEdge
step
1
until
RightEdge
:
396
Field
[
HorPos
]
[
VerPos
]
:
=
unitsquare
xscaled
Hsize
[
HorPos
]
yscaled
Vsize
[
VerPos
]
shifted
(
Hstep
[
HorPos
]
,
Vstep
[
VerPos
]
)
;
397
Field
[
VerPos
]
[
HorPos
]
:
=
Field
[
HorPos
]
[
VerPos
]
;
398
endfor
;
399
endfor
;
400
enddef
;
401 402
def
mfun_page_Area
=
hide
(
SetPageArea
;
)
Area
enddef
;
403
def
mfun_page_Location
=
hide
(
SetPageLocation
;
)
Location
enddef
;
404
def
mfun_page_Field
=
hide
(
SetPageField
;
)
Field
enddef
;
405
def
mfun_page_Vsize
=
hide
(
SetPageVsize
;
)
Vsize
enddef
;
406
def
mfun_page_Hsize
=
hide
(
SetPageHsize
;
)
Hsize
enddef
;
407
def
mfun_page_Vstep
=
hide
(
SetPageVstep
;
)
Vstep
enddef
;
408
def
mfun_page_Hstep
=
hide
(
SetPageHstep
;
)
Hstep
enddef
;
409 410
def
SetAreaVariables
=
411
let
Area
=
mfun_page_Area
;
412
let
Location
=
mfun_page_Location
;
413
let
Field
=
mfun_page_Field
;
414
let
Vsize
=
mfun_page_Vsize
;
415
let
Hsize
=
mfun_page_Hsize
;
416
let
Vstep
=
mfun_page_Vstep
;
417
let
Hstep
=
mfun_page_Hstep
;
418
enddef
;
419 420
% we should make Page no path .. from now on don't assume this .. for a while we keek it
421 422
vardef
FrontPageWidth
=
PaperWidth
enddef
;
423
vardef
BackPageWidth
=
PaperWidth
enddef
;
424
vardef
CoverWidth
=
2
*
PaperWidth
+
SpineWidth
enddef
;
425
vardef
CoverHeight
=
PaperHeight
enddef
;
426 427
vardef
FrontPageHeight
=
PaperHeight
enddef
;
428
vardef
BackPageHeight
=
PaperHeight
enddef
;
429
vardef
SpineHeight
=
PaperHeight
enddef
;
430 431
def
SetPagePage
=
path
Page
;
Page
:
=
unitsquare
xscaled
PaperWidth
yscaled
PaperHeight
;
enddef
;
432
def
SetPageCoverPage
=
path
CoverPage
;
CoverPage
:
=
unitsquare
xscaled
CoverWidth
yscaled
CoverHeight
;
enddef
;
433
def
SetPageSpine
=
path
Spine
;
Spine
:
=
unitsquare
xscaled
SpineWidth
yscaled
CoverHeight
shifted
(
BackPageWidth
,
0
)
;
enddef
;
434
def
SetPageBackPage
=
path
BackPage
;
BackPage
:
=
unitsquare
xscaled
BackPageWidth
yscaled
CoverHeight
;
enddef
;
435
def
SetPageFrontPage
=
path
FrontPage
;
FrontPage
:
=
unitsquare
xscaled
FrontPageWidth
yscaled
CoverHeight
shifted
(
BackPageWidth
+
SpineWidth
,
0
)
;
enddef
;
436 437
def
mfun_page_Page
=
hide
(
SetPagePage
;
)
Page
enddef
;
438
def
mfun_page_CoverPage
=
hide
(
SetPageCoverPage
;
)
CoverPage
enddef
;
439
def
mfun_page_Spine
=
hide
(
SetPageSpine
;
)
Spine
enddef
;
440
def
mfun_page_BackPage
=
hide
(
SetPageBackPage
;
)
BackPage
enddef
;
441
def
mfun_page_FrontPage
=
hide
(
SetPageFrontPage
;
)
FrontPage
enddef
;
442 443
def
SetPageVariables
=
444
SetAreaVariables
;
445
%
446
let
Page
=
mfun_page_Page
;
447
let
CoverPage
=
mfun_page_CoverPage
;
448
let
Spine
=
mfun_page_Spine
;
449
let
BackPage
=
mfun_page_BackPage
;
450
let
FrontPage
=
mfun_page_FrontPage
;
451
enddef
;
452 453
SetPageVariables
;
454 455
let
SetPageAreas
=
SetPageVariables
;
% compatiblity
456 457
def
BoundPageAreas
=
458
% pickup pencircle scaled 0pt ;
459
bboxmargin
:
=
0
;
setbounds
currentpicture
to
Page
;
460
enddef
;
461 462
def
StartPage
=
463
begingroup
;
464
% if PageStateAvailable :
465
% LoadPageState ;
466
% SwapPageState ;
467
% fi ;
468
SetPageVariables
;
469
BoundPageAreas
;
470
enddef
;
471 472
def
StopPage
=
473
BoundPageAreas
;
474
endgroup
;
475
enddef
;
476 477
% cover pages
478 479
def
BoundCoverAreas
=
480
% todo: add cropmarks
481
bboxmargin
:
=
0
;
setbounds
currentpicture
to
CoverPage
enlarged
PaperBleed
;
482
enddef
;
483 484
let
SetCoverAreas
=
SetPageVariables
;
% compatiblity
485 486
def
StartCover
=
487
begingroup
;
488
% if PageStateAvailable :
489
% LoadPageState ;
490
% fi ;
491
SetPageVariables
;
% was SetPageAreas ;
492
SetCoverAreas
;
493
BoundCoverAreas
;
494
enddef
;
495 496
def
StopCover
=
497
BoundCoverAreas
;
498
endgroup
;
499
enddef
;
500 501
% overlays:
502 503
def
OverlayBox
=
504
(
unitsquare
xyscaled
(
OverlayWidth
,
OverlayHeight
)
)
505
enddef
;
506 507
def
BoundToOverlayBox
=
508
setbounds
currentpicture
to
OverlayBox
;
509
enddef
;
510 511
% handy
512 513
def
innerenlarged
=
514
hide
(
LoadPageState
)
515
if
OnRightPage
:
leftenlarged
else
:
rightenlarged
fi
516
enddef
;
517 518
def
outerenlarged
=
519
hide
(
LoadPageState
)
520
if
OnRightPage
:
rightenlarged
else
:
leftenlarged
fi
521
enddef
;
522 523
% obsolete
524 525
def
llEnlarged
(
expr
p
,
d
)
=
(
llcorner
p
shifted
(
-
d
,
-
d
)
)
enddef
;
526
def
lrEnlarged
(
expr
p
,
d
)
=
(
lrcorner
p
shifted
(
+
d
,
-
d
)
)
enddef
;
527
def
urEnlarged
(
expr
p
,
d
)
=
(
urcorner
p
shifted
(
+
d
,
+
d
)
)
enddef
;
528
def
ulEnlarged
(
expr
p
,
d
)
=
(
ulcorner
p
shifted
(
-
d
,
+
d
)
)
enddef
;
529 530
def
Enlarged
(
expr
p
,
d
)
=
531
(
llEnlarged
(
p
,
d
)
--
532
lrEnlarged
(
p
,
d
)
--
533
urEnlarged
(
p
,
d
)
--
534
ulEnlarged
(
p
,
d
)
--
cycle
)
535
enddef
;
536 537
% for the moment we put these here:
538 539
string
RuleDirection
;
RuleDirection
:
=
"
"
;
540
string
RuleOption
;
RuleOption
:
=
"
"
;
541
numeric
RuleWidth
;
RuleWidth
:
=
0
;
542
numeric
RuleHeight
;
RuleHeight
:
=
0
;
543
numeric
RuleDepth
;
RuleDepth
:
=
0
;
544
numeric
RuleH
;
RuleH
:
=
0
;
545
numeric
RuleV
;
RuleV
:
=
0
;
546
numeric
RuleThickness
;
RuleThickness
:
=
0
;
547
numeric
RuleFactor
;
RuleFactor
:
=
0
;
548
numeric
RuleOffset
;
RuleOffset
:
=
0
;
549
def
RuleColor
=
(
.5
white
)
enddef
;
550 551
def
FakeWord
(
expr
RuleWidth
,
RuleHeight
,
RuleDepth
,
RuleThickness
)
(
text
RuleColor
)
=
552
fill
unitsquare
553
xscaled
RuleWidth
554
yscaled
(
RuleDepth
-
RuleThickness
/
2
)
555
withcolor
RuleColor
;
556
fill
unitsquare
557
xscaled
RuleWidth
558
yscaled
(
RuleHeight
-
RuleDepth
-
RuleThickness
/
2
)
559
shifted
(
0
,
RuleDepth
+
RuleThickness
)
560
withcolor
RuleColor
;
561
enddef
;
562 563
def
FakeRule
(
expr
RuleWidth
,
RuleHeight
,
RuleDepth
,
RuleThickness
)
(
text
RuleColor
)
=
564
fill
unitsquare
565
xscaled
RuleWidth
566
yscaled
RuleHeight
567
withcolor
RuleColor
;
568
enddef
;
569