]> marstr Code Repo - orthographic/commitdiff
Adjustment to trees at buildings
authormarstr <marcus@marstr.online>
Tue, 3 Sep 2024 18:02:08 +0000 (20:02 +0200)
committermarstr <marcus@marstr.online>
Tue, 3 Sep 2024 18:02:08 +0000 (20:02 +0200)
layergen.py

index 7bc2703e95f94207fefb1e7e89154f94e51d5163..81f2a6deca159a42ee67211b58590d294faaf2d7 100644 (file)
@@ -658,6 +658,7 @@ class mstr_layergen:
 
                     # Add some random trees
                     div = int(self._imgsize/200)
+                    trees = Image.new("RGBA", (self._imgsize, self._imgsize))
                     for y 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:
@@ -671,11 +672,16 @@ class mstr_layergen:
                                         shf_x = randrange(x-11, x+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:
-                                            # Pick some file
-                                            pick = str(randrange(1, 11))
-                                            tree = Image.open(mstr_datafolder + "Textures\\building\\area\\p" + pick + ".png")
-                                            layer_comp.alpha_composite(tree, (shf_x, shf_y))
-                                            #layer_comp.paste(tree, (shf_x, shf_y))
+                                            # Pick a number of trees to place
+                                            numtrees = randrange(1, 5)
+                                            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")
+                                                trees.alpha_composite(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")