2 %% NFPA warning triangle
4 labels := false; % turn on debugging labels
9 u := 2cm; % unit, for overall scaling
12 numeric cyl_thickness, wire_thickness;
13 border := 1pt; % thickness of the box outlines
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
23 % return a diamond path
24 vardef diamond(expr radius) =
27 P := (-radius,0) -- (0,radius) -- (radius,0) -- (0,-radius) -- cycle;
31 def NFPA(expr center, radius, h, f, r, o) =
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;
43 draw diamond(radius) shifted center withpen pencircle scaled border
46 draw p -- -p shifted center withpen pencircle scaled border
49 draw p -- -p shifted center withpen pencircle scaled border
52 label(h, center-(hr,0));
53 label(f, center+(0,hr));
54 label(r, center+(hr,0));
58 label(o, center-(0,hr));