diff options
author | Arun Isaac | 2016-12-21 02:21:54 +0530 |
---|---|---|
committer | Arun Isaac | 2016-12-21 02:21:54 +0530 |
commit | b3484b533476aa6d6263775b7a79670bc9eec70e (patch) | |
tree | b23b559f5aef54bcde689ee7307da762181dce9a /biometry.asy | |
download | ksh-reports-b3484b533476aa6d6263775b7a79670bc9eec70e.tar.gz ksh-reports-b3484b533476aa6d6263775b7a79670bc9eec70e.tar.lz ksh-reports-b3484b533476aa6d6263775b7a79670bc9eec70e.zip |
Initial commit
Diffstat (limited to 'biometry.asy')
-rw-r--r-- | biometry.asy | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/biometry.asy b/biometry.asy new file mode 100644 index 0000000..294c212 --- /dev/null +++ b/biometry.asy @@ -0,0 +1,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); +}
\ No newline at end of file |