meta-imp-mat.mkiv /size: 8373 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=meta-mat,
3
%D version=2013.07.19,
4
%D title=\METAPOST\ Graphics,
5
%D subtitle=Math,
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
% A few accents:
15
%
16
% / for cambria
17 18
%D We need this for Alan, who nests math in \METAPOST:
19 20
\unprotect
21 22
\setupmathstackers
23
[
\c!mp
=
minifun
:
:
math
:
stacker
:
\number
\scratchunicode
]
24 25
\protect
26 27
\startMPextensions
28
vardef
math_stacker_bracket_shape
(
expr
delta
,
rotate
)
=
29
image
(
30
draw
31
(
0
,
OverlayOffset
)
--
32
(
0
,
delta
-
OverlayOffset
)
--
33
(
OverlayWidth
,
delta
-
OverlayOffset
)
--
34
(
OverlayWidth
,
OverlayOffset
)
35
withcolor
36
OverlayLineColor
;
37
setbounds
currentpicture
to
boundingbox
currentpicture
bottomenlarged
OverlayOffset
;
38
if
rotate
:
39
currentpicture
:
=
currentpicture
rotated
180
;
40
fi
;
41
)
42
enddef
;
43
vardef
math_stacker_parent_shape
(
expr
delta
,
rotate
)
=
44
image
(
45
draw
46
(
0
,
OverlayOffset
)
...
47
(
OverlayWidth
/
2
,
delta
-
OverlayOffset
)
...
48
(
OverlayWidth
,
OverlayOffset
)
49
withcolor
50
OverlayLineColor
;
51
setbounds
currentpicture
to
boundingbox
currentpicture
bottomenlarged
OverlayOffset
;
52
if
rotate
:
53
currentpicture
:
=
currentpicture
rotated
180
;
54
fi
;
55
)
56
enddef
;
57
vardef
math_stacker_brace_shape
(
expr
delta
,
rotate
)
=
58
image
(
59
draw
60
(
0
,
OverlayOffset
)
...
61
(
OverlayWidth
/
4
-
OverlayOffset
,
delta
-
OverlayOffset
)
...
62
(
OverlayWidth
/
2
-
OverlayOffset
,
delta
-
OverlayOffset
)
...
63
(
OverlayWidth
/
2
,
delta
)
&
64
(
OverlayWidth
/
2
,
delta
)
...
65
(
OverlayWidth
/
2
+
OverlayOffset
,
delta
-
OverlayOffset
)
...
66
(
3
OverlayWidth
/
4
+
OverlayOffset
,
delta
-
OverlayOffset
)
...
67
(
OverlayWidth
,
OverlayOffset
)
68
withcolor
69
OverlayLineColor
;
70
setbounds
currentpicture
to
boundingbox
currentpicture
bottomenlarged
OverlayOffset
;
71
if
rotate
:
72
currentpicture
:
=
currentpicture
rotated
180
;
73
fi
;
74
)
75
enddef
;
76
vardef
math_stacker_bar_shape
(
expr
rotate
)
=
77
image
(
78
draw
79
(
0
,
OverlayOffset
)
--
(
OverlayWidth
,
OverlayOffset
)
80
withcolor
81
OverlayLineColor
;
82
setbounds
currentpicture
to
boundingbox
currentpicture
bottomenlarged
OverlayOffset
;
83
if
rotate
:
84
currentpicture
:
=
currentpicture
rotated
180
;
85
fi
;
86
)
87
enddef
;
88
% arrows
89
vardef
math_stacker_arrow_shape
(
expr
axis
,
ex
,
em
,
rotate
)
=
90
image
(
91
interim
ahlength
:
=
ex
/
2
;
92
drawarrow
93
(
(
OverlayWidth
,
ex
/
2
)
--
(
0
,
ex
/
2
)
)
94
withcolor
95
OverlayLineColor
;
96
setbounds
currentpicture
to
unitsquare
xysized
(
OverlayWidth
,
ex
)
;
97
if
rotate
:
98
currentpicture
:
=
currentpicture
rotated
180
;
99
fi
;
100
)
101
enddef
;
102
vardef
math_stacker_leftrightarrow_shape
(
expr
axis
,
ex
,
em
,
rotate
)
=
103
image
(
104
interim
ahlength
:
=
ex
/
2
;
105
drawdblarrow
106
(
(
OverlayWidth
,
ex
/
2
)
--
(
0
,
ex
/
2
)
)
107
withcolor
108
OverlayLineColor
;
109
setbounds
currentpicture
to
unitsquare
xysized
(
OverlayWidth
,
ex
)
;
110
if
rotate
:
111
currentpicture
:
=
currentpicture
rotated
180
;
112
fi
;
113
)
114
enddef
;
115
vardef
math_stacker_rightoverleftarrow_shape
(
expr
axis
,
ex
,
em
,
rotate
)
=
116
image
(
117
interim
ahlength
:
=
ex
/
2
;
118
drawdoublearrows
119
(
(
OverlayWidth
,
ex
/
2
)
--
(
0
,
ex
/
2
)
)
120
withcolor
121
OverlayLineColor
;
122
setbounds
currentpicture
to
unitsquare
xysized
(
OverlayWidth
,
ex
)
;
123
if
rotate
:
124
currentpicture
:
=
currentpicture
rotated
180
;
125
fi
;
126
)
127
enddef
;
128 129
% main handler
130 131
def
math_stacker_draw_accent
(
expr
p
)
=
132
draw
p
withpen
pencircle
scaled
OverlayLineWidth
xyscaled
(
2
,
3
)
rotated
45
;
133
enddef
;
134 135
def
math_stacker_draw_arrow
(
expr
p
)
=
136
draw
p
withpen
pencircle
scaled
OverlayLineWidth
;
137
enddef
;
138
\stopMPextensions
139 140
\startuniqueMPgraphic
{
minifun::math:stacker:\number"FE3B4
}
{
axis,ex,em
}
141
math_stacker_draw_accent
(
math_stacker_bracket_shape
(
OverlayHeight
,
false
)
)
;
142
\stopuniqueMPgraphic
143 144
\startuniqueMPgraphic
{
minifun::math:stacker:\number"FE3B5
}
{
axis,ex,em
}
145
math_stacker_draw_accent
(
math_stacker_bracket_shape
(
OverlayDepth
,
true
)
)
;
146
\stopuniqueMPgraphic
147 148
\startuniqueMPgraphic
{
minifun::math:stacker:\number"FE3DC
}
{
axis,ex,em
}
149
math_stacker_draw_accent
(
math_stacker_parent_shape
(
OverlayHeight
,
false
)
)
;
150
\stopuniqueMPgraphic
151 152
\startuniqueMPgraphic
{
minifun::math:stacker:\number"FE3DD
}
{
axis,ex,em
}
153
math_stacker_draw_accent
(
math_stacker_parent_shape
(
OverlayDepth
,
true
)
)
;
154
\stopuniqueMPgraphic
155 156
\startuniqueMPgraphic
{
minifun::math:stacker:\number"FE3DE
}
{
axis,ex,em
}
157
math_stacker_draw_accent
(
math_stacker_brace_shape
(
OverlayHeight
,
false
)
)
;
158
\stopuniqueMPgraphic
159 160
\startuniqueMPgraphic
{
minifun::math:stacker:\number"FE3DF
}
{
axis,ex,em
}
161
math_stacker_draw_accent
(
math_stacker_brace_shape
(
OverlayDepth
,
true
)
)
;
162
\stopuniqueMPgraphic
163 164
\startuniqueMPgraphic
{
minifun::math:stacker:\number"FE33E
}
{
axis,ex,em
}
165
math_stacker_draw_accent
(
math_stacker_bar_shape
(
false
)
)
;
166
\stopuniqueMPgraphic
167 168
\startuniqueMPgraphic
{
minifun::math:stacker:\number"FE33F
}
{
axis,ex,em
}
169
math_stacker_draw_accent
(
math_stacker_bar_shape
(
true
)
)
;
170
\stopuniqueMPgraphic
171 172
\startuniqueMPgraphic
{
minifun::math:stacker:\number"2190
}
{
axis,ex,em
}
173
math_stacker_draw_arrow
(
math_stacker_arrow_shape
(
\MPvar
{
axis
}
,
\MPvar
{
ex
}
,
\MPvar
{
em
}
,
false
)
)
;
174
\stopuniqueMPgraphic
175 176
\startuniqueMPgraphic
{
minifun::math:stacker:\number"2192
}
{
axis,ex,em
}
177
math_stacker_draw_arrow
(
math_stacker_arrow_shape
(
\MPvar
{
axis
}
,
\MPvar
{
ex
}
,
\MPvar
{
em
}
,
true
)
)
;
178
\stopuniqueMPgraphic
179 180
\startuniqueMPgraphic
{
minifun::math:stacker:\number"2194
}
{
axis,ex,em
}
181
math_stacker_draw_arrow
(
math_stacker_leftrightarrow_shape
(
\MPvar
{
axis
}
,
\MPvar
{
ex
}
,
\MPvar
{
em
}
,
false
)
)
;
182
\stopuniqueMPgraphic
183 184
\startuniqueMPgraphic
{
minifun::math:stacker:\number"27F7
}
{
axis,ex,em
}
185
math_stacker_draw_arrow
(
math_stacker_leftrightarrow_shape
(
\MPvar
{
axis
}
,
\MPvar
{
ex
}
,
\MPvar
{
em
}
,
false
)
)
;
186
\stopuniqueMPgraphic
187 188
\startuniqueMPgraphic
{
minifun::math:stacker:\number"21C4
}
{
axis,ex,em
}
189
math_stacker_draw_arrow
(
math_stacker_rightoverleftarrow_shape
(
\MPvar
{
axis
}
,
\MPvar
{
ex
}
,
\MPvar
{
em
}
,
false
)
)
;
190
\stopuniqueMPgraphic
191 192
%D Radicals:
193 194
\startMPextensions
195
vardef
math_radical_simple
(
expr
w
,
h
,
d
,
o
)
=
196
(
-
h
/
2
-
o
,
h
/
2
-
o
)
--
197
(
-
h
/
4
-
o
,
-
d
-
o
)
--
198
(
-
o
,
h
+
o
)
--
199
(
w
+
o
,
h
+
o
)
--
200
(
w
+
o
,
h
-
h
/
10
+
o
)
201
enddef
;
202
\stopMPextensions
203 204
\startuniqueMPgraphic
{
minifun::math:radical:default
}
{
axis,ex,em
}
205
draw
206
math_radical_simple
(
OverlayWidth
,
OverlayHeight
,
OverlayDepth
,
OverlayOffset
)
207
withpen
pencircle
xscaled
(
2
OverlayLineWidth
)
yscaled
(
3
OverlayLineWidth
/
4
)
rotated
30
208
% dashed evenly
209
withcolor
OverlayLineColor
;
210
\stopuniqueMPgraphic
211 212
\continueifinputfile
{
meta
-
imp
-
mat
.
mkiv
}
213 214
\setupmathstackers
[
both
]
[
color
=
darkred
,
alternative
=
mp
]
215
\setupmathstackers
[
top
]
[
color
=
darkred
,
alternative
=
mp
]
216
\setupmathstackers
[
bottom
]
[
color
=
darkred
,
alternative
=
mp
]
217 218
\startTEXpage
[
offset
=
1
0
pt
]
219 220
$
221
\overbracket
{
a
+
b
+
c
+
d
}
\quad
222
\underbracket
{
a
+
b
+
c
+
d
}
\quad
223
\doublebracket
{
a
+
b
+
c
+
d
}
224
$
225
\blank
[
2
*
big
]
226
$
227
\overparent
{
a
+
b
+
c
+
d
}
\quad
228
\underparent
{
a
+
b
+
c
+
d
}
\quad
229
\doubleparent
{
a
+
b
+
c
+
d
}
230
$
231
\blank
[
2
*
big
]
232
$
233
\overbrace
{
a
+
b
+
c
+
d
}
\quad
234
\underbrace
{
a
+
b
+
c
+
d
}
\quad
235
\doublebrace
{
a
+
b
+
c
+
d
}
236
$
237
\blank
[
2
*
big
]
238
$
239
\overbar
{
a
+
b
+
c
+
d
}
\quad
240
\underbar
{
a
+
b
+
c
+
d
}
\quad
241
\doublebar
{
a
+
b
+
c
+
d
}
242
$
243
\blank
[
2
*
big
]
244
$
245
\overleftarrow
{
a
+
b
+
c
+
d
}
\quad
246
\overrightarrow
{
a
+
b
+
c
+
d
}
247
$
248
\blank
[
2
*
big
]
249
$
250
\underleftarrow
{
a
+
b
+
c
+
d
}
\quad
251
\underrightarrow
{
a
+
b
+
c
+
d
}
252
$
253 254
\stopTEXpage
255