mp-asnc.mpxl /size: 5942 b    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=mp-asnc.mpiv,
3
%D version=2012.02.19, % was mp-core: 1999.08.01, anchoring
4
%D title=\CONTEXT\ \METAPOST\ graphics,
5
%D subtitle=anchored background macros,
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 See anch-snc.mkxl for historic comments.
15 16
if
known
context_asnc
:
endinput
;
fi
;
17 18
boolean
context_asnc
;
context_asnc
:
=
true
;
19 20
newscriptindex
mfid_asnc_collect
;
mfid_asnc_collect
:
=
scriptindex
"
asnc_collect
"
;
def
asnc_collect
(
expr
category
,
realpage
,
region
)
=
runscript
mfid_asnc_collect
(
category
)
(
realpage
)
(
region
)
enddef
;
21 22
newscriptindex
mfid_asnc_extend
;
mfid_asnc_extend
:
=
scriptindex
"
asnc_extend
"
;
def
asnc_extend
=
runscript
mfid_asnc_extend
enddef
;
23
newscriptindex
mfid_asnc_prune
;
mfid_asnc_prune
:
=
scriptindex
"
asnc_prune
"
;
def
asnc_prune
=
runscript
mfid_asnc_prune
enddef
;
24
newscriptindex
mfid_asnc_collapse
;
mfid_asnc_collapse
:
=
scriptindex
"
asnc_collapse
"
;
def
asnc_collapse
=
runscript
mfid_asnc_collapse
enddef
;
25
newscriptindex
mfid_asnc_getsize
;
mfid_asnc_getsize
:
=
scriptindex
"
asnc_getsize
"
;
def
asnc_getsize
=
runscript
mfid_asnc_getsize
enddef
;
26
newscriptindex
mfid_asnc_getx
;
mfid_asnc_getx
:
=
scriptindex
"
asnc_getx
"
;
def
asnc_getx
=
runscript
mfid_asnc_getx
enddef
;
27
newscriptindex
mfid_asnc_gety
;
mfid_asnc_gety
:
=
scriptindex
"
asnc_gety
"
;
def
asnc_gety
=
runscript
mfid_asnc_gety
enddef
;
28
newscriptindex
mfid_asnc_getw
;
mfid_asnc_getw
:
=
scriptindex
"
asnc_getw
"
;
def
asnc_getw
=
runscript
mfid_asnc_getw
enddef
;
29
newscriptindex
mfid_asnc_geth
;
mfid_asnc_geth
:
=
scriptindex
"
asnc_geth
"
;
def
asnc_geth
=
runscript
mfid_asnc_geth
enddef
;
30
newscriptindex
mfid_asnc_getd
;
mfid_asnc_getd
:
=
scriptindex
"
asnc_getd
"
;
def
asnc_getd
=
runscript
mfid_asnc_getd
enddef
;
31 32
newscriptindex
mfid_asnc_gettop
;
mfid_asnc_gettop
:
=
scriptindex
"
asnc_gettop
"
;
def
asnc_gettop
(
expr
n
)
=
(
runscript
mfid_asnc_gettop
n
)
enddef
;
33
newscriptindex
mfid_asnc_getbottom
;
mfid_asnc_getbottom
:
=
scriptindex
"
asnc_getbottom
"
;
def
asnc_getbottom
(
expr
n
)
=
(
runscript
mfid_asnc_getbottom
n
)
enddef
;
34
newscriptindex
mfid_asnc_getkind
;
mfid_asnc_getkind
:
=
scriptindex
"
asnc_getkind
"
;
def
asnc_getkind
(
expr
n
)
=
(
runscript
mfid_asnc_getkind
n
)
enddef
;
35
newscriptindex
mfid_asnc_gettask
;
mfid_asnc_gettask
:
=
scriptindex
"
asnc_gettask
"
;
def
asnc_gettask
(
expr
n
)
=
(
runscript
mfid_asnc_gettask
n
)
enddef
;
36 37
presetparameters
"
synchronizer
"
[
38
color
=
"
darkgray
"
,
% default color
39
colors
=
{
40
"
darkred
"
41
"
darkgreen
"
42
"
darkblue
"
,
43
"
darkyellow
"
,
44
"
darkmagenta
"
,
45
"
darkcyan
"
,
46
"
darkgray
"
47
}
,
48
index
=
1
,
49
hoffset
=
0
,
50
voffset
=
0
,
51
region
=
"
"
,
52
width
=
1
cm
,
53
extend
=
false
,
54
prune
=
true
,
55
collapse
=
true
,
56
draw
=
true
,
57
fill
=
true
,
58
page
=
"
auto
"
,
% yes | clip | auto | no
59
]
;
60 61
def
lmt_synchronizer
=
applyparameters
"
synchronizer
"
"
lmt_do_synchronizer
"
enddef
;
62 63
% boxdx boxdy ...
64 65
vardef
lmt_do_synchronizer
=
66
pushparameters
"
synchronizer
"
;
67
begingroup
;
68
save
index
,
dx
,
dy
,
width
,
count
,
page
,
region
,
paths
,
tasks
,
kinds
;
69
path
paths
[
]
;
numeric
tasks
[
]
;
numeric
kinds
[
]
;
70
%
71
numeric
index
;
index
:
=
getparameter
"
index
"
;
72
numeric
dx
;
dx
:
=
getparameter
"
hoffset
"
;
73
numeric
dy
;
dy
:
=
getparameter
"
voffset
"
;
74
numeric
width
;
width
:
=
getparameter
"
width
"
;
75
numeric
count
;
count
:
=
0
;
76
string
page
;
page
:
=
getparameter
"
page
"
;
77
string
region
;
region
:
=
getparameter
"
region
"
;
78
%
79
count
:
=
asnc_collect
(
index
,
RealPageNumber
,
region
)
;
80
if
getparameter
"
extend
"
:
81
count
:
=
asnc_extend
;
% to top of text area
82
fi
;
83
if
getparameter
"
prune
"
:
84
count
:
=
asnc_prune
;
% clip top / bottom
85
fi
;
86
if
getparameter
"
collapse
"
:
87
count
:
=
asnc_collapse
;
88
fi
;
89
if
count
>
0
:
90
save
k
,
t
,
b
,
l
,
r
,
y
;
91
numeric
l
;
l
:
=
dx
;
92
numeric
r
;
r
:
=
dx
+
width
;
93
numeric
y
;
y
:
=
asnc_gety
+
dy
;
94
for
i
=
1
upto
count
:
95
k
:
=
asnc_getkind
(
i
)
;
96
t
:
=
asnc_gettop
(
i
)
-
y
;
97
b
:
=
asnc_getbottom
(
i
)
-
y
;
98
paths
[
i
]
=
(
(
l
,
t
)
--
(
r
,
t
)
--
(
r
,
b
)
--
(
l
,
b
)
--
cycle
)
;
99
tasks
[
i
]
=
asnc_gettask
(
i
)
;
100
kinds
[
i
]
=
k
;
101
endfor
;
102
if
page
=
"
auto
"
:
103
page
:
=
if
region
=
=
"
"
:
"
clip
"
else
:
"
no
"
fi
;
104
fi
;
105
if
(
page
=
"
clip
"
)
or
(
page
=
"
yes
"
)
:
106
StartPage
;
107
fi
;
108
if
getparameter
"
fill
"
:
109
for
i
=
1
upto
count
:
110
fill
paths
[
i
]
111
withcolor
getparameterdefault
"
colors
"
i
(
getparameter
"
color
"
)
;
112
;
113
endfor
;
114
fi
;
115
if
getparameter
"
draw
"
:
116
for
i
=
1
upto
count
:
117
draw
paths
[
i
]
118
withcolor
getparameterdefault
"
colors
"
i
(
getparameter
"
color
"
)
;
119
;
120
endfor
;
121
fi
;
122
if
page
=
"
clip
"
:
123
clip
currentpicture
to
Page
;
124
setbounds
currentpicture
to
Page
;
125
fi
;
126
if
(
page
=
"
clip
"
)
or
(
page
=
"
yes
"
)
:
127
StopPage
;
128
fi
;
129
fi
;
130
endgroup
;
131
popparameters
;
132
enddef
;
133 134