1
2
3
4
5
6
7
8
9
10
11
12
13
14if known context_fobg : endinput ; fi ;
15
16boolean context_fobg ; context_fobg := true ;
17
18FoNone := 0 ; FoHidden := 1 ; FoDotted := 2 ; FoDashed := 3 ; FoSolid := 4 ;
19FoDouble := 5 ; FoGroove := 6 ; FoRidge := 7 ; FoInset := 8 ; FoOutset := 9 ;
20FoAll := 0 ; FoTop := 1 ; FoBottom := 2 ; FoLeft := 3 ; FoRight := 4 ;
21FoMedium := .5pt ; FoThin := FoMedium2 ; FoThick := FoMedium2 ;
22
23color FoBackgroundColor, FoNoColor, FoLineColor[] ; FoNoColor := (-1,-1,-1) ;
24numeric FoLineWidth[], FoLineStyle[] ;
25boolean FoFrame, FoBackground, FoSplit ;
26
27FoFrame := FoBackground := FoSplit := false ;
28FoBackgroundColor := white ;
29FoDashFactor := .5 ;
30FoDotFactor := .375 ;
31
32for i = FoAll upto FoRight :
33 FoLineColor[i] := black ;
34 FoLineWidth[i] := .5pt ;
35 FoLineStyle[i] := FoNone ;
36endfor ;
37
38def DrawFoFrame(expr n, p) =
39 drawoptions(withcolor FoLineColor[n] withpen pencircle scaled FoLineWidth[n]) ;
40 if FoLineStyle[n] = FoNone :
41
42 elseif FoLineStyle[n] = FoHidden :
43
44 elseif FoLineStyle[n] = FoDotted :
45 draw p dashed (withdots scaled (FoDotFactorFoLineWidth[n])) ;
46 elseif FoLineStyle[n] = FoDashed :
47 draw p dashed (evenly scaled (FoDashFactorFoLineWidth[n])) ;
48 elseif FoLineStyle[n] = FoSolid :
49 draw p ;
50 elseif FoLineStyle[n] = FoDouble :
51 draw p enlarged FoLineWidth[n] ; draw p enlarged FoLineWidth[n] ;
52 elseif FoLineStyle[n] = FoGroove :
53 draw p ;
54 draw p withpen pencircle scaled .5FoLineWidth[n] withcolor (inverted FoLineColor[n] softened .5) ;
55 elseif FoLineStyle[n] = FoRidge :
56 draw p withcolor (inverted FoLineColor[n] softened .5) ;
57 draw p withpen pencircle scaled .5FoLineWidth[n] ;
58 elseif FoLineStyle[n] = FoInset :
59 draw p ; draw p inset 2.5FoLineWidth[n] ;
60 elseif FoLineStyle[n] = FoOutset :
61 draw p ; draw p outset 2.5FoLineWidth[n] ;
62 fi ;
63enddef ;
64
65primarydef p outset d =
66 ((lrcorner p -- urcorner p -- ulcorner p -- llcorner p -- cycle)
67 shifted (d(-1,1)) cutbefore topboundary p) cutafter leftboundary p
68enddef ;
69
70primarydef p inset d =
71 ((ulcorner p -- llcorner p -- lrcorner p -- urcorner p -- cycle)
72 shifted (d(1,-1)) cutbefore bottomboundary p) cutafter rightboundary p
73enddef ;
74
75vardef equalpaths(expr p, q) =
76 if length(p) = length(q) :
77 save ok ; boolean ok ; ok := true ;
78 for i = 0 upto length(p)-1 :
79 ok := ok and (round(point i of p) = round(point i of q)) ;
80 endfor ;
81 ok
82 else :
83 false
84 fi
85enddef ;
86
87endinput ;
88 |