Claimed floors back to fitted flagstones in the masters' colours with damage; high-res floor decals
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
362f4e7670
commit
ca8494aea0
51 files changed
+154
-39
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Turn a generated decal (a picture on a flat magenta background) into a transparent tile for
|
||||
the high-res atlas: magenta keyed out, scaled down without magenta fringes (premultiplied), the
|
||||
alpha made hard (pixels are either there or not, like the rest of the pixel art).
|
||||
|
||||
Usage:
|
||||
make_decal.py raw.png out_prefix --size 128 [--gray]
|
||||
|
||||
--gray neutral grey (a dark crack whose lines took on the magenta of the background)
|
||||
|
||||
Writes out_prefix-<size>.png and out_prefix-<size>-preview.png (on a grey floor, scaled up 3x).
|
||||
Needs Pillow.
|
||||
"""
|
||||
import argparse
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("raw")
|
||||
ap.add_argument("out")
|
||||
ap.add_argument("--size", type=int, default=128)
|
||||
ap.add_argument("--gray", action="store_true")
|
||||
a = ap.parse_args()
|
||||
|
||||
img = Image.open(a.raw).convert("RGBA")
|
||||
px = img.load()
|
||||
for y in range(img.height):
|
||||
for x in range(img.width):
|
||||
r, g, b, _ = px[x, y]
|
||||
if r > g + 40 and b > g + 40:
|
||||
px[x, y] = (0, 0, 0, 0)
|
||||
# premultiplied scaling: transparent pixels add nothing to the colour
|
||||
small = img.resize((a.size, a.size), Image.BOX)
|
||||
sp = small.load()
|
||||
for y in range(a.size):
|
||||
for x in range(a.size):
|
||||
r, g, b, al = sp[x, y]
|
||||
if al < 110:
|
||||
sp[x, y] = (0, 0, 0, 0)
|
||||
else:
|
||||
k = 255 / al
|
||||
c = (min(255, int(r * k)), min(255, int(g * k)), min(255, int(b * k)))
|
||||
if a.gray:
|
||||
v = min(c) * 0.9
|
||||
c = (int(v), int(v), int(v * 1.05))
|
||||
sp[x, y] = c + (255,)
|
||||
# Pillow's BOX filter works on straight alpha; transparent pixels were black, so colours near
|
||||
# the edges come out darker, which suits the dark outlines
|
||||
small.save(f"{a.out}-{a.size}.png")
|
||||
prev = Image.new("RGBA", (a.size, a.size), (90, 86, 84, 255))
|
||||
prev.alpha_composite(small)
|
||||
prev.resize((a.size * 3, a.size * 3), Image.NEAREST).save(f"{a.out}-{a.size}-preview.png")
|
||||
print(f"{a.out}-{a.size}.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+5
-2
@@ -2,7 +2,7 @@
|
||||
"""Turn a generated texture into a seamless pixel-art tile sheet for the high-res atlas.
|
||||
|
||||
Usage:
|
||||
make_tile.py raw.png out_prefix [--size 128] [--colors 32] [--band 14] [--variants N]
|
||||
make_tile.py raw.png out_prefix [--size 128] [--colors 32] [--band 14] [--variants N] [--bright F]
|
||||
|
||||
The picture is scaled down to size x size (default 128: a 2x2 block of 64x64 tiles; the game
|
||||
lays the four quarters out by the tiles' positions, so the floor repeats only every two tiles),
|
||||
@@ -20,7 +20,7 @@ out_prefix-v<tile>-preview.png (a floor of them laid out at random). Needs Pillo
|
||||
import argparse
|
||||
import random
|
||||
|
||||
from PIL import Image, ImageChops
|
||||
from PIL import Image, ImageChops, ImageEnhance
|
||||
|
||||
|
||||
def seamless(img, band):
|
||||
@@ -75,12 +75,15 @@ def main():
|
||||
ap.add_argument("--colors", type=int, default=32)
|
||||
ap.add_argument("--band", type=int, default=14)
|
||||
ap.add_argument("--variants", type=int, default=0)
|
||||
ap.add_argument("--bright", type=float, default=1.0)
|
||||
a = ap.parse_args()
|
||||
|
||||
img = Image.open(a.raw).convert("RGB")
|
||||
s = min(img.size)
|
||||
img = img.crop(((img.width - s) // 2, (img.height - s) // 2, (img.width + s) // 2, (img.height + s) // 2))
|
||||
img = img.resize((a.size, a.size), Image.LANCZOS)
|
||||
if a.bright != 1.0:
|
||||
img = ImageEnhance.Brightness(img).enhance(a.bright)
|
||||
img = seamless(img, a.band)
|
||||
if a.variants:
|
||||
return variants(img, a)
|
||||
|
||||
Reference in new issue
Block a user