from tkinter import *
import math as m
root = Tk()
w = Canvas(root, width=200, height=100)
w.pack()
center_x=100
center_y=50
r = 50
points = [
# 左上点
center_x - int(r * m.sin(2*m.pi / 5)),
center_y - int(r * m.cos(2*m.pi / 5)),
# 右上点
center_x + int(r * m.sin(2*m.pi / 5)),
center_y - int(r * m.cos(2*m.pi / 5)),
# 左下角
center_x - int(r * m.sin(m.pi / 5)),
center_y + int(r * m.cos(m.pi / 5)),
# 顶点
center_x,
center_y - r,
# 右下点
center_x + int(r * m.sin(m.pi / 5)),
center_y + int(r * m.cos(m.pi / 5))
]
w.create_polygon(points, outline='green', fill='yellow')
mainloop()
Python 画五角星
最新推荐文章于 2024-09-23 10:31:04 发布