summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2005-05-25 00:00:00 +0200
committerHans Hagen <pragma@wxs.nl>2005-05-25 00:00:00 +0200
commit7791a6c6b224e5ec3c1a40489e231c887a8864fa (patch)
treef38992e333d212fe5ab14d23ae5e31ff7a73ab8c /metapost
parentc8cc55cfd81ec71e266cef774271a0fb56d73726 (diff)
downloadcontext-7791a6c6b224e5ec3c1a40489e231c887a8864fa.tar.gz
stable 2005.05.25
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mp-tool.mp35
1 files changed, 35 insertions, 0 deletions
diff --git a/metapost/context/base/mp-tool.mp b/metapost/context/base/mp-tool.mp
index 1f299807a..5c7353e38 100644
--- a/metapost/context/base/mp-tool.mp
+++ b/metapost/context/base/mp-tool.mp
@@ -21,6 +21,41 @@ if known context_tool : endinput ; fi ;
boolean context_tool ; context_tool := true ;
+%D New, version number testing:
+%D
+%D \starttyping
+%D fill fullcircle scaled 2cm withcolor if mpversiongt("0.6") : red else : green fi ;
+%D fill fullcircle scaled 1cm withcolor if mpversionlt(0.6) : blue else : white fi ;
+%D \stoptyping
+
+if not known mpversion : string mpversion ; mpversion := "0.641" ; fi ;
+
+% vardef mpversiongt(expr s) =
+% scantokens (mpversion & " > " & if numeric s : decimal s else : s fi)
+% enddef ;
+% vardef mpversionlt(expr s) =
+% scantokens (mpversion & " < " & if numeric s : decimal s else : s fi)
+% enddef ;
+% vardef mpversioneq(expr s) =
+% scantokens (mpversion & " = " & if numeric s : decimal s else : s fi)
+% enddef ;
+
+%D More interesting:
+%D
+%D \starttyping
+%D fill fullcircle scaled 4cm withcolor if mpversiongt("0.6") : red else : green fi ;
+%D fill fullcircle scaled 2cm withcolor if mpversionlt(0.6) : blue else : white fi ;
+%D fill fullcircle scaled 1cm withcolor if mpversioncmp(0.6,">=") : yellow else : black fi ;
+%D \stoptyping
+
+vardef mpversioncmp(expr s, c) =
+ scantokens (mpversion & c & if numeric s : decimal s else : s fi)
+enddef ;
+
+vardef mpversionlt (expr s) = mpversioncmp(s, "<") enddef ;
+vardef mpversioneq (expr s) = mpversioncmp(s, "=") enddef ;
+vardef mpversiongt (expr s) = mpversioncmp(s, ">") enddef ;
+
%D We always want \EPS\ conforming output, so we say:
prologues := 2 ; % 1 = troff, 2 = tex