Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] Re: (PR#3924) Bugfix for map/canvas coordination functions
Home

[Freeciv-Dev] Re: (PR#3924) Bugfix for map/canvas coordination functions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: a-l@xxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3924) Bugfix for map/canvas coordination functions
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 6 Apr 2003 23:24:48 -0700
Reply-to: rt@xxxxxxxxxxxxxx

a-l@xxxxxxx wrote:

> Yes, let's define the tile origin as the upper left corner of the draw
> bounding box. This is what map_to_canvas_pos() yields. I have verified
> that the above is true for non-iso by singel pixel iteration.
> Obviously it's not true for the diamond-shaped tiles; but the
> definition of the center of a tile should hold, always. I added a
> header comment.

Nice idea.

> --- cvs-Apr-04/client/mapview_common.c        Mon Apr  7 00:01:35 2003
> +++ comment/client/mapview_common.c   Mon Apr  7 00:09:22 2003
> @@ -149,8 +149,23 @@
>  
>  /**************************************************************************
>    Finds the pixel coordinates of a tile.  Beside setting the results
> -  in canvas_x,canvas_y it returns whether the tile is inside the
> -  visible map.
> +  in canvas_x, canvas_y it returns whether the tile is inside the
> +  visible map. The result represents the upper left pixel of the
> +  bounding draw box, which is always rectangular. Depending on map
> +  topology, this result may not always yield the same tile when sent
> +  to the reverse function without adjustment.
> +
> +  The center of a tile is defined as:
> +  {
> +    map_to_canvas_pos(&canvas_x, &canvas_y, map_x, map_y);
> +    canvas_x += NORMAL_TILE_WIDTH / 2;
> +    canvas_y += NORMAL_TILE_HEIGHT / 2;
> +  }
> +
> +  This pixel is one position closer to the lower right, which may be
> +  important to remember when doing some round-off operations. Other
> +  parts of the code assert NORMAL_TILE_WIDTH and NORMAL_TILE_HEIGHT
> +  to be even numbers.
>  **************************************************************************/
>  bool map_to_canvas_pos(int *canvas_x, int *canvas_y, int map_x, int map_y)
>  {

Make sure you understand the difference between GUI topology and map 
topology.  Currently we have iso-view, but not iso-maps.  So where you 
say "map topology" above you really mean "GUI topology" or "which view 
the GUI is using".

jason




[Prev in Thread] Current Thread [Next in Thread]