for x in range(0, osm_mask.width, int(osm_mask.width/200)):
px = epx[x,y]
if px[3] == 255:
- rx = randrange(30,60)
- ry = randrange(30,60)
+ rx = randrange(24,60)
+ ry = randrange(24,60)
f = randrange(1,10)
+
+ # Randomize the found locations a little
+ psx = randrange(x-11, x+11)
+ psy = randrange(y-11, y+11)
# Do some magic - but not on edges
if x > 0 and x < osm_mask.width and y > 0 and y < osm_mask.height:
if f != 5:
- imgd.ellipse((x-int(rx/2), y-int(ry/2), x+rx, y+ry), fill="black")
+ imgd.ellipse((psx-int(rx/2), psy-int(ry/2), psx+rx, psy+ry), fill="black")
if f == 3 or f == 7:
- imgd.ellipse((x-int(rx/2), y-int(ry/2), x+rx, y+ry), fill=(0,0,0,0))
+ imgd.ellipse((psx-int(rx/2), psy-int(ry/2), psx+rx, psy+ry), fill=(0,0,0,0))
# We need to change the image in certain conditions
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:
# Pick a number of trees to place
- numtrees = randrange(1, 5)
+ numtrees = randrange(1, 6)
for i in range(1, numtrees):
# Pick some file
pick = str(randrange(1, 11))
tree = Image.open(mstr_datafolder + "Textures/building/area/p" + pick + ".png")
+ # Do a correction for the location if needed
+ if shf_x < 1: shf_x = 1
+ if shf_y < 1: shf_y = 1
+ if shf_x > self._imgsize - tree.width: shf_x = self._imgsize - tree.width - 1
+ if shf_y > self._imgsize - tree.height: shf_y = self._imgsize - tree.height - 1
trees.alpha_composite(tree, (shf_x, shf_y))
- #layer_comp.paste(tree, (shf_x, shf_y))
trees.alpha_composite(layer_comp)
layer_comp = trees