1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16if known context_grid : endinput ; fi ;
17
18boolean context_grid ; context_grid := true ;
19
20string fmt_separator ; fmt_separator := "@" ;
21numeric fmt_precision ; fmt_precision := 3 ;
22boolean fmt_initialize ; fmt_initialize := false ;
23boolean fmt_zerocheck ; fmt_zerocheck := true ;
24
25if unknown fmt_loaded : input "mp-form.mpiv" ; fi ;
26
27boolean fmt_pictures ; fmt_pictures := true ;
28
29def do_format = if fmt_pictures : format else : formatstr fi enddef ;
30def do_mformat = if fmt_pictures : Mformat else : Mformatstr fi enddef ;
31
32numeric grid_eps ; grid_eps = eps ;
33
34def hlingrid (expr Min, Max, Step, Length, Width) text t =
35 image (
36 for i=Min step Step until Maxgrid_eps :
37 draw (origin--(Width,0)) shifted (0,i(LengthMax)) t ;
38 endfor ;
39 ) ;
40enddef ;
41
42def vlingrid (expr Min, Max, Step, Length, Height) text t =
43 image (
44 for i=Min step Step until Maxgrid_eps :
45 draw (origin--(0,Height)) shifted (i(LengthMax),0) t ;
46 endfor ;
47 ) ;
48enddef ;
49
50def hloggrid (expr Min, Max, Step, Length, Width) text t =
51 image (
52 for i=max(Min,1) step Step until min(Max,10)grid_eps :
53 draw (origin--(Width,0)) shifted (0,Lengthlog(i)) t ;
54 endfor ;
55 ) ;
56enddef ;
57
58def vloggrid (expr Min, Max, Step, Length, Height) text t =
59 image (
60 for i=max(Min,1) step Step until min(Max,10)grid_eps :
61 draw (origin--(0,Height)) shifted (Lengthlog(i),0) t ;
62 endfor ;
63 ) ;
64enddef ;
65
66vardef hlintext@#(expr Min, Max, Step, Length, Format) text t =
67 image (
68 for i=Min step Step until Maxgrid_eps :
69 draw textext@#(mfun_format_number(Format,i)) shifted (0,i(LengthMax)) t ;
70 endfor ;
71 )
72enddef ;
73
74vardef vlintext@#(expr Min, Max, Step, Length, Format) text t =
75 image (
76 for i=Min step Step until Maxgrid_eps :
77 draw textext@#(mfun_format_number(Format,i)) shifted (i(LengthMax),0) t ;
78 endfor ;
79 )
80enddef ;
81
82vardef hlogtext@#(expr Min, Max, Step, Length, Format) text t =
83 image (
84 for i=max(Min,1) step Step until min(Max,10)grid_eps :
85 draw textext@#(mfun_format_number(Format,i)) shifted (0,Lengthlog(i)) t ;
86 endfor ;
87 )
88enddef ;
89
90vardef vlogtext@#(expr Min, Max, Step, Length, Format) text t =
91 image (
92 for i=max(Min,1) step Step until min(Max,10)grid_eps :
93 draw textext@#(mfun_format_number(Format,i)) shifted (Lengthlog(i),0) t ;
94 endfor ;
95 )
96enddef ;
97
98vardef hlinlabel@#(expr Min, Max, Step, Length) text t =
99 image (
100 for i=Min step Step until Maxgrid_eps :
101 draw thelabel@#(decimal i,(0,i(LengthMax))) t ;
102 endfor ;
103 )
104enddef ;
105
106vardef vlinlabel@#(expr Min, Max, Step, Length) text t =
107 image (
108 for i=Min step Step until Maxgrid_eps :
109 draw thelabel@#(decimal i,(i(LengthMax),0)) t ;
110 endfor ;
111 )
112enddef ;
113
114vardef linlog(expr xy) = ( xpart xy, log(ypart xy)) enddef ;
115vardef loglin(expr xy) = (log(xpart xy), ypart xy) enddef ;
116vardef loglog(expr xy) = (log(xpart xy), log(ypart xy)) enddef ;
117vardef linlin(expr xy) = ( (xpart xy), (ypart xy)) enddef ;
118
119vardef loglinpath primary p = processpath (p) (loglin) enddef ;
120vardef linlogpath primary p = processpath (p) (linlog) enddef ;
121vardef loglogpath primary p = processpath (p) (loglog) enddef ;
122vardef linlinpath primary p = processpath (p) (linlin) enddef ;
123
124vardef processpath (expr p) (text pp) =
125 if path p :
126 for i=0 upto length(p)-1 :
127 pp(point i of p) .. controls
128 pp(postcontrol i of p) and
129 pp(precontrol (i+1) of p) ..
130 endfor
131 if cycle p :
132 cycle
133 else :
134 pp(point length(p) of p)
135 fi
136 elseif pair p :
137 pp(p)
138 else :
139 p
140 fi
141enddef ;
142
143 |