overall fix

This commit is contained in:
Klemek
2024-03-13 14:02:40 +01:00
parent c26ab25212
commit 5847130478
7 changed files with 21354 additions and 22879 deletions
+13 -9
View File
@@ -10,6 +10,9 @@ COUNT = 151
OUT_DIR = f"{os.path.dirname(__file__)}/pokemon-out"
WIDTH = 72
HEIGHT = 72
D_DATA = [
[
[0]
@@ -39,15 +42,15 @@ D_DATA = [
D_LEVELS = len(D_DATA) * 2 - 1
def make_dithering(i: int) -> Image.Image:
im = Image.new("L", (68, 68), 'white')
im = Image.new("L", (WIDTH, WIDTH), 'white')
if i < len(D_DATA):
d = D_DATA[i]
else:
d = D_DATA[D_LEVELS - i - 1]
w = len(d[0])
h = len(d)
for x in range(68):
for y in range(68):
for x in range(WIDTH):
for y in range(WIDTH):
v = d[y % h][x % w]
if i < len(D_DATA):
im.putpixel((x, y), 256 if v else 0)
@@ -58,9 +61,9 @@ def make_dithering(i: int) -> Image.Image:
D_IM = [make_dithering(i) for i in range(D_LEVELS)]
def make_extent() -> Image.Image:
im = Image.new("L", (12, 68), color=0)
for x in range(12):
for y in range(68):
im = Image.new("L", (WIDTH - HEIGHT, HEIGHT), color=0)
for x in range(WIDTH - HEIGHT):
for y in range(HEIGHT):
im.putpixel((x, y), 256)
return im
@@ -70,11 +73,12 @@ def make_mask(im: Image.Image, i: int) -> Image.Image:
return im.point(lambda p: 1 if p >= math.floor(i * 256 / D_LEVELS) and p < math.ceil((i + 1) * 256 / D_LEVELS) else 0, mode="1")
def convert(im: Image.Image) -> Image.Image:
im = im.resize((68, 68))
im0, im = im, Image.new(im.mode, (80, 68), color=1)
im = im.resize((WIDTH, HEIGHT))
im0, im = im, Image.new(im.mode, (WIDTH, HEIGHT), color=1)
for i in range(D_LEVELS):
im.paste(D_IM[i], (0, 0), mask=make_mask(im0, i))
im.paste(EXTENT, (68, 0))
im.paste(EXTENT, (2 * WIDTH - HEIGHT, 0))
im = im.convert(mode="P")
return im