summaryrefslogtreecommitdiff
path: root/biometry.asy
blob: 294c21207f44511b9a667b466eaefcaa4e232578 (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
pair pair_ratio(pair a, pair b, real fraction) {
     return a + (b - a)*fraction;
}
real real_ratio(real a, real b, real fraction) {
     return a + (b - a)*fraction;
}
void draw_tic(pair a, pair b, real fraction, real tic_height, bool label) {
     pair pt1 = pair_ratio(a, b, fraction);
     pair pt2 = pt1 - (0, tic_height);
     draw(pt1 -- pt2);
     if (label) {
     	label(format("%f\%", fraction*100), pt2, S);
     }
}
void draw_marker(pair a, pair b, real value, real marker_height) {
     pair markpt = pair_ratio(a, b, value);
     pair pt = (markpt.x, markpt.y + marker_height);
     label("*", pt);
}
void draw_scale(pair a, pair b, real value, real tic_height) {
     draw(pair_ratio(a, b, 0) -- pair_ratio(a, b, 1));
     draw_tic(a, b, 0.05, tic_height, true);
     draw_tic(a, b, 0.5, tic_height, true);
     draw_tic(a, b, 0.95, tic_height, true);
     draw_tic(a, b, 0.25, 0.5*tic_height, false);
     draw_tic(a, b, 0.75, 0.5*tic_height, false);
     draw_marker(a, b, value, 0.5*tic_height);
}
void draw_biometry(string param, string param_age, real percentile) {
     real width = 100;
     real height = 75;

     label(param, (width/2, 2*height/3), N);
     label(param_age, (width/2, 2*height/3), S);
     pair scale1 = (0.1*width, 0.25*height);
     pair scale2 = (0.9*width, 0.25*height);
     draw_scale(scale1, scale2, percentile/100, 0.1*height);
}