[Freeciv-Dev] Re: (PR#6356) move the origin tile of the mapview
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Jason Short wrote:
> The form that makes topology compatability easiest has the top-left
> corner of the bounding box of the x0,y0 tile at (0,0). Now we can align
> both left and top sides of the mapview with a non-wrapping iso-map. See
> new.png (sent to RT separately).
Patch attached.
Note that it is easy to verify that this patch works. The only two
places that need changing are map_to_canvas_pos and canvas_to_map_pos.
Just click around (middle-click) on various places on each tile and it's
obvious that the two operations are inverses.
jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.63
diff -u -r1.63 mapview_common.c
--- client/mapview_common.c 2003/10/01 10:30:56 1.63
+++ client/mapview_common.c 2003/10/01 18:57:34
@@ -218,12 +218,10 @@
/*
* As the above picture shows, each isometric-coordinate unit
* corresponds to a half-tile on the canvas. Since the (x0, y0)
- * tile actually has its top corner (of the diamond-shaped tile)
- * located right at the corner of the canvas, to find the top-left
- * corner of the surrounding rectangle we must subtract off an
- * additional half-tile in the X direction.
+ * tile has its top-left corner located right at the corner of the
+ * canvas, the math is easy.
*/
- *canvas_x = (iso_x - 1) * NORMAL_TILE_WIDTH / 2;
+ *canvas_x = iso_x * NORMAL_TILE_WIDTH / 2;
*canvas_y = iso_y * NORMAL_TILE_HEIGHT / 2;
} else { /* is_isometric */
*canvas_x = map_x - mapview_canvas.map_x0;
@@ -276,8 +274,13 @@
* only use integer math, and C integer division rounds toward zero
* instead of rounding down.
*
+ * canvas_x is translated so that the top corner of the origin tile
+ * will be at (0,0). This means the origin is the top-leftmost tile
+ * that is fully shown on the canvas.
+ *
* For another example of this math, see canvas_to_city_pos().
*/
+ canvas_x -= NORMAL_TILE_WIDTH / 2;
*map_x = DIVIDE(canvas_x * H + canvas_y * W, W * H);
*map_y = DIVIDE(canvas_y * W - canvas_x * H, W * H);
} else { /* is_isometric */
|
|