summaryrefslogtreecommitdiff
path: root/metapost/context/base/mp-func.mpiv
diff options
context:
space:
mode:
Diffstat (limited to 'metapost/context/base/mp-func.mpiv')
-rw-r--r--metapost/context/base/mp-func.mpiv70
1 files changed, 70 insertions, 0 deletions
diff --git a/metapost/context/base/mp-func.mpiv b/metapost/context/base/mp-func.mpiv
new file mode 100644
index 000000000..6ce7ee82a
--- /dev/null
+++ b/metapost/context/base/mp-func.mpiv
@@ -0,0 +1,70 @@
+%D \module
+%D [ file=mp-func.mp,
+%D version=2001.12.29,
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=function hacks,
+%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.
+
+%D Under construction.
+
+if known context_func : endinput ; fi ;
+
+boolean context_func ; context_func := true ;
+
+string mfun_pathconnectors[] ;
+
+mfun_pathconnectors[0] := "," ;
+mfun_pathconnectors[1] := "--" ;
+mfun_pathconnectors[2] := ".." ;
+mfun_pathconnectors[3] := "..." ;
+
+vardef mfun_draw_function (expr f) (expr u, t, b, e, s) = save x ; numeric x ;
+ for xx := b step s until e :
+ hide (x := xx ;)
+ if xx > b :
+ scantokens(mfun_pathconnectors[f])
+ fi
+ (scantokens(u),scantokens(t))
+ endfor
+enddef ;
+
+def punkedfunction = mfun_function (1) enddef ;
+def curvedfunction = mfun_function (2) enddef ;
+def tightfunction = mfun_function (3) enddef ;
+
+vardef mfun_constructedpath (expr f) (text t) =
+ save ok ; boolean ok ; ok := false ;
+ for i=t :
+ if ok :
+ scantokens(mfun_pathconnectors[f])
+ else :
+ ok := true ;
+ fi
+ i
+ endfor
+enddef ;
+
+def punkedpath = mfun_constructedpath (1) enddef ;
+def curvedpath = mfun_constructedpath (2) enddef ;
+def tightpath = mfun_constructedpath (3) enddef ;
+
+vardef mfun_constructedpairs (expr f) (text p) =
+ save i ; i := -1 ;
+ forever :
+ exitif unknown p[incr(i)] ;
+ if i>0 :
+ scantokens(mfun_pathconnectors[f])
+ fi
+ p[i]
+ endfor
+enddef ;
+
+def punkedpairs = mfun_constructedpairs (1) enddef ;
+def curvedpairs = mfun_constructedpairs (2) enddef ;
+def tightpairs = mfun_constructedpairs (3) enddef ;