-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimage.py
More file actions
35 lines (27 loc) · 744 Bytes
/
image.py
File metadata and controls
35 lines (27 loc) · 744 Bytes
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
import PIL
from PIL import Image
import re
import world
from world import Chunk
def generate_heart_chunk(filename = "heart.png", blockid=[35, 14]):
im = Image.open(filename)
im.thumbnail((16, 16), Image.ANTIALIAS)
imdata = list(im.getdata())
#print(list(im.getdata()))
data = []
pngtype = re.compile(".*\.png")
if pngtype.match(filename):
for i in imdata:
if i[3] > 50:
data.append(blockid)
else:
data.append([0,0])
else:
for i in imdata:
if i[2] > 50:
data.append(blockid)
else:
data.append([0,0])
chunk = Chunk(0,0,0, data)
chunk.fill(0,0)
return chunk