mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 15:41:30 -07:00
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]
This commit is contained in:
18
grid.h
18
grid.h
@ -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 */
|
||||
|
Reference in New Issue
Block a user