def _get_prefab_mmap(cls):
        """
        :rtype: MuxMap
        """

        prefab_path = os.path.join(cls.MAP_PATH, cls.map_file)
        parser = MapFileObjParser(open(prefab_path, 'r'))
        return parser.get_muxmap()
示例#2
0
"""
This is an example of how to open a map file, return a MuxMap object, and
get a few values.
"""

from btmux_maplib.map import MuxMap
from btmux_maplib.img_generator.mapimage import PixelHexMapImage, HexMapImage
from btmux_maplib.map_parser.fileobj import MapFileObjParser

# Grab the example map from sample_data.
parser = MapFileObjParser(open('../sample_data/large.map', 'r'))
# This is our new MuxMap object.
the_map = parser.get_muxmap()

# Set up an image generator pointing to the map object.
img_gen = HexMapImage(the_map)
# Pixel map generator. Faster but less pretty.
#img_gen = PixelHexMapImage(the_map)

# Set the mode to elevation map.
#img_gen.set_mode("elevmap")

# Generate the PIL Image.
img_gen.generate_map(max_dimension=400)

# Open with image viewer.
img_gen.show()

# Save the image to a file.
#img.save_image("currmap.png", "PNG")
示例#3
0
"""
This is an example of how to open a map file, return a MuxMap object, and
export the map to a new file. This is equivalent to copying the file, but
provides a good example of how to export maps to MUX .map files.
"""

from btmux_maplib.map_parser.fileobj import MapFileObjParser
from btmux_maplib.map_exporters.muxmap import MuxMapExporter 

# Open the original map for reading. This can be a file object via open(), or
# something like StringIO().
parser = MapFileObjParser(open('../sample_data/sample.map', 'r'))
# Show some verbose output.
parser.debug = True
# This is our new MuxMap object.
the_map = parser.get_muxmap()
# Pass the map and a file-like object to be written to. This doesn't have
# to be done with file(), it can be something else like StringIO().
exporter = MuxMapExporter(the_map, open('sample2.map', 'w'))
# Show some verbose output.
exporter.debug = True
exporter.write()