Skip to content

Commit 1d563eb

Browse files
ftomassettipsi29a
authored andcommitted
Improve ancient map operation
1 parent e18328d commit 1d563eb

File tree

4 files changed

+342
-220
lines changed

4 files changed

+342
-220
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ nosetests.xml
4747
*.world
4848

4949
generator.spec
50-
winbuild
50+
*.orig
51+
*.rej

worldengine/cli/main.py

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ def check_step(step_name):
120120
return step
121121

122122

123-
def operation_ancient_map(world, map_filename, resize_factor, sea_color):
124-
draw_ancientmap_on_file(world, map_filename, resize_factor, sea_color)
123+
def operation_ancient_map(world, map_filename, resize_factor, sea_color, draw_biome, draw_rivers, draw_mountains,
124+
draw_outer_land_border):
125+
draw_ancientmap_on_file(world, map_filename, resize_factor, sea_color, draw_biome, draw_rivers, draw_mountains,
126+
draw_outer_land_border)
125127
print("+ ancient map generated in '%s'" % map_filename)
126128

127129

@@ -307,6 +309,23 @@ def main():
307309
g_ancient_map.add_option('--sea_color', dest='sea_color',
308310
help="string for color [" + SEA_COLORS + "]",
309311
metavar="S", default="brown")
312+
g_ancient_map.add_option('--not-draw-biome', dest='draw_biome',
313+
action="store_false",
314+
help="Not draw biome",
315+
default=True)
316+
g_ancient_map.add_option('--not-draw-mountains', dest='draw_mountains',
317+
action="store_false",
318+
help="Not draw mountains",
319+
default=True)
320+
g_ancient_map.add_option('--not-draw-rivers', dest='draw_rivers',
321+
action="store_false",
322+
help="Not draw rivers",
323+
default=True)
324+
g_ancient_map.add_option('--draw-outer-border', dest='draw_outer_border',
325+
action="store_true",
326+
help="Draw outer land border",
327+
default=False)
328+
310329
# TODO: allow for RGB specification as [r g b], ie [0.5 0.5 0.5] for gray
311330
parser.add_option_group(g_ancient_map)
312331

@@ -397,9 +416,14 @@ def main():
397416
else:
398417
print(' (no rivers map)')
399418
if operation == 'ancient_map':
400-
print(' resize factor : %i' % options.resize_factor)
401-
print(' world file : %s' % options.world_file)
402-
print(' sea color : %s' % options.sea_color)
419+
print(' resize factor : %i' % options.resize_factor)
420+
print(' world file : %s' % options.world_file)
421+
print(' sea color : %s' % options.sea_color)
422+
print(' draw biome : %s' % options.draw_biome)
423+
print(' draw rivers : %s' % options.draw_rivers)
424+
print(' draw mountains : %s' % options.draw_mountains)
425+
print(' draw land outer border : %s' % options.draw_outer_border)
426+
403427

404428
set_verbose(options.verbose)
405429

@@ -446,7 +470,9 @@ def main():
446470
if not options.generated_file:
447471
options.generated_file = "ancient_map_%s.png" % world.name
448472
operation_ancient_map(world, options.generated_file,
449-
options.resize_factor, sea_color)
473+
options.resize_factor, sea_color,
474+
options.draw_biome, options.draw_rivers,
475+
options.draw_mountains, options.draw_outer_border)
450476
elif operation == 'info':
451477
world = load_world(args[1])
452478
print_world_info(world)
@@ -463,7 +489,7 @@ def usage(error=None):
463489
print(' Federico Tomassetti and Bret Curtis, 2011-2015')
464490
print(' Worldengine - a world generator (v. %s)' % VERSION)
465491
print(' ')
466-
print(' generator <world_name> [operation] [options]')
492+
print(' worldengine <world_name> [operation] [options]')
467493
print(' possible operations: %s' % OPERATIONS)
468494
print(' use -h to see options')
469495
print(

worldengine/draw.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,12 @@ def draw_biome_on_file(world, filename):
431431

432432

433433
def draw_ancientmap_on_file(world, filename, resize_factor=1,
434-
sea_color=(212, 198, 169, 255), verbose=False):
434+
sea_color=(212, 198, 169, 255),
435+
draw_biome=True, draw_rivers=True, draw_mountains=True,
436+
draw_outer_land_border=False, verbose=False):
435437
img = ImagePixelSetter(world.width * resize_factor,
436438
world.height * resize_factor, filename)
437-
draw_ancientmap(world, img, resize_factor, sea_color, verbose)
439+
draw_ancientmap(world, img, resize_factor, sea_color,
440+
draw_biome, draw_rivers, draw_mountains, draw_outer_land_border,
441+
verbose)
438442
img.complete()

0 commit comments

Comments
 (0)