Repository created.
[chemdb.git] / docs / mp / NFPA_c.mp
1
2 %% NFPA warning triangle
3 boolean labels;
4 labels := false;             % turn on debugging labels
5
6 % sizing
7 numeric u;
8
9 u := 2cm;               % unit, for overall scaling
10
11 % line thicknesses
12 numeric cyl_thickness, wire_thickness;
13 border := 1pt;  % thickness of the box outlines
14
15 % colors
16 color hcolor, fcolor, rcolor, ocolor, bcolor;
17 hcolor := (0,0,1); % health
18 fcolor := (1,0,0); % fire
19 rcolor := (1,1,0); % reactivity
20 ocolor := white;   % other
21 bcolor := black;   % border
22
23 % return a diamond path
24 vardef diamond(expr radius) =
25   save P;
26   path P;
27   P := (-radius,0) -- (0,radius) -- (radius,0) -- (0,-radius) -- cycle;
28   P
29 enddef;
30
31 def NFPA(expr center, radius, h, f, r, o) =
32   save p, hr, qr;
33   pair p;
34   numeric hr, hr;
35   hr := radius/2;
36   qr := radius/4;
37   % draw the background colors
38   fill diamond(hr) shifted (center-(hr,0)) withcolor hcolor;
39   fill diamond(hr) shifted (center+(0,hr)) withcolor fcolor;
40   fill diamond(hr) shifted (center+(hr,0)) withcolor rcolor;
41   fill diamond(hr) shifted (center-(0,hr)) withcolor ocolor;
42   % draw the borders
43   draw diamond(radius) shifted center withpen pencircle scaled border
44                                       withcolor bcolor;
45   p := (hr,hr);
46   draw p -- -p shifted center         withpen pencircle scaled border
47                                       withcolor bcolor;
48   p := (hr,-hr);
49   draw p -- -p shifted center         withpen pencircle scaled border
50                                       withcolor bcolor;
51   % add the text
52   label(h, center-(hr,0));
53   label(f, center+(0,hr));
54   label(r, center+(hr,0));
55   % btex 4 etex,
56   % btex ox etex;
57   % btex \sout{W} etex;
58   label(o, center-(0,hr));
59 enddef;
60
61 beginfig(1)
62   NFPA(origin, u,
63     h,
64     f,
65     r,
66     o);
67
68 endfig;
69
70 end