Fission FSN
Loading...
Searching...
No Matches
Image2Map.TileMap Class Reference

Public Member Functions

 __init__ (self, file, tileX, tileY)
 parseMap (self)
 printProgress (self, percentage)
 getTileImage (self)
 printHash (self, H)
 addEdge (self, s, t, dirr)
 graphFromList (self)
 growTileMap (self, TileMap, G, posX, posY, curV)
 centerOfDictionary (self, H)
 composeDictionaries (self, H1, H2)

Public Attributes

 TileX
 TileY = tileX, tileY
 MapImage = Image.open(file)
 MapImageWidth
 MapImageHeight = self.MapImage.size
 Width
 Height = self.MapImageWidth / self.TileX, self.MapImageHeight / self.TileY
 MapList
 TileList
 TileDict = self.parseMap()
dict FullTileMap = {}
 TileImage = self.getTileImage()
 G = networkx.MultiDiGraph(selfloops = False, multiedges = True)

Detailed Description

 This class represents a map of tiles.

Constructor & Destructor Documentation

◆ __init__()

Image2Map.TileMap.__init__ ( self,
file,
tileX,
tileY )

Member Function Documentation

◆ addEdge()

Image2Map.TileMap.addEdge ( self,
s,
t,
dirr )
 This function increases abs(value) of an edge st in a graph G, taking the
    'direction' of st into account.

        s: a start vertex
        t: an end  vertex
      dir: a value depicting the st-direction,
                +1 for left -> right
                -1 for up   -> down

◆ centerOfDictionary()

Image2Map.TileMap.centerOfDictionary ( self,
H )
 Returns the center of the dictionary, that is, the average of all keys.

◆ composeDictionaries()

Image2Map.TileMap.composeDictionaries ( self,
H1,
H2 )
 This method takes two dictionaries H1, H2 that represent pieces of the
    maps of unique tiles, and pastes the second into the first, as close to
    their centers -- as close together -- as possible.

◆ getTileImage()

Image2Map.TileMap.getTileImage ( self)
 This function takes the hash of unique tiles self.FullTileMap and
    creates a tileset image from it.

◆ graphFromList()

Image2Map.TileMap.graphFromList ( self)
 This function constructs a weighted directed graph from the 
    list that depicts the map using the following scheme:
        Left A, Right B -> add (A, B, 1)
        Left B, Right A -> add (B, A, 1)
        Up   A, Down  B -> add (A, B,-1)
        Up   B, Down  A -> add (B, A,-1)
    We then add all similar edges together, so for instance
        (A, B, 1) and (A, B,  1) -> (A, B, 2)
    but *NOT*
        (A, B, 1) and (A, B, -1) -> (A, B, 0)

◆ growTileMap()

Image2Map.TileMap.growTileMap ( self,
TileMap,
G,
posX,
posY,
curV )
 This is a recursive function that arranges a map of unique tiles.

◆ parseMap()

Image2Map.TileMap.parseMap ( self)
 This function takes the map image, and obtains
    * a list TList of unique tiles.
    * a hash TDict of unique tiles.
    * a double list self.MapList of where an entry equals i if
        self.TileList[i] is the corresponding picture on the map image.

◆ printHash()

Image2Map.TileMap.printHash ( self,
H )
 This function nicely aligns dictionaries with elements of the form
    "(y, x): n" in a table, in which row y, column x has entry n.

    In this specific case (x, y) will be the tile coordinates at which
    tile n will be placed in the tile image.

◆ printProgress()

Image2Map.TileMap.printProgress ( self,
percentage )
 This function prints the percentage on the current row after erasing what is already there.

Member Data Documentation

◆ FullTileMap

dict Image2Map.TileMap.FullTileMap = {}

◆ G

Image2Map.TileMap.G = networkx.MultiDiGraph(selfloops = False, multiedges = True)

◆ Height

Image2Map.TileMap.Height = self.MapImageWidth / self.TileX, self.MapImageHeight / self.TileY

◆ MapImage

Image2Map.TileMap.MapImage = Image.open(file)

◆ MapImageHeight

Image2Map.TileMap.MapImageHeight = self.MapImage.size

◆ MapImageWidth

Image2Map.TileMap.MapImageWidth

◆ MapList

Image2Map.TileMap.MapList

◆ TileDict

Image2Map.TileMap.TileDict = self.parseMap()

◆ TileImage

Image2Map.TileMap.TileImage = self.getTileImage()

◆ TileList

Image2Map.TileMap.TileList

◆ TileX

Image2Map.TileMap.TileX

◆ TileY

Image2Map.TileMap.TileY = tileX, tileY

◆ Width

Image2Map.TileMap.Width

The documentation for this class was generated from the following file: