#! ~/bin/python
from PIL import Image, ImageDraw, ImageFont
import sys
def generate_henohenomoheji(brow: str, eye: str, nose: str, mouth: str, file_name: str):
# 背景画像を作成
image = Image.new('RGB', (600,600), (255, 255, 255))
draw = ImageDraw.Draw(image)
# フォントの設定
font_size = 80
font = ImageFont.truetype("/Users/koshi/Library/Fonts/BIZUDGothic-Regular.ttf", font_size)
# へのへのもへじの要素を描画
draw.text((160, 120), brow, font=font, fill=(0, 0, 0)) # 眉毛
draw.text((340, 120), brow, font=font, fill=(0, 0, 0)) # 眉毛
draw.text((180, 200), eye, font=font, fill=(0, 0, 0)) # 目
draw.text((330, 200), eye, font=font, fill=(0, 0, 0)) # 目
draw.text((240, 290), nose, font=font, fill=(0, 0, 0)) # 鼻
draw.text((250, 380), mouth, font=font, fill=(0, 0, 0)) # 口
draw.text((480, 240), "〃", font=font, fill=(0, 0, 0)) # 濁点
# 顔の輪郭(ベジェ曲線ではない)
contour = [
(100, 100), (110, 150), (110, 200), (100, 250), (100, 300),
(110, 340), (120, 380), (140, 410), (160, 440), (180, 460),
(200, 480), (220, 490), (240, 500), (260, 505), (280, 505),
(300, 500), (320, 500), (340, 495), (360, 495), (370, 490),
(390, 480), (410, 470), (430, 460), (450, 440), (470, 410),
(480, 380), (480, 360), (475, 340), (470, 310), (470, 280),
]
draw.line(contour, width=5, fill=(0, 0, 0), joint="curve")
# 画像の表示と保存
image.show()
image.save(file_name, "PNG")
moji = list(sys.argv[1])
brow = moji[0]
eye = moji[1]
nose = moji[2]
mouth = moji[3]
print(brow,eye,nose,mouth)
generate_henohenomoheji(brow,eye,nose,mouth, "heno-mohe.png")