]> marstr Code Repo - orthographic/commitdiff
Made small inland rivers and streams blend much more naturally into the environment.
authormarstr <marcus@marstr.online>
Sun, 1 Sep 2024 11:53:34 +0000 (13:53 +0200)
committermarstr <marcus@marstr.online>
Sun, 1 Sep 2024 11:53:34 +0000 (13:53 +0200)
layergen.py
maskgen.py

index d25a772824d1e93710a9365b3387fb92484cb169..8e366e93322714b7326531fa3d745f551660b295 100644 (file)
@@ -293,12 +293,6 @@ class mstr_layergen:
                     osm_edge = osm_edge.filter(ImageFilter.BoxBlur(radius=2))
                     layer_border = self.genborder(osm_edge, "landuse", "meadow")
                     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
@@ -454,7 +448,13 @@ class mstr_layergen:
                             layer_comp_pix[x, y] = ( r,g,b,a[3] )
                         if self._tag == "waterway" and (self._value == "stream" or self._value == "river"):
                             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":
                             r = randrange(1, 20)
                             
@@ -485,6 +485,7 @@ class mstr_layergen:
                             g = 159 - d
                             b = 138  - d
                             layer_comp_pix[x, y] = ( r,g,b,a[3] )
+
             mstr_msg("mstr_layergen", "Layer image generated")
 
             # Building shadow
@@ -522,8 +523,9 @@ class mstr_layergen:
 
                 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
             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.")
-                
-
index 5375d77e52126bb8734abbd7a025fab77d8c22ea..c661d193657566dba51cb536923ea82bf9274c8c 100644 (file)
@@ -182,4 +182,3 @@ class mstr_maskgen:
         mask_img.save(mstr_datafolder + "_cache\\" + fstr + "_" + self._tag + "-" + self._value + ".png")
         # Inform
         mstr_msg("mstr_maskgen", "Mask built.")
-    
\ No newline at end of file