Example #1
0
def gen(triangles):
    territories = set()
    lines = set([])
    for tri in triangles:
        terr = territory.LandTerr(tri.lines)
        terr.add_triangle(tri.p1.x, tri.p1.y, tri.p2.x, tri.p2.y, tri.p3.x, tri.p3.y)
        territories.add(terr)
        lines = lines | set(tri.lines)
    new_map = skeleton.Map(lines, lines, territories, set())
    new_map.find_bounds()
    render.basic(new_map, 't.png')
Example #2
0
def save_to_image(landmass):
    render.basic(landmass, "map_temp.png", True)
    return copy_to_unique_name("map_temp.png", "map_images")
Example #3
0
def copy_to_unique_name(path, dest_dir=""):
    f = open(path)
    file_ext = os.path.splitext(path)[1]
    h = hashlib.sha1()
    h.update(f.read())
    hash = h.hexdigest()
    f.close()
    dest = os.path.join(dest_dir, hash + file_ext)
    shutil.copy(path, dest)
    return dest


def save_to_image(landmass):
    render.basic(landmass, "map_temp.png", True)
    return copy_to_unique_name("map_temp.png", "map_images")


if __name__ == "__main__":
    gen = behemoth.ContinentGenerator()
    if len(sys.argv) > 1:
        gen.base_distance = 40
        gen.verbose = False
        render.basic(gen.generate(), sys.argv[1])
        copy_to_unique_name(sys.argv[1])
        quit()
    import demo

    gen.verbose = True
    main_window = demo.MapGenWindow(gen)
Example #4
0
def make_image(territories, lines):
    new_map = skeleton.Map(lines, lines, territories, set())
    new_map.find_bounds()
    render.basic(new_map, 't2.png')