|
Fission FSN
|
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) | |
This class represents a map of tiles.
| Image2Map.TileMap.__init__ | ( | self, | |
| file, | |||
| tileX, | |||
| tileY ) |
| 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
| Image2Map.TileMap.centerOfDictionary | ( | self, | |
| H ) |
Returns the center of the dictionary, that is, the average of all keys.
| 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.
| Image2Map.TileMap.getTileImage | ( | self | ) |
This function takes the hash of unique tiles self.FullTileMap and
creates a tileset image from it.
| 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)
| Image2Map.TileMap.growTileMap | ( | self, | |
| TileMap, | |||
| G, | |||
| posX, | |||
| posY, | |||
| curV ) |
This is a recursive function that arranges a map of unique tiles.
| 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.
| 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.
| Image2Map.TileMap.printProgress | ( | self, | |
| percentage ) |
This function prints the percentage on the current row after erasing what is already there.
| dict Image2Map.TileMap.FullTileMap = {} |
| Image2Map.TileMap.G = networkx.MultiDiGraph(selfloops = False, multiedges = True) |
| Image2Map.TileMap.Height = self.MapImageWidth / self.TileX, self.MapImageHeight / self.TileY |
| Image2Map.TileMap.MapImage = Image.open(file) |
| Image2Map.TileMap.MapImageHeight = self.MapImage.size |
| Image2Map.TileMap.MapImageWidth |
| Image2Map.TileMap.MapList |
| Image2Map.TileMap.TileDict = self.parseMap() |
| Image2Map.TileMap.TileImage = self.getTileImage() |
| Image2Map.TileMap.TileList |
| Image2Map.TileMap.TileX |
| Image2Map.TileMap.Width |