代码:
from tkinter import *
import math as m
root = Tk()
w = Canvas(root,width=200,height=100)
w.pack()
x = 100
y = 50
r = 50
points = [
#左上点
x - int(r * m.sin(2 * m.pi / 5)),
y - int(r * m.cos(2 * m.pi / 5)),
#右上点
x + int(r * m.sin(2 * m.pi / 5)),
y - int(r * m.cos(2 * m.pi / 5)),
#左下点
x - int(r * m.sin(m.pi / 5)),
y + int(r * m.cos(m.pi / 5)),
#顶点
x,
y - r,
#右下点
x + int(r * m.sin(m.pi / 5)),
y + int(r * m.cos(m.pi / 5)),
]
w.create_polygon(points,outline="green",fill="yellow")
mainloop()
效果图: