Remove duplicate pack_rectangles

This commit is contained in:
2024-06-16 22:51:48 +02:00
parent 7b73aef5fe
commit 859c83745b
22 changed files with 1 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 B

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 B

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 972 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 B

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 B

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 B

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 B

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 569 B

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 637 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 857 B

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 B

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

After

Width:  |  Height:  |  Size: 101 B

View File

@@ -57,25 +57,6 @@ class Bin:
self.grid[rect_y][rect_x] = False self.grid[rect_y][rect_x] = False
def pack_rectangles(rectangles, grid):
rectangles = sorted(
rectangles, key=lambda r: r.width * r.height, reverse=True)
bins = [Bin(grid)]
for rectangle in rectangles:
for bin in bins:
if bin.place_rectangle(rectangle):
break
else:
new_bin = Bin(grid)
if new_bin.place_rectangle(rectangle):
bins.append(new_bin)
else:
return False
return True
def generate_rectangle(min_width: int = 10, max_width: int = 25): def generate_rectangle(min_width: int = 10, max_width: int = 25):
width = randint(min_width, max_width) width = randint(min_width, max_width)
height = randint(min_width, max_width) height = randint(min_width, max_width)

View File

@@ -54,7 +54,7 @@ def world_maker():
filter_smooth( filter_smooth(
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png') './world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png')
for i in range(5): for i in range(10):
overide_map('./world_maker/data/heightmap_with_building.png', overide_map('./world_maker/data/heightmap_with_building.png',
'./world_maker/data/building_moutain.png').save('./world_maker/data/heightmap_with_building.png') './world_maker/data/building_moutain.png').save('./world_maker/data/heightmap_with_building.png')
overide_map('./world_maker/data/heightmap_with_building.png', overide_map('./world_maker/data/heightmap_with_building.png',