import math
from PIL import Image, ImageDraw
# 定数
VERTEX_COUNT = 5 # 頂点の数
LINE_WIDTH = 1 # 辺の太さ
RADIUS = 96 # 外接円の半径(各頂点の中心からの距離)
IMAGE_WIDTH = 256 # 画像の横幅
IMAGE_HEIGHT = 256 # 画像の縦幅
# 色
COLOR_BLACK = (0, 0, 0)
COLOR_WHITE = (255, 255, 255)
COLOR_YELLOW = (255, 255, 0)
# 色の指定
BACKGROUND_COLOR = COLOR_WHITE # 背景の色
EDGE_COLOR = COLOR_BLACK # 辺の色
FILL_COLOR = COLOR_YELLOW # 内部の領域の色
img = Image.new(mode="RGB", size=(IMAGE_WIDTH, IMAGE_HEIGHT), color=BACKGROUND_COLOR)
draw = ImageDraw.Draw(img)
origin_offset_x = IMAGE_WIDTH // 2 # 中心のX座標
origin_offset_y = IMAGE_HEIGHT // 2 # 中心のY座標
delta = 2.0 * math.pi / VERTEX_COUNT
vertices = []
for i in range(VERTEX_COUNT):
vertices.append(
(
int(origin_offset_x + RADIUS * math.cos(delta * i)),
int(origin_offset_y + RADIUS * math.sin(delta * i)),
)
)
draw.polygon(vertices, outline=EDGE_COLOR, fill=FILL_COLOR)
img.save("output.png")