diff options
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/metafun.mp | 1 | ||||
-rw-r--r-- | metapost/context/base/mp-figs.mp | 50 |
2 files changed, 51 insertions, 0 deletions
diff --git a/metapost/context/base/metafun.mp b/metapost/context/base/metafun.mp index 818653f7b..5071013c5 100644 --- a/metapost/context/base/metafun.mp +++ b/metapost/context/base/metafun.mp @@ -39,6 +39,7 @@ input mp-butt.mp ; input mp-char.mp ; input mp-step.mp ; input mp-grph.mp ; +input mp-figs.mp ; % mp-form.mp ; input mp-grid.mp ; diff --git a/metapost/context/base/mp-figs.mp b/metapost/context/base/mp-figs.mp new file mode 100644 index 000000000..aa6bc0399 --- /dev/null +++ b/metapost/context/base/mp-figs.mp @@ -0,0 +1,50 @@ +%D \module +%D [ file=mp-tool.mp, +%D version=2003.01.15, +%D title=\CONTEXT\ \METAPOST\ graphics, +%D subtitle=figures, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See licen-en.pdf for +%C details. + +if unknown context_tool : input mp-tool ; fi ; +if known context_figs : endinput ; fi ; + +boolean context_figs ; context_figs := true ; + +% todo: check defined + +def registerfigure(expr name,width,height) = + begingroup ; + save s ; string s ; s := cleanstring(name) ; + scantokens( s & "_width := " & decimal(width)) ; + scantokens( s & "_height := " & decimal(width)) ; + endgroup ; +enddef ; + +vardef figuresize(expr name) = + save s ; string s ; s := cleanstring(name) ; + save p ; pair p ; + scantokens( "p := " & "(" & s & "_width" & "," & s & "_height" & ")" ) ; + p +enddef ; + +vardef figurewidth(expr name) = + xpart figuresize(name) +enddef ; + +vardef figureheight(expr name) = + ypart figuresize(name) +enddef ; + +def figuredimensions = figuresize enddef ; % for old times sake + +def naturalfigure(expr name) = + externalfigure name xyscaled(figuresize(name)) +enddef ; + +endinput |