4 * The geeky little puzzle game with a big noodly crunch!
6 * gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
7 * Original Flash game by John Tantalo <john.tantalo@case.edu>
8 * Original game concept by Mary Radcliffe
10 * gPlanarity is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * gPlanarity is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Postfish; see the file COPYING. If not, write to the
22 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include "gameboard.h"
31 #include "gameboard_draw_button.h"
33 void topbox (Gameboard
*g
,cairo_t
*c
, double w
, double h
){
35 double x0
= B_BORDER
+B_RADIUS
;
39 double y1
= B_BORDER
+B_RADIUS
;
42 double y2
= h
-B_BORDER
-B_RADIUS
;
44 double x3
= B_BORDER
+B_RADIUS
;
45 double y3
= h
-B_BORDER
;
47 double x4
= w
/2 - B_HUMP
- B_RADIUS
;
48 double y4
= h
-B_BORDER
;
50 double x5
= x4
+B_RADIUS
;
54 double x7
= w
/2 + B_HUMP
+ B_RADIUS
;
55 double y7
= h
-B_BORDER
;
57 double x8
= w
- B_BORDER
-B_RADIUS
;
58 double y8
= h
-B_BORDER
;
60 double x9
= w
- B_BORDER
;
61 double y9
= h
-B_BORDER
-B_RADIUS
;
63 double x10
= w
- B_BORDER
;
64 double y10
= B_BORDER
+B_RADIUS
;
66 double x11
= w
- B_BORDER
-B_RADIUS
;
67 double y11
= B_BORDER
;
69 cairo_set_line_width(c
,B_LINE
);
71 cairo_move_to (c
, x0
, y0
);
72 cairo_curve_to (c
, x1
,y0
, x1
,y0
, x1
,y1
);
73 cairo_line_to (c
, x2
,y2
);
74 cairo_curve_to (c
, x2
,y3
, x2
,y3
, x3
,y3
);
75 cairo_line_to (c
, x4
,y4
);
78 double hh
= g
->g
.orig_height
*.5+50;
80 double radius
= sqrt( (w
*.5-x5
) * (w
*.5-x5
) + (hh
-y5
) * (hh
-y5
));
81 double siderad
= atan( (x5
-w
*.5)/(hh
-y5
));
83 double xx
= sin(siderad
+.05)*radius
+w
*.5;
84 double yy
= -cos(siderad
+.05)*radius
+hh
;
85 double x
= sin(siderad
+.1)*radius
+w
*.5;
86 double y
= -cos(siderad
+.1)*radius
+hh
;
88 cairo_curve_to (c
, x4
+B_RADIUS
,y4
, xx
,yy
, x
,y
);
89 cairo_arc(c
,w
*.5,hh
,radius
,-M_PI
*.5+siderad
+.1,-M_PI
*.5-siderad
-.1);
91 xx
= -sin(siderad
+.05)*radius
+w
*.5;
92 yy
= -cos(siderad
+.05)*radius
+hh
;
93 xx
= -sin(siderad
+.1)*radius
+w
*.5;
94 yy
= -cos(siderad
+.1)*radius
+hh
;
96 cairo_curve_to (c
, xx
,yy
, x7
-B_RADIUS
,y7
, x7
,y7
);
100 cairo_line_to (c
, x8
,y8
);
101 cairo_curve_to (c
, x9
,y8
, x9
,y8
, x9
,y9
);
102 cairo_line_to (c
, x10
,y10
);
103 cairo_curve_to (c
, x10
,y11
, x10
,y11
, x11
,y11
);
104 cairo_close_path (c
);
106 cairo_set_source_rgba (c
, B_COLOR
);
107 cairo_fill_preserve (c
);
108 cairo_set_source_rgba (c
, B_LINE_COLOR
);
113 void bottombox (Gameboard
*g
, cairo_t
*c
, double w
, double h
){
115 double x0
= B_BORDER
+B_RADIUS
;
116 double y0
= h
-B_BORDER
;
118 double x1
= B_BORDER
;
119 double y1
= h
-B_BORDER
-B_RADIUS
;
121 double x2
= B_BORDER
;
122 double y2
= B_BORDER
+B_RADIUS
;
124 double x3
= B_BORDER
+B_RADIUS
;
125 double y3
= B_BORDER
;
127 double x4
= w
/2 - B_HUMP
- B_RADIUS
;
128 double y4
= B_BORDER
;
130 double x5
= x4
+B_RADIUS
;
134 double x7
= w
/2 + B_HUMP
+ B_RADIUS
;
135 double y7
= B_BORDER
;
137 double x8
= w
- B_BORDER
-B_RADIUS
;
138 double y8
= B_BORDER
;
140 double x9
= w
- B_BORDER
;
141 double y9
= B_BORDER
+B_RADIUS
;
143 double x10
= w
- B_BORDER
;
144 double y10
= h
- B_BORDER
-B_RADIUS
;
146 double x11
= w
- B_BORDER
-B_RADIUS
;
147 double y11
= h
-B_BORDER
;
149 cairo_set_line_width(c
,B_LINE
);
151 cairo_move_to (c
, x0
, y0
);
152 cairo_curve_to (c
, x1
,y0
, x1
,y0
, x1
,y1
);
153 cairo_line_to (c
, x2
,y2
);
154 cairo_curve_to (c
, x2
,y3
, x2
,y3
, x3
,y3
);
155 cairo_line_to (c
, x4
,y4
);
158 double hh
= g
->g
.orig_height
*.5+50;
160 double radius
= sqrt( (w
*.5-x5
) * (w
*.5-x5
) + (y5
+hh
-h
) * (y5
+hh
-h
));
161 double siderad
= atan( (x5
-w
*.5)/(y5
+hh
-h
));
163 double xx
= sin(siderad
+.05)*radius
+w
*.5;
164 double yy
= cos(siderad
+.05)*radius
-hh
+h
;
165 double x
= sin(siderad
+.1)*radius
+w
*.5;
166 double y
= cos(siderad
+.1)*radius
-hh
+h
;
168 cairo_curve_to (c
, x4
+B_RADIUS
,y4
, xx
,yy
, x
,y
);
169 cairo_arc_negative(c
,w
*.5,h
-hh
,radius
,M_PI
*.5-siderad
-.1,M_PI
*.5+siderad
+.1);
171 xx
= -sin(siderad
+.05)*radius
+w
*.5;
172 yy
= cos(siderad
+.05)*radius
-hh
+h
;
173 xx
= -sin(siderad
+.1)*radius
+w
*.5;
174 yy
= cos(siderad
+.1)*radius
-hh
+h
;
176 cairo_curve_to (c
, xx
,yy
, x7
-B_RADIUS
,y7
, x7
,y7
);
180 cairo_line_to (c
, x8
,y8
);
181 cairo_curve_to (c
, x9
,y8
, x9
,y8
, x9
,y9
);
182 cairo_line_to (c
, x10
,y10
);
183 cairo_curve_to (c
, x10
,y11
, x10
,y11
, x11
,y11
);
184 cairo_close_path (c
);
186 cairo_set_source_rgba (c
, B_COLOR
);
187 cairo_fill_preserve (c
);
188 cairo_set_source_rgba (c
, B_LINE_COLOR
);
193 void centerbox (cairo_t
*c
, int x
, int y
, double w
, double h
){
195 double x0
= B_BORDER
+B_RADIUS
;
196 double y0
= h
-B_BORDER
;
198 double x1
= B_BORDER
;
199 double y1
= h
-B_BORDER
-B_RADIUS
;
201 double x2
= B_BORDER
;
202 double y2
= B_BORDER
+B_RADIUS
;
204 double x3
= B_BORDER
+B_RADIUS
;
205 double y3
= B_BORDER
;
207 double x8
= w
- B_BORDER
-B_RADIUS
;
208 double y8
= B_BORDER
;
210 double x9
= w
- B_BORDER
;
211 double y9
= B_BORDER
+B_RADIUS
;
213 double x10
= w
- B_BORDER
;
214 double y10
= h
- B_BORDER
-B_RADIUS
;
216 double x11
= w
- B_BORDER
-B_RADIUS
;
217 double y11
= h
-B_BORDER
;
220 cairo_translate(c
,x
,y
);
221 cairo_set_line_width(c
,B_LINE
);
223 cairo_move_to (c
, x0
, y0
);
224 cairo_curve_to (c
, x1
,y0
, x1
,y0
, x1
,y1
);
225 cairo_line_to (c
, x2
,y2
);
226 cairo_curve_to (c
, x2
,y3
, x2
,y3
, x3
,y3
);
227 cairo_line_to (c
, x8
,y8
);
228 cairo_curve_to (c
, x9
,y8
, x9
,y8
, x9
,y9
);
229 cairo_line_to (c
, x10
,y10
);
230 cairo_curve_to (c
, x10
,y11
, x10
,y11
, x11
,y11
);
231 cairo_close_path (c
);
233 cairo_set_source_rgba (c
, B_COLOR
);
234 cairo_fill_preserve (c
);
235 cairo_set_source_rgba (c
, B_LINE_COLOR
);
241 void borderbox_path (cairo_t
*c
, double x
, double y
, double w
, double h
){
243 double x0
= x
+ B_RADIUS
;
247 double y1
= y
+ h
-B_RADIUS
;
250 double y2
= y
+ B_RADIUS
;
252 double x3
= x
+ B_RADIUS
;
255 double x8
= x
+ w
-B_RADIUS
;
259 double y9
= y
+ B_RADIUS
;
262 double y10
= y
+ h
-B_RADIUS
;
264 double x11
= x
+ w
-B_RADIUS
;
267 cairo_move_to (c
, x0
, y0
);
268 cairo_curve_to (c
, x1
,y0
, x1
,y0
, x1
,y1
);
269 cairo_line_to (c
, x2
,y2
);
270 cairo_curve_to (c
, x2
,y3
, x2
,y3
, x3
,y3
);
271 cairo_line_to (c
, x8
,y8
);
272 cairo_curve_to (c
, x9
,y8
, x9
,y8
, x9
,y9
);
273 cairo_line_to (c
, x10
,y10
);
274 cairo_curve_to (c
, x10
,y11
, x10
,y11
, x11
,y11
);
275 cairo_close_path (c
);