Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] Re: (PR#4004) A canvas_iterate macro for mapview
Home

[Freeciv-Dev] Re: (PR#4004) A canvas_iterate macro for mapview

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4004) A canvas_iterate macro for mapview
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Thu, 17 Apr 2003 11:28:07 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Tue, 15 Apr 2003, Jason Short wrote:

> rwetmore@xxxxxxxxxxxx wrote:
> > Using citymap_checked_iterate as the template ...
> > 
> > #define canvas_checked_iterate(x0, y0, dx. dy, cx, cy, mx, my)  \
> > {  int cx, cy, mx, my;                                          \
> >     for (cy = y0; cy < y0+dy; cy += NORMAL_TILE_HEIGHT)          \
> >     for (cx = x0; cx < x0+dx; cx += NORMAL_TILE_WIDTH) {         \
> >       if (canvas_to_map_pos(&mx, &my, cx, cy)) {
> > 
> > #define canvas_checked_iterate_end                              \
> >       }                                                          \
> >     }                                                            \
> > }
> 
> This is a great example of a nice, clean implementation that just won't 
> work.
> 
> 1.  In iso-view there are additional map positions on the half-tile.  So 
> a native-style loop (like is used in show_city_descriptions) would be 
> helpful.
> 
> 2.  We need to catch all tiles that overlap the area.  Even in non-iso 
> view you need to consider the case where (x0,y0) does not mark a tile 
> origin.  In iso-view it becomes quite a bit more complicated since the 
> tiles are aligned isometrically, and you need to account for the extra 
> UNIT_TILE_HEIGHT area (which is one reason why having a draw_type 
> parameter would be helpful - to allow the users to filter out unwanted 
> tiles).

I drew a couple of iso example on a piece of paper and I think that
"catching all tiles that overlap" can produce rather strange shapes.  I
think "all tiles whose centers are in the rectangle" is both nicer 
visually and easier to implement.

G.





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