diff options
author | Marius <mariausol@gmail.com> | 2011-10-13 22:40:14 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-10-13 22:40:14 +0300 |
commit | b356573a2d7c9f73058b973e322791d5eee16ef5 (patch) | |
tree | 2a4dc5359a5af1a77114ce64e34b21b50700ee9a /metapost/context/base/mp-func.mpii | |
parent | 5d962b2279f50640b57dd1f86236a36da8f5cdf5 (diff) | |
download | context-b356573a2d7c9f73058b973e322791d5eee16ef5.tar.gz |
beta 2011.10.13 21:36
Diffstat (limited to 'metapost/context/base/mp-func.mpii')
-rw-r--r-- | metapost/context/base/mp-func.mpii | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/metapost/context/base/mp-func.mpii b/metapost/context/base/mp-func.mpii new file mode 100644 index 000000000..407d534e8 --- /dev/null +++ b/metapost/context/base/mp-func.mpii @@ -0,0 +1,58 @@ +%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 pathconnectors[] ; + +pathconnectors[0] := "," ; +pathconnectors[1] := "--" ; +pathconnectors[2] := ".." ; +pathconnectors[3] := "..." ; + +vardef 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(pathconnectors[f]) fi + (scantokens(u),scantokens(t)) + endfor +enddef ; + +def punkedfunction = function (1) enddef ; +def curvedfunction = function (2) enddef ; +def tightfunction = function (3) enddef ; + +vardef constructedpath (expr f) (text t) = + save ok ; boolean ok ; ok := false ; + for i=t : + if ok : scantokens(pathconnectors[f]) else : ok := true ; fi i + endfor +enddef ; + +def punkedpath = constructedpath (1) enddef ; +def curvedpath = constructedpath (2) enddef ; +def tightpath = constructedpath (3) enddef ; + +vardef constructedpairs (expr f) (text p) = + save i ; i := -1 ; + forever : exitif unknown p[incr(i)] ; + if i>0 : scantokens(pathconnectors[f]) fi p[i] + endfor +enddef ; + +def punkedpairs = constructedpairs (1) enddef ; +def curvedpairs = constructedpairs (2) enddef ; +def tightpairs = constructedpairs (3) enddef ; |