Skip to content

Commit

Permalink
Improve ancient map operation
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti authored and psi29a committed Jun 30, 2015
1 parent e18328d commit 1d563eb
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 220 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -47,4 +47,5 @@ nosetests.xml
*.world

generator.spec
winbuild
*.orig
*.rej
40 changes: 33 additions & 7 deletions worldengine/cli/main.py
Expand Up @@ -120,8 +120,10 @@ def check_step(step_name):
return step


def operation_ancient_map(world, map_filename, resize_factor, sea_color):
draw_ancientmap_on_file(world, map_filename, resize_factor, sea_color)
def operation_ancient_map(world, map_filename, resize_factor, sea_color, draw_biome, draw_rivers, draw_mountains,
draw_outer_land_border):
draw_ancientmap_on_file(world, map_filename, resize_factor, sea_color, draw_biome, draw_rivers, draw_mountains,
draw_outer_land_border)
print("+ ancient map generated in '%s'" % map_filename)


Expand Down Expand Up @@ -307,6 +309,23 @@ def main():
g_ancient_map.add_option('--sea_color', dest='sea_color',
help="string for color [" + SEA_COLORS + "]",
metavar="S", default="brown")
g_ancient_map.add_option('--not-draw-biome', dest='draw_biome',
action="store_false",
help="Not draw biome",
default=True)
g_ancient_map.add_option('--not-draw-mountains', dest='draw_mountains',
action="store_false",
help="Not draw mountains",
default=True)
g_ancient_map.add_option('--not-draw-rivers', dest='draw_rivers',
action="store_false",
help="Not draw rivers",
default=True)
g_ancient_map.add_option('--draw-outer-border', dest='draw_outer_border',
action="store_true",
help="Draw outer land border",
default=False)

# TODO: allow for RGB specification as [r g b], ie [0.5 0.5 0.5] for gray
parser.add_option_group(g_ancient_map)

Expand Down Expand Up @@ -397,9 +416,14 @@ def main():
else:
print(' (no rivers map)')
if operation == 'ancient_map':
print(' resize factor : %i' % options.resize_factor)
print(' world file : %s' % options.world_file)
print(' sea color : %s' % options.sea_color)
print(' resize factor : %i' % options.resize_factor)
print(' world file : %s' % options.world_file)
print(' sea color : %s' % options.sea_color)
print(' draw biome : %s' % options.draw_biome)
print(' draw rivers : %s' % options.draw_rivers)
print(' draw mountains : %s' % options.draw_mountains)
print(' draw land outer border : %s' % options.draw_outer_border)


set_verbose(options.verbose)

Expand Down Expand Up @@ -446,7 +470,9 @@ def main():
if not options.generated_file:
options.generated_file = "ancient_map_%s.png" % world.name
operation_ancient_map(world, options.generated_file,
options.resize_factor, sea_color)
options.resize_factor, sea_color,
options.draw_biome, options.draw_rivers,
options.draw_mountains, options.draw_outer_border)
elif operation == 'info':
world = load_world(args[1])
print_world_info(world)
Expand All @@ -463,7 +489,7 @@ def usage(error=None):
print(' Federico Tomassetti and Bret Curtis, 2011-2015')
print(' Worldengine - a world generator (v. %s)' % VERSION)
print(' ')
print(' generator <world_name> [operation] [options]')
print(' worldengine <world_name> [operation] [options]')
print(' possible operations: %s' % OPERATIONS)
print(' use -h to see options')
print(
Expand Down
8 changes: 6 additions & 2 deletions worldengine/draw.py
Expand Up @@ -431,8 +431,12 @@ def draw_biome_on_file(world, filename):


def draw_ancientmap_on_file(world, filename, resize_factor=1,
sea_color=(212, 198, 169, 255), verbose=False):
sea_color=(212, 198, 169, 255),
draw_biome=True, draw_rivers=True, draw_mountains=True,
draw_outer_land_border=False, verbose=False):
img = ImagePixelSetter(world.width * resize_factor,
world.height * resize_factor, filename)
draw_ancientmap(world, img, resize_factor, sea_color, verbose)
draw_ancientmap(world, img, resize_factor, sea_color,
draw_biome, draw_rivers, draw_mountains, draw_outer_land_border,
verbose)
img.complete()

0 comments on commit 1d563eb

Please sign in to comment.