From 0b9d8433a6caf11edb0886239b079e8ba476ea5d Mon Sep 17 00:00:00 2001 From: "Marcus Str." Date: Sun, 22 Dec 2024 12:37:21 +0100 Subject: [PATCH] Attempt to make the fill of empty space look more realistic, hopefully fixed a contrast issue for some tags --- photogen.py | 33 +++++++++------------------------ resourcegen.py | 3 ++- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/photogen.py b/photogen.py index 8a6c2fb..d5c8035 100644 --- a/photogen.py +++ b/photogen.py @@ -87,30 +87,15 @@ class mstr_photogen: edn = self.find_earthnavdata_number() edns = self.latlng_folder(edn) - cplstr = "" - for c in range(0, len(cpl)): - cplstr = cplstr + str(cpl[c]) - if c < len(cpl)-1: - cplstr = cplstr + "_" - - # Find the right color catalogue - cpl_catalog = 0 - for c in range(len(mstr_completion_colors)): - if mstr_completion_colors[c][0] == edn: - cpl_catalog = c - - # Put in some pixels - cmpl_bg = Image.new("RGBA", (self._tile.width, self._tile.height)) - cmpl_pix = cmpl_bg.load() - for y in range(0, self._tile.height): - for x in range(0, self._tile.width): - idx = randrange(0, len(mstr_completion_colors[cpl_catalog][1])) - clr = mstr_completion_colors[cpl_catalog][1][idx] - cmpl_pix[x,y] = clr - cmpl_bg = ImageEnhance.Contrast(cmpl_bg).enhance(0.8) - cmpl_bg = cmpl_bg.filter(ImageFilter.GaussianBlur(radius=1)) - cmpl_bg.alpha_composite(self._tile) - self._tile = cmpl_bg + cmpl_ptc = Image.open(mstr_datafolder + "textures/tile/completion/ptc.png") + cmpl_brd = Image.open(mstr_datafolder + "textures/tile/completion/brd.png") + + # Generate the source image + for p in range(1, 201): + rx = randrange(0 - int(cmpl_ptc.width / 2), ptc_full.width - int(cmpl_ptc.width / 2)) + ry = randrange(0 - int(cmpl_ptc.height / 2), ptc_full.height - int(cmpl_ptc.height / 2)) + cmpl.alpha_composite(cmpl_ptc, dest=(rx, ry)) + cmpl.alpha_composite(cmpl_brd) # Patches to add from other sources. If they don't exist, we also need to make them masks = glob.glob(mstr_datafolder + "textures/tile/completion/*.png") diff --git a/resourcegen.py b/resourcegen.py index 41cd315..f5e0898 100644 --- a/resourcegen.py +++ b/resourcegen.py @@ -29,12 +29,13 @@ class mstr_resourcegen: self._sources = sources self._tag = tag self._value = value - self._contrast = 0 + self._contrast = 1 # Sets the contrast from layergen def setLayerContrast(self, contrast): self._contrast = contrast + if contrast == 0: self._contrast = 1 # This generates a resource from the given sources -- 2.30.2