mp-bare.mpiv /size: 2853 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=mp-bare.mpiv,
3
%D version=2014.10.31,
4
%D title=\CONTEXT\ \METAPOST\ graphics,
5
%D subtitle=plain plugins,
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
context_bare
:
endinput
;
fi
;
15
boolean
context_bare
;
context_bare
:
=
true
;
16 17
vardef
colordecimals
primary
c
=
18
if
cmykcolor
c
:
19
decimal
cyanpart
c
&
"
:
"
&
decimal
magentapart
c
&
"
:
"
&
decimal
yellowpart
c
&
"
:
"
&
decimal
blackpart
c
20
elseif
rgbcolor
c
:
21
decimal
redpart
c
&
"
:
"
&
decimal
greenpart
c
&
"
:
"
&
decimal
bluepart
c
22
else
:
23
decimal
c
24
fi
25
enddef
;
26 27
rgbcolor
mfun_tt_r
;
28
numeric
mfun_tt_n
;
mfun_tt_n
:
=
0
;
29
picture
mfun_tt_o
;
mfun_tt_o
:
=
nullpicture
;
30
picture
mfun_tt_c
;
mfun_tt_c
:
=
nullpicture
;
31 32
def
mfun_reset_tex_texts
=
33
mfun_tt_n
:
=
0
;
34
mfun_tt_o
:
=
nullpicture
;
% redundant
35
mfun_tt_c
:
=
nullpicture
;
% redundant
36
enddef
;
37 38
def
mfun_flush_tex_texts
=
39
enddef
;
40 41
vardef
rawtextext
(
expr
s
)
=
42
if
s
=
"
"
:
43
nullpicture
44
else
:
45
mfun_tt_n
:
=
mfun_tt_n
+
1
;
46
mfun_tt_c
:
=
nullpicture
;
47
mfun_tt_o
:
=
nullpicture
;
48
addto
mfun_tt_o
doublepath
origin
_op_
;
% save drawoptions
49
mfun_tt_r
:
=
runscript
(
"
mp.SomeText(
"
&
decimal
mfun_tt_n
&
"
,
"
&
ditto
&
s
&
ditto
&
"
)
"
)
;
50
addto
mfun_tt_c
doublepath
unitsquare
51
xscaled
redpart
mfun_tt_r
52
yscaled
(
greenpart
mfun_tt_r
+
bluepart
mfun_tt_r
)
53
shifted
(
0
,
-
bluepart
mfun_tt_r
)
54
withprescript
"
mf_object=text
"
55
withprescript
"
tx_index=
"
&
decimal
mfun_tt_n
56
withprescript
"
tx_color=
"
&
colordecimals
colorpart
mfun_tt_o
57
;
58
mfun_tt_c
59
fi
60
enddef
;
61 62
vardef
rawmadetext
=
63
mfun_tt_n
:
=
mfun_tt_n
+
1
;
64
mfun_tt_c
:
=
nullpicture
;
65
mfun_tt_o
:
=
nullpicture
;
66
addto
mfun_tt_o
doublepath
origin
_op_
;
% save drawoptions
67
mfun_tt_r
:
=
runscript
(
"
mp.MadeText(
"
&
decimal
mfun_tt_n
&
"
)
"
)
;
68
addto
mfun_tt_c
doublepath
unitsquare
69
xscaled
redpart
mfun_tt_r
70
yscaled
(
greenpart
mfun_tt_r
+
bluepart
mfun_tt_r
)
71
shifted
(
0
,
-
bluepart
mfun_tt_r
)
72
withprescript
"
mf_object=text
"
73
withprescript
"
tx_index=
"
&
decimal
mfun_tt_n
74
withprescript
"
tx_color=
"
&
colordecimals
colorpart
mfun_tt_o
75
;
76
mfun_tt_c
77
enddef
;
78 79
extra_beginfig
:
=
extra_beginfig
&
"
mfun_reset_tex_texts ;
"
;
80
extra_endfig
:
=
"
mfun_flush_tex_texts ; mfun_reset_tex_texts ;
"
&
extra_endfig
;
81 82
primarydef
str
infont
name
=
% nasty hack
83
if
name
=
"
"
:
84
rawtextext
(
str
)
85
else
:
86
rawtextext
(
"
\definedfont[
"
&
name
&
"
]
"
&
str
)
87
fi
88
enddef
;
89 90