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.
29 #include <gtk/gtkmain.h>
37 #include "gameboard.h"
40 /******** draw edges ********************************************/
42 void setup_background_edge(cairo_t
*c
){
43 cairo_set_line_width(c
,E_LINE
);
44 cairo_set_source_rgba(c
,E_LINE_B_COLOR
);
47 void setup_foreground_edge(cairo_t
*c
){
48 cairo_set_line_width(c
,E_LINE
);
49 cairo_set_source_rgba(c
,E_LINE_F_COLOR
);
52 void draw_edge(cairo_t
*c
,edge
*e
){
53 cairo_move_to(c
,e
->A
->x
,e
->A
->y
);
54 cairo_line_to(c
,e
->B
->x
,e
->B
->y
);
57 void finish_edge(cairo_t
*c
){
61 void draw_edges(cairo_t
*c
, vertex
*v
, int offx
, int offy
){
63 edge_list
*el
=v
->edges
;
67 if(e
->A
->grabbed
==0 || e
->B
->grabbed
==0 || v
==e
->A
){
69 cairo_move_to(c
,e
->A
->x
+offx
,e
->A
->y
+offy
);
71 cairo_move_to(c
,e
->A
->x
,e
->A
->y
);
74 cairo_line_to(c
,e
->B
->x
+offx
,e
->B
->y
+offy
);
76 cairo_line_to(c
,e
->B
->x
,e
->B
->y
);
83 /* invalidate edge region for efficient expose *******************/
85 void invalidate_edges(GtkWidget
*widget
, vertex
*v
, int offx
, int offy
){
89 edge_list
*el
=v
->edges
;
93 if(e
->A
->grabbed
==0 || e
->B
->grabbed
==0 || v
==e
->A
){
94 int Ax
= e
->A
->x
+ (e
->A
->grabbed
?offx
:0);
95 int Ay
= e
->A
->y
+ (e
->A
->grabbed
?offy
:0);
96 int Bx
= e
->B
->x
+ (e
->B
->grabbed
?offx
:0);
97 int By
= e
->B
->y
+ (e
->B
->grabbed
?offy
:0);
99 r
.x
= min(Ax
,Bx
) - E_LINE
;
100 r
.y
= min(Ay
,By
) - E_LINE
;
101 r
.width
= labs(Bx
- Ax
) + 1 + E_LINE
*2;
102 r
.height
= labs(By
- Ay
) + 1 + E_LINE
*2;
104 gdk_window_invalidate_rect (widget
->window
, &r
, FALSE
);