forked from aliaagheisX/Cheeese
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconverter.py
More file actions
47 lines (39 loc) · 1.74 KB
/
converter.py
File metadata and controls
47 lines (39 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from PIL import Image
files = [
'b',
'k',
'KK',
'p',
'q',
'r',
]
for filename in files:
im = Image.open("s/" + filename + ".png").convert('LA') ####greyscal, alpha
pixels = list(im.getdata())
px = []
for elm in pixels:
px.append(elm[:-1])
C = []
for c,i in enumerate(px):
if pixels[c][1] == 0:
C.append(4)
elif pixels[c][0] - 0 < 255 - pixels[c][0]:
C.append(21)
else :C.append(21)
StrC = f"{filename} DB "
# Split the array into multiple lines cause it will be too long for one line for the tasm/masm.
for i in range(len(C)):
if i!=0 and i % 7 == 0:
StrC = StrC + str(C[i]) + " " + "\n DB "
else:
StrC = StrC + str(C[i]) + ", "
StrC = StrC[:-2]
print(StrC)
print('\n\n')
# Used pallete: https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/VGA_palette_with_black_borders.svg/1200px-VGA_palette_with_black_borders.svg.png
# This pallete is the default 256 colors in the Tasm/Masm Extension for VS code, Note that the original asm86 only supported the first 16 colors
# So make sure while drawing your art to pick (via color picker) from this palette, btw: Krita(~30mb) is a great and easy app for creating pixel art:
# How to set up Krita for pixel art(5 mins): https://www.youtube.com/watch?v=aaRzNTCanIQ
# Nice Pixel art tutorials playlist (each video is 5~15 mins): https://www.youtube.com/playlist?list=PLmac3HPrav-9UWt-ahViIZxpyQxJ2wPSH
# It is okay tho to use black(0) as escaping since there are other codes for the same color like 16, 248..255.
# if it is .png with some pixels having 0 in alpha channel (making them tranparent: use black(0) as escaping color)