webgo/generate_goban_images.py

28 lines
970 B
Python
Raw Normal View History

2005-09-06 19:52:46 +02:00
#!/usr/bin/python
"""
a simple script using pil to generate the goban from background, grid and stone images.
"""
import Image,ImageOps
2005-09-06 19:52:46 +02:00
gridlist = ["bottomleftline","bottomline","bottomrightline",
"centerline","hoshi","leftline","rightline",
"topleftline", "topline","toprightline"]
whitestone = Image.open("imgsource/whitestone.png").convert("RGBA")
blackstone = Image.open("imgsource/blackstone.png").convert("RGBA")
for item in gridlist:
#creating empty goban
bg = Image.open("imgsource/background.png").convert("RGBA")
img = Image.open("imgsource/"+item+".png").convert("RGBA")
bg.paste(img,None,img)
#bg = Image.composite(img,bg,img)
2005-09-06 19:52:46 +02:00
bg.save("img/"+item+".png")
tmp = bg #for the white stones
tmp2 = bg #for the black stones
2005-09-06 19:52:46 +02:00
#filling with white stones
tmp.paste(whitestone,None,whitestone)
tmp.save("img/"+item+"_white.png")
2005-09-06 19:52:46 +02:00
#filling with black stones
tmp2.paste(blackstone.convert("RGB"),None,blackstone)
tmp2.save("img/"+item+"_black.png")