mp-figs.mpxl /size: 1308 b    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=mp-figs.mpiv,
3
%D version=2003.01.15,
4
%D title=\CONTEXT\ \METAPOST\ graphics,
5
%D subtitle=figures,
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_figs
:
endinput
;
fi
;
15 16
newinternal
boolean
metafun_loaded_figs
;
metafun_loaded_figs
:
=
true
;
immutable
metafun_loaded_figs
;
17 18
% todo: check defined
19 20
def
registerfigure
(
expr
name
,
width
,
height
)
=
21
begingroup
;
22
save
s
;
string
s
;
s
:
=
cleanstring
(
name
)
;
23
scantokens
(
s
&
"
_width :=
"
&
decimal
(
width
)
)
;
24
scantokens
(
s
&
"
_height :=
"
&
decimal
(
height
)
)
;
25
endgroup
;
26
enddef
;
27 28
vardef
figuresize
(
expr
name
)
=
29
save
s
,
p
;
string
s
;
pair
p
;
30
s
:
=
cleanstring
(
name
)
;
31
scantokens
(
"
p :=
"
&
"
(
"
&
s
&
"
_width
"
&
"
,
"
&
s
&
"
_height
"
&
"
)
"
)
;
32
p
33
enddef
;
34 35
vardef
figurewidth
(
expr
name
)
=
36
xpart
figuresize
(
name
)
37
enddef
;
38 39
vardef
figureheight
(
expr
name
)
=
40
ypart
figuresize
(
name
)
41
enddef
;
42 43
let
figuredimensions
=
figuresize
;
% for old times sake
44 45
def
naturalfigure
(
expr
name
)
=
46
externalfigure
name
xyscaled
(
figuresize
(
name
)
)
47
enddef
;
48