Пример #1
0
def main(blessed_images_dir, tests_data_dir):
    w = World.open_protobuf("%s/seed_28070.world" % tests_data_dir)
    draw_simple_elevation_on_file(
        w, "%s/simple_elevation_28070.png" % blessed_images_dir, w.sea_level())
    draw_elevation_on_file(w,
                           "%s/elevation_28070_shadow.png" %
                           blessed_images_dir,
                           shadow=True)
    draw_elevation_on_file(w,
                           "%s/elevation_28070_no_shadow.png" %
                           blessed_images_dir,
                           shadow=False)
    draw_riversmap_on_file(w, "%s/riversmap_28070.png" % blessed_images_dir)
    draw_grayscale_heightmap_on_file(
        w, "%s/grayscale_heightmap_28070.png" % blessed_images_dir)
    draw_ocean_on_file(w.ocean, "%s/ocean_28070.png" % blessed_images_dir)
    draw_precipitation_on_file(
        w, "%s/precipitation_28070.png" % blessed_images_dir)
    draw_world_on_file(w, "%s/world_28070.png" % blessed_images_dir)
    draw_temperature_levels_on_file(
        w, "%s/temperature_28070.png" % blessed_images_dir)
    draw_biome_on_file(w, "%s/biome_28070.png" % blessed_images_dir)
    draw_scatter_plot_on_file(w, "%s/scatter_28070.png" % blessed_images_dir)
    draw_satellite_on_file(w, "%s/satellite_28070.png" % blessed_images_dir)
    draw_ancientmap_on_file(w,
                            "%s/ancientmap_28070_factor3.png" %
                            blessed_images_dir,
                            resize_factor=3)

    img = PNGWriter.rgba_from_dimensions(
        w.width * 2, w.height * 2,
        "%s/rivers_28070_factor2.png" % blessed_images_dir)
    draw_rivers_on_image(w, img, factor=2)
    img.complete()
Пример #2
0
def draw_ancientmap_on_file(world, filename, resize_factor=1,
                            sea_color=(212, 198, 169, 255),
                            draw_biome=True, draw_rivers=True, draw_mountains=True, 
                            draw_outer_land_border=False, verbose=False):
    img = PNGWriter.rgba_from_dimensions(world.width * resize_factor, world.height * resize_factor, filename)
    draw_ancientmap(world, img, resize_factor, sea_color,
                    draw_biome, draw_rivers, draw_mountains, draw_outer_land_border, 
                    verbose)
    img.complete()
Пример #3
0
 def test_draw_ancient_map_outer_borders(self):
     # TODO: So far this only calls the function without testing the result.
     # Add a blessed image with borders, maybe
     target = PNGWriter.rgba_from_dimensions(self.w.width * 3,
                                             self.w.height * 3)
     draw_ancientmap(self.w,
                     target,
                     resize_factor=3,
                     draw_outer_land_border=True)
Пример #4
0
def main(blessed_images_dir, tests_data_dir):
    w = World.open_protobuf("%s/seed_28070.world" % tests_data_dir)
    draw_simple_elevation_on_file(w, "%s/simple_elevation_28070.png"
                                  % blessed_images_dir, w.sea_level())
    draw_elevation_on_file(w, "%s/elevation_28070_shadow.png" % blessed_images_dir, shadow=True)
    draw_elevation_on_file(w, "%s/elevation_28070_no_shadow.png" % blessed_images_dir, shadow=False)
    draw_riversmap_on_file(w, "%s/riversmap_28070.png" % blessed_images_dir)
    draw_grayscale_heightmap_on_file(w, "%s/grayscale_heightmap_28070.png" % blessed_images_dir)
    draw_ocean_on_file(w.ocean, "%s/ocean_28070.png" % blessed_images_dir)
    draw_precipitation_on_file(w, "%s/precipitation_28070.png" % blessed_images_dir)
    draw_world_on_file(w, "%s/world_28070.png" % blessed_images_dir)
    draw_temperature_levels_on_file(w, "%s/temperature_28070.png" % blessed_images_dir)
    draw_biome_on_file(w, "%s/biome_28070.png" % blessed_images_dir)
    draw_scatter_plot_on_file(w, "%s/scatter_28070.png" % blessed_images_dir)
    draw_satellite_on_file(w, "%s/satellite_28070.png" % blessed_images_dir)
    draw_ancientmap_on_file(w, "%s/ancientmap_28070_factor3.png" % blessed_images_dir, resize_factor=3)

    img = PNGWriter.rgba_from_dimensions(w.width * 2, w.height * 2, "%s/rivers_28070_factor2.png" % blessed_images_dir)
    draw_rivers_on_image(w, img, factor=2)
    img.complete()
Пример #5
0
 def test_draw_satellite(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(w.width, w.height)
     draw_satellite(w, target)
     self._assert_img_equal("satellite_28070", target)
Пример #6
0
 def test_draw_ocean(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(w.width, w.height)
     draw_ocean(w.layers['ocean'].data, target)
     self._assert_img_equal("ocean_28070", target)
Пример #7
0
 def test_draw_elevation_no_shadow(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(w.width, w.height)
     draw_elevation(w, False, target)
     self._assert_img_equal("elevation_28070_no_shadow", target)
Пример #8
0
def draw_satellite_on_file(world, filename):
    img = PNGWriter.rgba_from_dimensions(world.width, world.height, filename)
    draw_satellite(world, img)
    img.complete()
Пример #9
0
def draw_precipitation_on_file(world, filename, black_and_white=False):
    img = PNGWriter.rgba_from_dimensions(world.width, world.height, filename)
    draw_precipitation(world, img, black_and_white)
    img.complete()
Пример #10
0
def draw_elevation_on_file(world, filename, shadow=True):
    img = PNGWriter.rgba_from_dimensions(world.width, world.height, filename)
    draw_elevation(world, shadow, img)
    img.complete()
Пример #11
0
 def test_draw_grayscale_heightmap(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.grayscale_from_array(w.layers['elevation'].data, scale_to_range=True)
     self._assert_img_equal("grayscale_heightmap_28070", target)
Пример #12
0
 def test_draw_rivers_on_image(self):
     target = PNGWriter.rgba_from_dimensions(self.w.width * 2,
                                             self.w.height * 2)
     draw_rivers_on_image(self.w, target, factor=2)
     self._assert_img_equal("rivers_28070_factor2", target)
Пример #13
0
 def test_draw_ancient_map(self):
     target = PNGWriter.rgba_from_dimensions(self.w.width * 3,
                                             self.w.height * 3)
     draw_ancientmap(self.w, target, resize_factor=3)
     self._assert_img_equal("ancientmap_28070_factor3", target)
 def test_draw_ancient_map_outer_borders(self):
     # TODO: So far this only calls the function without testing the result.
     # Add a blessed image with borders, maybe
     target = PNGWriter.rgba_from_dimensions(self.w.width * 3, self.w.height * 3)
     draw_ancientmap(self.w, target, resize_factor=3, draw_outer_land_border=True)
Пример #15
0
def draw_grayscale_heightmap_on_file(world, filename):
    img = PNGWriter.grayscale_from_array(world.layers['elevation'].data, filename, scale_to_range=True)
    img.complete()
Пример #16
0
def draw_grayscale_heightmap_on_file(world, filename):
    img = PNGWriter.grayscale_from_array(world.elevation['data'], filename, scale_to_range=True)
    #draw_grayscale_heightmap(world, img)
    img.complete()
Пример #17
0
 def test_draw_ocean(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(w.width, w.height)
     draw_ocean(w.layers['ocean'].data, target)
     self._assert_img_equal("ocean_28070", target)
Пример #18
0
def draw_ocean_on_file(ocean, filename):
    height, width = ocean.shape
    img = PNGWriter.rgba_from_dimensions(width, height, filename)
    draw_ocean(ocean, img)
    img.complete()
Пример #19
0
 def test_draw_scatter_plot(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(512, 512)
     draw_scatter_plot(w, 512, target)
     self._assert_img_equal("scatter_28070", target)
Пример #20
0
def draw_temperature_levels_on_file(world, filename, black_and_white=False):
    img = PNGWriter.rgba_from_dimensions(world.width, world.height, filename)
    draw_temperature_levels(world, img, black_and_white)
    img.complete()
Пример #21
0
 def test_draw_satellite(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(w.width, w.height)
     draw_satellite(w, target)
     self._assert_img_equal("satellite_28070", target)
Пример #22
0
def draw_scatter_plot_on_file(world, filename):
    img = PNGWriter.rgba_from_dimensions(512, 512, filename)
    draw_scatter_plot(world, 512, img)
    img.complete()
Пример #23
0
 def test_draw_simple_elevation(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(w.width, w.height)
     draw_simple_elevation(w, w.sea_level(), target)
     self._assert_img_equal("simple_elevation_28070", target)
Пример #24
0
def draw_icecaps_on_file(world, filename):
    img = PNGWriter.grayscale_from_array(world.icecap, filename, scale_to_range=True)
    img.complete()
Пример #25
0
 def test_draw_elevation_shadow(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(w.width, w.height)
     draw_elevation(w, True, target)
     self._assert_img_equal("elevation_28070_shadow", target)
Пример #26
0
 def test_draw_grayscale_heightmap(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.grayscale_from_array(w.layers['elevation'].data,
                                             scale_to_range=True)
     self._assert_img_equal("grayscale_heightmap_28070", target)
Пример #27
0
 def test_draw_ancient_map(self):
     target = PNGWriter.rgba_from_dimensions(self.w.width * 3, self.w.height * 3)
     draw_ancientmap(self.w, target, resize_factor=3)
     self._assert_img_equal("ancientmap_28070_factor3", target)
Пример #28
0
 def test_draw_scatter_plot(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(512, 512)
     draw_scatter_plot(w, 512, target)
     self._assert_img_equal("scatter_28070", target)
Пример #29
0
 def test_draw_rivers_on_image(self):
     target = PNGWriter.rgba_from_dimensions(self.w.width * 2, self.w.height * 2)
     draw_rivers_on_image(self.w, target, factor=2)
     self._assert_img_equal("rivers_28070_factor2", target)
Пример #30
0
 def test_draw_simple_elevation(self):
     w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
     target = PNGWriter.rgba_from_dimensions(w.width, w.height)
     draw_simple_elevation(w, w.sea_level(), target)
     self._assert_img_equal("simple_elevation_28070", target)
Пример #31
0
def draw_simple_elevation_on_file(world, filename, sea_level):
    img = PNGWriter.rgba_from_dimensions(world.width, world.height, filename)
    draw_simple_elevation(world, sea_level, img)
    img.complete()