]> marstr Code Repo - marstr/orthographic.git/commitdiff
Change to maskgen for farmland lines.
authorMarcus Str. <marcus@marstr.online>
Tue, 4 Feb 2025 14:11:59 +0000 (15:11 +0100)
committerMarcus Str. <marcus@marstr.online>
Tue, 4 Feb 2025 14:11:59 +0000 (15:11 +0100)
maskgen.py

index bf846f9c41b47e395dc8528bd671a3494944f51b..15572a191487b20fbeed724df35594c9ef4d3f49 100644 (file)
@@ -263,6 +263,26 @@ class mstr_maskgen:
                     bld_shadow.save(fn)\r
 \r
 \r
+        # Let's apply a trick that came to me one night :)\r
+        # Adds random lines to farmland areas\r
+        if (self._tag == "landuse" and self._value == "farmland") or (self._tag == "landuse" and self._value == "farmyard"):\r
+            lines = Image.new("RGBA", (2048,2048))\r
+            mask_pix = mask_img.load()\r
+            pts = []\r
+            for l in range(96, 201):\r
+                p = ( randrange(0,2048), randrange(0,2048) )\r
+                pts.append(p)\r
+            imgl = ImageDraw.Draw(lines)\r
+            imgl.line(pts, fill="#000000", width=1, joint="curve")\r
+            lines = lines.filter(ImageFilter.GaussianBlur(radius=1))\r
+            linepix = lines.load()\r
+            for y in range(0, 2048):\r
+                for x in range(0, 2048):\r
+                    lp = linepix[x,y]\r
+                    if lp[3] > 0:\r
+                        c = (0,0,0,255-lp[3])\r
+                        mask_pix[x,y] = c\r
+\r
         # Inform\r
         mstr_msg("maskgen", "Mask built.")\r
 \r