diff options
| author | Simon Tatham <anakin@pobox.com> | 2011-04-23 11:44:43 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2011-04-23 11:44:43 +0000 |
| commit | 5e3de7d95bee214a95a01f8d16778987da75b04c (patch) | |
| tree | f86ff3511da42555f083061ab8fb3ad11f4eadbd /grid.h | |
| parent | 0a547b2451a038ab53dcb695c156070792b954c8 (diff) | |
| download | puzzles-5e3de7d95bee214a95a01f8d16778987da75b04c.zip puzzles-5e3de7d95bee214a95a01f8d16778987da75b04c.tar.gz puzzles-5e3de7d95bee214a95a01f8d16778987da75b04c.tar.bz2 puzzles-5e3de7d95bee214a95a01f8d16778987da75b04c.tar.xz | |
Move most of face_text_pos() into grid.c, leaving in loopy.c only the
part that converts from abstract grid coordinates into screen
coordinates. This should speed up window-resizing by eliminating
pointless reiteration of the complicated part of the algorithm: now
when a game_drawstate is renewed, only the conversion into screen
coordinates has to be redone.
[originally from svn r9157]
Diffstat (limited to 'grid.h')
| -rw-r--r-- | grid.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -34,6 +34,22 @@ struct grid_face { int order; /* Number of edges, also the number of dots */ grid_edge **edges; /* edges around this face */ grid_dot **dots; /* corners of this face */ + /* + * For each face, we optionally compute and store its 'incentre'. + * The incentre of a triangle is the centre of a circle tangent to + * all three edges; I generalise the concept to arbitrary polygons + * by defining it to be the centre of the largest circle you can fit + * anywhere in the polygon. It's a useful thing to know because if + * you want to draw any symbol or text in the face (e.g. clue + * numbers in Loopy), that's the place it will most easily fit. + * + * When a grid is first generated, no face has this information + * computed, because it's fiddly to do. You can call + * grid_find_incentre() on a face, and it will fill in ix,iy below + * and set has_incentre to indicate that it's done so. + */ + int has_incentre; + int ix, iy; /* incentre (centre of largest inscribed circle) */ }; struct grid_edge { grid_dot *dot1, *dot2; @@ -89,4 +105,6 @@ void grid_free(grid *g); grid_edge *grid_nearest_edge(grid *g, int x, int y); +void grid_find_incentre(grid_face *f); + #endif /* PUZZLES_GRID_H */ |