Fix arg from building
|
Before Width: | Height: | Size: 969 B After Width: | Height: | Size: 696 B |
BIN
world_maker/data/city_map.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -278,15 +278,15 @@ def detect_mountain(image: Union[str, Image] = './world_maker/data/sobelmap.png'
|
|||||||
def rectangle_2D_to_3D(rectangle: list[tuple[tuple[int, int], tuple[int, int]]],
|
def rectangle_2D_to_3D(rectangle: list[tuple[tuple[int, int], tuple[int, int]]],
|
||||||
height_min: int = 6, height_max: int = 10) \
|
height_min: int = 6, height_max: int = 10) \
|
||||||
-> list[tuple[tuple[int, int, int], tuple[int, int, int]]]:
|
-> list[tuple[tuple[int, int, int], tuple[int, int, int]]]:
|
||||||
image = handle_import_image('./world_maker/data/heightmap.png')
|
image = handle_import_image('./world_maker/data/heightmap.png').convert('L')
|
||||||
new_rectangle = []
|
new_rectangle = []
|
||||||
for rect in rectangle:
|
for rect in rectangle:
|
||||||
start, end = rect
|
start, end = rect
|
||||||
avg_height = 0
|
avg_height = 0
|
||||||
for x in range(start[0], end[0]):
|
for x in range(start[0], end[0]):
|
||||||
for y in range(start[1], end[1]):
|
for y in range(start[1], end[1]):
|
||||||
avg_height += np.array(image.getpixel((x, y)))
|
avg_height += image.getpixel((x, y))
|
||||||
avg_height = int(avg_height / ((end[0] - start[0]) * (end[1] - start[1])))
|
avg_height = int(avg_height / ((end[0] - start[0]) * (end[1] - start[1])))
|
||||||
new_rectangle.append(((start[0], avg_height, start[1]), (end[0], avg_height + randint(height_min, height_max), end[1])))
|
new_rectangle.append(
|
||||||
|
((start[0], avg_height, start[1]), (end[0], avg_height + randint(height_min, height_max), end[1])))
|
||||||
return new_rectangle
|
return new_rectangle
|
||||||
|
|
||||||
|
|||||||