summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/minim-mp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-03-04 22:04:55 +0000
committerKarl Berry <karl@freefriends.org>2022-03-04 22:04:55 +0000
commitf4b65fd65868a9f68c17fa969bd5533b8c81af68 (patch)
tree20f68ebb5713403ef628f48ec4c41090013df5bc /Master/texmf-dist/metapost/minim-mp
parent2af24efcc003674f1cb52ea3284357faf60540f1 (diff)
minim* (4mar22)
git-svn-id: svn://tug.org/texlive/trunk@62419 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/minim-mp')
-rw-r--r--Master/texmf-dist/metapost/minim-mp/minim.mp81
1 files changed, 76 insertions, 5 deletions
diff --git a/Master/texmf-dist/metapost/minim-mp/minim.mp b/Master/texmf-dist/metapost/minim-mp/minim.mp
index c78dde2a927..f3f03eb3d0e 100644
--- a/Master/texmf-dist/metapost/minim-mp/minim.mp
+++ b/Master/texmf-dist/metapost/minim-mp/minim.mp
@@ -1,13 +1,19 @@
delimiters ();
+% redefine some constants to work with the new numerical engines
+numeric mm, cm, pt, pc, dd, cc;
+pc = 12 pt; cc = 12 dd; cm = 10 mm;
+803 pt = 800; 127 mm = 360; 1157 dd = 1238 pt;
+eps := 1/2048; infinity := 64*64-epsilon;
+
message "Loading the minim extension macros";
% interaction with tex
-def baseline expr o =
- fill if numeric o: (0,o) else o fi
+vardef baseline expr o =
+ fill if numeric o : (0,o) else: o fi
-- cycle withprescript "BASELINE:"; enddef;
-def boxresource expr nr = image(
+vardef boxresource expr nr = image(
fill unitsquare withprescript "BOXRESOURCE:" & decimal nr ;
setbounds currentpicture to unitsquare transformed runscript
("return { 'box_size', tex.getboxresourcedimensions(" & decimal nr & ") }");
@@ -17,6 +23,46 @@ primarydef t infont f = image( runscript(
"return require('minim-mp').infont("&ditto&t&ditto&", "
&if numeric f: decimal(f) else: ditto&f&ditto fi&")" ) ) enddef;
+% even-odd rule
+def nofill expr c = fill c withprescript "OTYPE:nofill" enddef;
+def eofill expr c = fill c withprescript "OTYPE:eofill" enddef;
+def eofilldraw expr c = filldraw c withprescript "OTYPE:eofilldraw" enddef;
+
+def multidraw (text paths) text opts = draw image(
+ for p = paths: ; nofill p opts endfor
+ withprescript "OTYPE:outline";) enddef;
+def multifill (text paths) text opts = draw image(
+ for p = paths: ; nofill p opts endfor
+ withprescript "OTYPE:fill";) enddef;
+def multifilldraw (text paths) text opts = draw image(
+ for p = paths: ; nofill p opts endfor
+ withprescript "OTYPE:filldraw";) enddef;
+def multieofill (text paths) text opts = draw image(
+ for p = paths: ; nofill p opts endfor
+ withprescript "OTYPE:eofill";) enddef;
+def multieofilldraw (text paths) text opts = draw image(
+ for p = paths: ; nofill p opts endfor
+ withprescript "OTYPE:eofilldraw";) enddef;
+
+vardef clipto text t =
+ clip currentpicture to bbox currentpicture
+ for c = t: -- c -- cycle endfor -- cycle enddef;
+vardef clipout text t =
+ clip currentpicture to
+ for c = t: c -- cycle -- endfor cycle enddef;
+
+vardef glyph expr c of f = image(for p =
+ runscript("return require('minim-mp').get_"
+ &if string c: "named_glyph("&ditto&c&ditto
+ else: "glyph("& decimal c fi &", "
+ &if numeric f: decimal(f) else: ditto&f&ditto fi
+ & ")" ) : ; nofill p endfor
+ withprescript "OTYPE:fill"; ) enddef;
+
+def contours expr t of f =
+ runscript("return require('minim-mp').get_contours("&ditto&t&ditto&", "
+ &if numeric f: decimal(f) else: ditto&f&ditto fi& ")" ) enddef;
+
% interaction with lua
vardef hexadecimal expr n =
% TODO: support other number systems
@@ -68,6 +114,31 @@ def endpattern (expr xstep, ystep) =
newinternal tilingtype; tilingtype:=1;
_patterns_._last_ := 0;
-% so that we can load plain.mp after this
-let dump = endinput ;
+% shorthands
+primarydef p xshifted x = p shifted (x,0) enddef;
+primarydef p yshifted y = p shifted (0,y) enddef;
+
+% reverse paths to allow „p & vflip p”
+def hflip primary p = if path p: reverse fi p xscaled -1 enddef;
+def vflip primary p = if path p: reverse fi p yscaled -1 enddef;
+
+% missing definitions
+path fullsquare, unitcircle ;
+fullsquare := unitsquare shifted - center unitsquare ;
+unitcircle := fullcircle shifted urcorner fullcircle ;
+
+% complement counterclockwise
+vardef clockwise primary c =
+ if turningnumber c > 0: reverse fi c enddef;
+
+% cmyk colours
+cmykcolor cyan, magenta, yellow, key;
+cyan = (1,0,0,0);
+magenta = (0,1,0,0);
+yellow = (0,0,1,0);
+key = (0,0,0,1);
+
+% constants
+pi := 355/113;
+