Add smooth building terrain

This commit is contained in:
2024-06-16 21:56:58 +02:00
parent 8f3c92bd1d
commit 54a4a12cca
20 changed files with 27 additions and 10 deletions

View File

@@ -97,9 +97,14 @@ def draw_rectangles(rectangles, grid, heightmap):
image = Image.new('L', (len(grid[0]), len(grid)), (0))
for rectangle in rectangles:
start, end = rectangle
height = []
for x in range(start[0], end[0]):
for y in range(start[1], end[1]):
image.putpixel((x, y), heightmap.getpixel((x, y)))
height.append(heightmap.getpixel((x, y)))
height_average = sum(height)/len(height)
for x in range(start[0], end[0]):
for y in range(start[1], end[1]):
image.putpixel((x, y), round(height_average))
return image