import os
class background_map ( gtk.gdk.Pixmap ) :
+ """Pixmap to hold a background map big enough for screen size
+The minimal pixmap is calculated to hold an integer number of tiles as large
+as required to cover the requested screen size. The number of tiles is rounded
+up to an odd number, to clearly know which one is the central tile.
+Although not strictly required for visualization, a tiles border is added,
+whose primary purpose is to keep elements drawn in the pixmap when they get
+scrolled out, to get better visualization if they are later scrolled in.
+The object also stores a reference pixel that can be retrieved with method
+get_viewport(), and gives the topleft/base pixel to extract the viewable
+area (the reference pixel is actually encapsulated in the inner tile loader).
+"""
def __init__ ( self , map_size , tileloader ) :
bordersize = 1
def index ( self , x , y ) :
return x + y * self.size[0]
+ # FIXME : This implementation does not account for the requested screen size, so don't give the right pixel
def get_viewport ( self ) :
refpix = self.tileloader.get_refpix()
return self.__vport_base[0] + refpix[0] , self.__vport_base[1] + refpix[1]