~ubuntu-branches/ubuntu/saucy/sgt-puzzles/saucy

« back to all changes in this revision

Viewing changes to grid.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings
  • Date: 2011-07-11 03:56:55 UTC
  • mfrom: (1.2.10 upstream)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20110711035655-qjakg0h7wv99tmu9
* New upstream version:
  - Remove unused-but-set variables - closes: #625425
  - Avoid infinite loop in Loopy at Easy level
  - Add Penrose tilings to Loopy
* Update German translation, thanks to Helge Kreutzmann
* Do not compile with -Werror

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#ifndef PUZZLES_GRID_H
10
10
#define PUZZLES_GRID_H
11
11
 
 
12
#include "puzzles.h" /* for random_state */
 
13
 
12
14
/* Useful macros */
13
15
#define SQ(x) ( (x) * (x) )
14
16
 
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 */
 
39
  /*
 
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.
 
47
   *
 
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.
 
52
   */
 
53
  int has_incentre;
 
54
  int ix, iy;      /* incentre (centre of largest inscribed circle) */
37
55
};
38
56
struct grid_edge {
39
57
  grid_dot *dot1, *dot2;
73
91
  int refcount;
74
92
} grid;
75
93
 
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. */
 
95
 
 
96
#define GRIDGEN_LIST(A) \
 
97
  A(SQUARE,square) \
 
98
  A(HONEYCOMB,honeycomb) \
 
99
  A(TRIANGULAR,triangular) \
 
100
  A(SNUBSQUARE,snubsquare) \
 
101
  A(CAIRO,cairo) \
 
102
  A(GREATHEXAGONAL,greathexagonal) \
 
103
  A(OCTAGONAL,octagonal) \
 
104
  A(KITE,kites) \
 
105
  A(FLORET,floret) \
 
106
  A(DODECAGONAL,dodecagonal) \
 
107
  A(GREATDODECAGONAL,greatdodecagonal) \
 
108
  A(PENROSE_P2,penrose_p2_kite) \
 
109
  A(PENROSE_P3,penrose_p3_thick)
 
110
 
 
111
#define ENUM(upper,lower) GRID_ ## upper,
 
112
typedef enum grid_type { GRIDGEN_LIST(ENUM) GRID_TYPE_MAX } grid_type;
 
113
#undef ENUM
 
114
 
 
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);
 
119
 
 
120
grid *grid_new(grid_type type, int width, int height, char *desc);
87
121
 
88
122
void grid_free(grid *g);
89
123
 
90
124
grid_edge *grid_nearest_edge(grid *g, int x, int y);
91
125
 
 
126
void grid_compute_size(grid_type type, int width, int height,
 
127
                       int *tilesize, int *xextent, int *yextent);
 
128
 
 
129
void grid_find_incentre(grid_face *f);
 
130
 
92
131
#endif /* PUZZLES_GRID_H */