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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
%D \module
%D [ file=mp-grid.mpiv,
%D version=2000.07.10,
%D title=\CONTEXT\ \METAPOST\ graphics,
%D subtitle=grid support,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%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 metafun_loaded_grid : endinput ; fi ;
newinternal boolean metafun_loaded_grid ; metafun_loaded_grid := true ; immutable metafun_loaded_grid ;
string fmt_separator ; fmt_separator := "@" ;
numeric fmt_precision ; fmt_precision := 3 ;
boolean fmt_initialize ; fmt_initialize := false ;
boolean fmt_zerocheck ; fmt_zerocheck := true ;
if unknown fmt_loaded : input "mp-form.mpxl" ; fi ;
boolean fmt_pictures ; fmt_pictures := true ;
def do_format = if fmt_pictures : format else : formatstr fi enddef ;
def do_mformat = if fmt_pictures : Mformat else : Mformatstr fi enddef ;
numeric grid_eps ; grid_eps = eps ;
def hlingrid (expr asked_min, asked_max, asked_step, asked_length, asked_width) text t =
image (
for i=asked_min step asked_step until asked_max+grid_eps :
draw (origin--(asked_width,0)) shifted (0,i*(asked_length/asked_max)) t ;
endfor ;
) ;
enddef ;
def vlingrid (expr asked_min, asked_max, asked_step, asked_length, asked_height) text t =
image (
for i=asked_min step asked_step until asked_max+grid_eps :
draw (origin--(0,asked_height)) shifted (i*(asked_length/asked_max),0) t ;
endfor ;
) ;
enddef ;
def hloggrid (expr asked_min, asked_max, asked_step, asked_length, asked_width) text t =
image (
for i=max(asked_min,1) step asked_step until min(asked_max,10)+grid_eps :
draw (origin--(asked_width,0)) shifted (0,asked_length*log(i)) t ;
endfor ;
) ;
enddef ;
def vloggrid (expr asked_min, asked_max, asked_step, asked_length, asked_height) text t =
image (
for i=max(asked_min,1) step asked_step until min(asked_max,10)+grid_eps :
draw (origin--(0,asked_height)) shifted (asked_length*log(i),0) t ;
endfor ;
) ;
enddef ;
vardef hlintext@#(expr asked_min, asked_max, asked_step, asked_length, asked_format) text t =
image (
for i=asked_min step asked_step until asked_max+grid_eps :
draw textext@#(mfun_format_number(asked_format,i)) shifted (0,i*(asked_length/asked_max)) t ;
endfor ;
)
enddef ;
vardef vlintext@#(expr asked_min, asked_max, asked_step, asked_length, asked_format) text t =
image (
for i=asked_min step asked_step until asked_max+grid_eps :
draw textext@#(mfun_format_number(asked_format,i)) shifted (i*(asked_length/asked_max),0) t ;
endfor ;
)
enddef ;
vardef hlogtext@#(expr asked_min, asked_max, asked_step, asked_length, asked_format) text t =
image (
for i=max(asked_min,1) step asked_step until min(asked_max,10)+grid_eps :
draw textext@#(mfun_format_number(asked_format,i)) shifted (0,asked_length*log(i)) t ;
endfor ;
)
enddef ;
vardef vlogtext@#(expr asked_min, asked_max, asked_step, asked_length, asked_format) text t =
image (
for i=max(asked_min,1) step asked_step until min(asked_max,10)+grid_eps :
draw textext@#(mfun_format_number(asked_format,i)) shifted (asked_length*log(i),0) t ;
endfor ;
)
enddef ;
vardef hlinlabel@#(expr asked_min, asked_max, asked_step, asked_length) text t =
image (
for i=asked_min step asked_step until asked_max+grid_eps :
draw thelabel@#(decimal i,(0,i*(asked_length/asked_max))) t ;
endfor ;
)
enddef ;
vardef vlinlabel@#(expr asked_min, asked_max, asked_step, asked_length) text t =
image (
for i=asked_min step asked_step until asked_max+grid_eps :
draw thelabel@#(decimal i,(i*(asked_length/asked_max),0)) t ;
endfor ;
)
enddef ;
% these will be replace by lmt_* variants
vardef linlog(expr xy) = ( xpart xy, log(ypart xy)) enddef ;
vardef loglin(expr xy) = (log(xpart xy), ypart xy) enddef ;
vardef loglog(expr xy) = (log(xpart xy), log(ypart xy)) enddef ;
vardef linlin(expr xy) = ( (xpart xy), (ypart xy)) enddef ;
vardef loglinpath primary p = processpath (p) (loglin) enddef ;
vardef linlogpath primary p = processpath (p) (linlog) enddef ;
vardef loglogpath primary p = processpath (p) (loglog) enddef ;
vardef linlinpath primary p = processpath (p) (linlin) enddef ;
permanent hlingrid, vlingrid, hloggrid, vloggrid, hlintext, vlintext, hlogtext, vlogtext, hlinlabel, vlinlabel ;
permanent linlog, loglin, loglog, linlin, loglinpath, linlogpath, loglogpath, linlinpath ;
|