mp-butt.mpxl /size: 2437 b    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=mp-butt.mpiv,
3
%D version=2000.05.31,
4
%D title=\CONTEXT\ \METAPOST\ graphics,
5
%D subtitle=buttons,
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 licen-en.pdf for
12
%C details.
13 14
if
known
metafun_loaded_butt
:
endinput
;
fi
;
15 16
newinternal
boolean
metafun_loaded_butt
;
metafun_loaded_butt
:
=
true
;
immutable
metafun_loaded_butt
;
17 18
def
predefinedbutton
(
expr
button_type
,
button_size
,
button_linecolor
,
button_fillcolor
)
=
19 20
begingroup
;
21 22
save
button_linewidth
,
p
,
d
,
l
;
23 24
numeric
button_linewidth
;
button_linewidth
:
=
button_size
/
10
;
25 26
drawoptions
(
withpen
pencircle
scaled
button_linewidth
withcolor
button_linecolor
)
;
27 28
path
p
;
p
:
=
unitsquare
scaled
button_size
;
29
numeric
d
;
d
:
=
button_size
;
30
numeric
l
;
l
:
=
button_linewidth
;
31 32
fill
p
withcolor
button_fillcolor
;
33
draw
p
;
34 35
if
button_type
=
101
:
36
draw
(
d
-2
l
,
2
l
)
--
(
2
l
,
.5
d
)
--
(
d
-2
l
,
d
-2
l
)
-
-
cycle
;
37
elseif
button_type
=
102
:
38
draw
(
2
l
,
2
l
)
--
(
d
-2
l
,
.5
d
)
--
(
2
l
,
d
-2
l
)
-
-
cycle
;
39
elseif
button_type
=
103
:
40
for
i
=
2
l
step
2
l
until
d
-2
l
:
41
draw
(
2
l
,
i
)
--
(
2
l
,
i
)
;
42
draw
(
4
l
,
i
)
--
(
d
-2
l
,
i
)
;
43
endfor
;
44
elseif
button_type
=
104
:
45
for
i
=
2
l
step
2
l
until
d
-2
l
:
46
draw
(
2
l
,
i
)
--
(
d
/
2
-
l
,
i
)
;
47
draw
(
d
/
2
+
l
,
i
)
--
(
d
-2
l
,
i
)
;
48
endfor
;
49
elseif
button_type
=
105
:
50
fill
fullcircle
scaled
(
.2
d
)
shifted
(
.5
d
,
.7
d
)
;
51
fill
fullcircle
xscaled
(
.6
d
)
yscaled
d
shifted
(
.5
d
,
0
)
;
52
clip
currentpicture
to
p
;
53
draw
p
;
54
elseif
button_type
=
106
:
55
draw
(
2
l
,
2
l
)
--
(
d
-2
l
,
d
-2
l
)
;
56
draw
(
d
-2
l
,
2
l
)
--
(
2
l
,
d
-2
l
)
;
57
elseif
button_type
=
107
:
58
p
:
=
(
3
l
,
d
-2
l
)
--
(
d
-3
l
,
d
-2
l
)
--
(
.5
d
,
4
l
)
-
-
cycle
;
59
fill
p
;
draw
p
;
60
draw
(
.5
d
,
2
l
)
;
61
elseif
button_type
=
108
:
62
draw
(
.5
d
,
2
l
)
--
(
d
-2
l
,
d
-2
l
)
--
(
2
l
,
d
-2
l
)
-
-
cycle
;
63
elseif
button_type
=
109
:
64
draw
(
.5
d
,
d
-2
l
)
--
(
d
-2
l
,
2
l
)
--
(
2
l
,
2
l
)
-
-
cycle
;
65
elseif
button_type
=
110
:
66
button_linewidth
:
=
button_linewidth
/
2
;
67
draw
p
enlarged
(
-2
l
,
-
l
)
;
68
for
i
=
2
l
step
l
until
d
-2
l
:
69
draw
(
3
l
,
i
)
--
(
d
-3
l
,
i
)
;
70
endfor
;
71
fi
;
72 73
endgroup
;
74 75
enddef
;
76 77
let
some_button
=
predefinedbutton
78