1
2
3
4
5
6
7
8
9
10
11
12
13
14if known metafun_loaded_butt : endinput ; fi ;
15
16newinternal boolean metafun_loaded_butt ; metafun_loaded_butt := true ; immutable metafun_loaded_butt ;
17
18def predefinedbutton (expr button_type, button_size, button_linecolor, button_fillcolor) =
19
20 begingroup ;
21
22 save button_linewidth, p, d, l ;
23
24 numeric button_linewidth ; button_linewidth := button_size10 ;
25
26 drawoptions (withpen pencircle scaled button_linewidth withcolor button_linecolor) ;
27
28 path p ; p := unitsquare scaled button_size ;
29 numeric d ; d := button_size ;
30 numeric l ; l := button_linewidth ;
31
32 fill p withcolor button_fillcolor ;
33 draw p ;
34
35 if button_type = 101 :
36 draw (d-2l,2l)--(2l,.5d)--(d-2l,d-2l)cycle ;
37 elseif button_type = 102 :
38 draw (2l,2l)--(d-2l,.5d)--(2l,d-2l)cycle ;
39 elseif button_type = 103 :
40 for i=2l step 2l until d-2l :
41 draw (2l,i)--(2l ,i) ;
42 draw (4l,i)--(d-2l,i) ;
43 endfor ;
44 elseif button_type = 104 :
45 for i=2l step 2l until d-2l :
46 draw (2l ,i)--(d2l,i) ;
47 draw (d2l,i)--(d-2l ,i) ;
48 endfor ;
49 elseif button_type = 105 :
50 fill fullcircle scaled (.2d) shifted (.5d,.7d) ;
51 fill fullcircle xscaled (.6d) yscaled d shifted (.5d,0) ;
52 clip currentpicture to p ;
53 draw p ;
54 elseif button_type = 106 :
55 draw (2l,2l)--(d-2l,d-2l) ;
56 draw (d-2l,2l)--(2l,d-2l) ;
57 elseif button_type = 107 :
58 p := (3l,d-2l)--(d-3l,d-2l)--(.5d,4l)cycle ;
59 fill p ; draw p ;
60 draw (.5d,2l) ;
61 elseif button_type = 108 :
62 draw (.5d,2l)--(d-2l,d-2l)--(2l,d-2l)cycle ;
63 elseif button_type = 109 :
64 draw (.5d,d-2l)--(d-2l,2l)--(2l,2l)cycle ;
65 elseif button_type = 110 :
66 button_linewidth := button_linewidth2 ;
67 draw p enlarged (-2l,l) ;
68 for i=2l step l until d-2l :
69 draw (3l,i)--(d-3l,i) ;
70 endfor ;
71 fi ;
72
73 endgroup ;
74
75enddef ;
76
77let some_button = predefinedbutton
78 |