34
36
int order; /* Number of edges, also the number of dots */
35
37
grid_edge **edges; /* edges around this face */
36
38
grid_dot **dots; /* corners of this face */
40
* For each face, we optionally compute and store its 'incentre'.
41
* The incentre of a triangle is the centre of a circle tangent to
42
* all three edges; I generalise the concept to arbitrary polygons
43
* by defining it to be the centre of the largest circle you can fit
44
* anywhere in the polygon. It's a useful thing to know because if
45
* you want to draw any symbol or text in the face (e.g. clue
46
* numbers in Loopy), that's the place it will most easily fit.
48
* When a grid is first generated, no face has this information
49
* computed, because it's fiddly to do. You can call
50
* grid_find_incentre() on a face, and it will fill in ix,iy below
51
* and set has_incentre to indicate that it's done so.
54
int ix, iy; /* incentre (centre of largest inscribed circle) */
39
57
grid_dot *dot1, *dot2;
76
grid *grid_new_square(int width, int height);
77
grid *grid_new_honeycomb(int width, int height);
78
grid *grid_new_triangular(int width, int height);
79
grid *grid_new_snubsquare(int width, int height);
80
grid *grid_new_cairo(int width, int height);
81
grid *grid_new_greathexagonal(int width, int height);
82
grid *grid_new_octagonal(int width, int height);
83
grid *grid_new_kites(int width, int height);
84
grid *grid_new_floret(int width, int height);
85
grid *grid_new_dodecagonal(int width, int height);
86
grid *grid_new_greatdodecagonal(int width, int height);
94
/* Grids are specified by type: GRID_SQUARE, GRID_KITE, etc. */
96
#define GRIDGEN_LIST(A) \
98
A(HONEYCOMB,honeycomb) \
99
A(TRIANGULAR,triangular) \
100
A(SNUBSQUARE,snubsquare) \
102
A(GREATHEXAGONAL,greathexagonal) \
103
A(OCTAGONAL,octagonal) \
106
A(DODECAGONAL,dodecagonal) \
107
A(GREATDODECAGONAL,greatdodecagonal) \
108
A(PENROSE_P2,penrose_p2_kite) \
109
A(PENROSE_P3,penrose_p3_thick)
111
#define ENUM(upper,lower) GRID_ ## upper,
112
typedef enum grid_type { GRIDGEN_LIST(ENUM) GRID_TYPE_MAX } grid_type;
115
/* Free directly after use if non-NULL. Will never contain an underscore
116
* (so clients can safely use that as a separator). */
117
char *grid_new_desc(grid_type type, int width, int height, random_state *rs);
118
char *grid_validate_desc(grid_type type, int width, int height, char *desc);
120
grid *grid_new(grid_type type, int width, int height, char *desc);
88
122
void grid_free(grid *g);
90
124
grid_edge *grid_nearest_edge(grid *g, int x, int y);
126
void grid_compute_size(grid_type type, int width, int height,
127
int *tilesize, int *xextent, int *yextent);
129
void grid_find_incentre(grid_face *f);
92
131
#endif /* PUZZLES_GRID_H */