Adjustment to trees at buildings

This commit is contained in:
marstr 2024-09-03 20:02:08 +02:00
parent a1391cbc5e
commit 5a9f53ba41

View File

@ -658,6 +658,7 @@ class mstr_layergen:
# Add some random trees # Add some random trees
div = int(self._imgsize/200) div = int(self._imgsize/200)
trees = Image.new("RGBA", (self._imgsize, self._imgsize))
for y in range(0, self._imgsize, div): for y in range(0, self._imgsize, div):
for x in range(0, self._imgsize, div): for x in range(0, self._imgsize, div):
if x > 0 and x < self._imgsize and y > 0 and y < self._imgsize: if x > 0 and x < self._imgsize and y > 0 and y < self._imgsize:
@ -671,11 +672,16 @@ class mstr_layergen:
shf_x = randrange(x-11, x+11) shf_x = randrange(x-11, x+11)
shf_y = randrange(y-11, y+11) shf_y = randrange(y-11, y+11)
if shf_x > 0 and shf_x < self._imgsize and shf_y > 0 and shf_y < self._imgsize: if shf_x > 0 and shf_x < self._imgsize and shf_y > 0 and shf_y < self._imgsize:
# Pick a number of trees to place
numtrees = randrange(1, 5)
for i in range(1, numtrees):
# Pick some file # Pick some file
pick = str(randrange(1, 11)) pick = str(randrange(1, 11))
tree = Image.open(mstr_datafolder + "Textures\\building\\area\\p" + pick + ".png") tree = Image.open(mstr_datafolder + "Textures\\building\\area\\p" + pick + ".png")
layer_comp.alpha_composite(tree, (shf_x, shf_y)) trees.alpha_composite(tree, (shf_x, shf_y))
#layer_comp.paste(tree, (shf_x, shf_y)) #layer_comp.paste(tree, (shf_x, shf_y))
trees.alpha_composite(layer_comp)
layer_comp = trees
mstr_msg("layergen", "Layer image generated") mstr_msg("layergen", "Layer image generated")