blob: d8646ef3bddfe542606b132cbaff01ce1941ab63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
%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 unknown context_tool : input mp-tool ; fi ;
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 ;
|