Made small inland rivers and streams blend much more naturally into the environment.

This commit is contained in:
marstr 2024-09-01 13:53:34 +02:00
parent adcf86cc70
commit d180f75e07
2 changed files with 11 additions and 10 deletions

View File

@ -293,12 +293,6 @@ class mstr_layergen:
osm_edge = osm_edge.filter(ImageFilter.BoxBlur(radius=2)) osm_edge = osm_edge.filter(ImageFilter.BoxBlur(radius=2))
layer_border = self.genborder(osm_edge, "landuse", "meadow") layer_border = self.genborder(osm_edge, "landuse", "meadow")
layer_comp.alpha_composite(layer_border) layer_comp.alpha_composite(layer_border)
# Give streams a more natural look
if self._tag == "waterway" and (self._value == "stream" or self._value == "river"):
osm_edge = osm_edge.filter(ImageFilter.ModeFilter(size=15))
osm_edge = osm_edge.filter(ImageFilter.BoxBlur(radius=2))
layer_border = self.genborder(osm_edge, "natural", "wetland")
layer_comp.alpha_composite(layer_border)
# Store layer # Store layer
@ -454,7 +448,13 @@ class mstr_layergen:
layer_comp_pix[x, y] = ( r,g,b,a[3] ) layer_comp_pix[x, y] = ( r,g,b,a[3] )
if self._tag == "waterway" and (self._value == "stream" or self._value == "river"): if self._tag == "waterway" and (self._value == "stream" or self._value == "river"):
d = randrange(1, 15) d = randrange(1, 15)
layer_comp_pix[x, y] = ( 129-d, 148-d, 159-d, a[3] ) # Rock, grass, water
mats = [ (48-d, 45-d, 42-d), (58-d, 81-d, 41-d), (129-d, 148-d, 159-d) ]
# Pick one of those
pick = randrange(1,4)
t = a[3]-d
if t < 0: t = 0
layer_comp_pix[x, y] = ( mats[pick-1][0], mats[pick-1][1], mats[pick-1][2], t )
if self._tag == "building": if self._tag == "building":
r = randrange(1, 20) r = randrange(1, 20)
@ -485,6 +485,7 @@ class mstr_layergen:
g = 159 - d g = 159 - d
b = 138 - d b = 138 - d
layer_comp_pix[x, y] = ( r,g,b,a[3] ) layer_comp_pix[x, y] = ( r,g,b,a[3] )
mstr_msg("mstr_layergen", "Layer image generated") mstr_msg("mstr_layergen", "Layer image generated")
# Building shadow # Building shadow
@ -522,8 +523,9 @@ class mstr_layergen:
mstr_msg("mstr_layergen", "Street lines added") mstr_msg("mstr_layergen", "Street lines added")
if self._tag == "waterway" and (self._value == "river" or self._value == "stream"):
layer_comp = layer_comp.filter(ImageFilter.GaussianBlur(radius=4))
# Store layer # Store layer
layer_comp.save( mstr_datafolder + "_cache\\" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + "_layer.png" ) layer_comp.save( mstr_datafolder + "_cache\\" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + "_layer.png" )
mstr_msg("mstr_layergen", "Layer image finalized and saved.") mstr_msg("mstr_layergen", "Layer image finalized and saved.")

View File

@ -182,4 +182,3 @@ class mstr_maskgen:
mask_img.save(mstr_datafolder + "_cache\\" + fstr + "_" + self._tag + "-" + self._value + ".png") mask_img.save(mstr_datafolder + "_cache\\" + fstr + "_" + self._tag + "-" + self._value + ".png")
# Inform # Inform
mstr_msg("mstr_maskgen", "Mask built.") mstr_msg("mstr_maskgen", "Mask built.")