summaryrefslogtreecommitdiff
path: root/info/drawing-with-metapost/src/color-hsv-bathymetric.mp
blob: 057e923eddf270563b395c1ce5c7bdcea8d6ae7c (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
\documentclass{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
input color-hsv-macro
beginfig(2);
    defaultfont := "phvr8r";
    defaultscale := 3/4;
    path h,d,b; numeric n;
    h = ((-2,0)--(0,0)--(-1,3)--(-2,3)--cycle) scaled 60;
    d = h rotated 180;
    n = 10;
    b = subpath (0,1) of h -- point 1+1/n of d -- (xpart point 0 of h, ypart point 1+1/n of d) -- cycle;
    fill b withcolor hsv_color(123, 1/8, 7/8);
    draw subpath (2.13,4) of b;

    for i=1 upto n:
        fill point 4-(i-1)/n of h -- point 1+(i-1)/n of h 
             -- point 1+i/n of h -- point 4-i/n of h -- cycle
             withcolor hsv_color(42, 1/4 + 3/4 * i/n, 1 - i/3n);
        fill point 4-(i-1)/n of d -- point 1+(i-1)/n of d 
             -- point 1+i/n of d -- point 4-i/n of d -- cycle
             withcolor hsv_color(200, i/n - 1/n, 1 - i/3n);
    endfor
    string s;
    for i=1 upto n-1: 
        draw point 4-i/n of h -- point 1+i/n of h; 
        draw point 4-i/n of d -- point 1+i/n of d; 
        s := decimal if i < 4: (i**2+1) else: (10 + (i-3)*10) fi & "00";
        label.rt(s, point 1+i/n of h);
        label.lft(s, point 1+i/n of d);
    endfor
    label.rt("Metres", point 2 of h);
    label.lft("Metres", point 2 of d);
    label.lft("Hypsometric tints" infont defaultfont scaled defaultscale rotated 90, point 7/2 of h);
    label.rt("Bathymetric tints" infont defaultfont scaled defaultscale rotated -90, point 7/2 of d);
    label.lft("sea level", point 0 of h);
    label("areas below sea level", center b);
    draw h; draw d;
endfig;
\end{mplibcode}
\end{document}