From fbb71123886a2dfb4ee1ef98c772249f3dae4f51 Mon Sep 17 00:00:00 2001 From: "Marcus Str." Date: Tue, 4 Feb 2025 15:11:59 +0100 Subject: [PATCH] Change to maskgen for farmland lines. --- maskgen.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/maskgen.py b/maskgen.py index bf846f9..15572a1 100644 --- a/maskgen.py +++ b/maskgen.py @@ -263,6 +263,26 @@ class mstr_maskgen: bld_shadow.save(fn) + # Let's apply a trick that came to me one night :) + # Adds random lines to farmland areas + if (self._tag == "landuse" and self._value == "farmland") or (self._tag == "landuse" and self._value == "farmyard"): + lines = Image.new("RGBA", (2048,2048)) + mask_pix = mask_img.load() + pts = [] + for l in range(96, 201): + p = ( randrange(0,2048), randrange(0,2048) ) + pts.append(p) + imgl = ImageDraw.Draw(lines) + imgl.line(pts, fill="#000000", width=1, joint="curve") + lines = lines.filter(ImageFilter.GaussianBlur(radius=1)) + linepix = lines.load() + for y in range(0, 2048): + for x in range(0, 2048): + lp = linepix[x,y] + if lp[3] > 0: + c = (0,0,0,255-lp[3]) + mask_pix[x,y] = c + # Inform mstr_msg("maskgen", "Mask built.")