Production-ready change to building rendering

This commit is contained in:
Marcus Str. 2024-12-19 16:20:58 +01:00
parent 3bdf595173
commit b29bc3b0d2
3 changed files with 17 additions and 11 deletions

View File

@ -704,14 +704,19 @@ class mstr_layergen:
# Patch and border sources. There can only be one for each. # Patch and border sources. There can only be one for each.
brd_src = None brd_src = None
numbers = list(range(1, len(srclist)))
res = random.sample(numbers, 4)
ptc_src = [] ptc_src = []
ptc_img = Image.open(mstr_datafolder + "textures/" + self._tag + "/" + self._value + "/" + str(srcnum) + ".png")
for p in range(0, len(res)):
ptc_src.append(Image.open(mstr_datafolder + "textures/" + self._tag + "/" + self._value + "/" + str(res[p]) + ".png"))
# Set some contrast # Set some contrast
lyr_contrast = randrange(1, 4) lyr_contrast = 0.85
# Open the images # Open the images
ptc_src.append( ptc_img ) # Used to be an array, so let's keep it
#ptc_src.append( ptc_img ) # Used to be an array, so let's keep it
#brd_src = bldg_src[1] #brd_src = bldg_src[1]
# Begin producing a largely random image # Begin producing a largely random image
@ -720,12 +725,13 @@ class mstr_layergen:
imgid = 0 imgid = 0
if len(ptc_src) == 1: imgid = 0 if len(ptc_src) == 1: imgid = 0
if len(ptc_src) >= 2: if len(ptc_src) >= 2:
imgid = randrange(1, len(ptc_src) + 1) - 1 imgid = randrange(0, len(ptc_src))
l = 0 - int(ptc_src[imgid].width / 2) i = ptc_src[imgid].rotate(randrange(0, 360), expand=True)
r = layer.width - int(ptc_src[imgid].width / 2) l = 0 - int(i.width / 2)
t = 0 - int(ptc_src[imgid].height / 2) r = layer.width - int(i.width / 2)
b = layer.height - int(ptc_src[imgid].height / 2) t = 0 - int(i.height / 2)
bld_src.alpha_composite(ptc_src[imgid], (randrange(l, r), randrange(t, b))) b = layer.height - int(i.height / 2)
bld_src.alpha_composite(i, (randrange(l, r), randrange(t, b)))
mstr_msg("layergen", "Layer image generated") mstr_msg("layergen", "Layer image generated")
bld_src_pix = bld_src.load() bld_src_pix = bld_src.load()

View File

@ -225,7 +225,7 @@ class mstr_orthographic:
osmxml.acquire_osm(grid_lat, grid_lng) osmxml.acquire_osm(grid_lat, grid_lng)
# Let the user know # Let the user know
mstr_msg("orthographic", "Generating missing orthophoto " + str(grid_lat) + "-" + str(grid_lng)) mstr_important_msg("orthographic", "Generating missing orthophoto " + str(grid_lat) + "-" + str(grid_lng))
# Check for work to be done # Check for work to be done
layers = self.determineLayerWork(osmxml) layers = self.determineLayerWork(osmxml)

View File

@ -353,7 +353,7 @@ class mstr_photogen:
lx = randrange(0, self._imgsize) lx = randrange(0, self._imgsize)
ly = randrange(0, self._imgsize) ly = randrange(0, self._imgsize)
lp = lyrmask[lx,ly] lp = lyrmask[lx,ly]
if lp[3] > 0: if lp[3] == 255:
tree = self.generate_tree() tree = self.generate_tree()
trees.alpha_composite(tree, (lx, ly)) trees.alpha_composite(tree, (lx, ly))