webgo/generate_goban_images.py

27 lines
970 B
Python
Executable file

#!/usr/bin/python
"""
a simple script using pil to generate the goban from background, grid and stone images.
"""
import Image,ImageOps
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)
bg.save("img/"+item+".png")
tmp = bg #for the white stones
tmp2 = bg #for the black stones
#filling with white stones
tmp.paste(whitestone,None,whitestone)
tmp.save("img/"+item+"_white.png")
#filling with black stones
tmp2.paste(blackstone.convert("RGB"),None,blackstone)
tmp2.save("img/"+item+"_black.png")