"""
tkinter.canvas
中华人民共和国国旗是五星红旗:旗面为红色,长方形,其长与高为三与二之比,
旗面左上方缀黄色五角星五颗。一星较大,其外接圆直径为旗高十分之三,居左;
四星较小,其外接圆直径为旗高十分之一,环拱于大星之右
作者:昨非
"""
import tkinter as tk
import math as m
root = tk.Tk()
w = tk.Canvas(root,width=600,height=400,background="red") #旗面
w.pack()
center_x_1 = 100 #主星
center_y_1 = 100
r1 = 60 #主星半径
star1=[
#左上点
center_x_1 - int(r1*m.sin(2*m.pi/5)),
center_y_1 - int(r1*m.cos(2*m.pi/5)),
#右上点
center_x_1 + int(r1*m.sin(2*m.pi/5)),
center_y_1 - int(r1*m.cos(2*m.pi/5)),
#左下点
center_x_1 - int(r1*m.sin(m.pi/5)),
center_y_1 + int(r1*m.cos(m.pi/5)),
#顶点
center_x_1,
center_y_1 - r1,
#右下点
center_x_1 + int(r1*m.sin(m.pi/5)),
center_y_1 + int(r1*m.cos(m.pi/5)),
]
r2 = 20#副星半径
center_x_2 = 200 #副星一
center_y_2 = 40
star2=[
#左上点
center_x_2 - int(r2*m.cos(2*m.pi/5+m.atan(0.6))),#√
center_y_2 + int(r2*m.sin(2*m.pi/5+m.atan(0.6))),#√
#右上点
center_x_2 - int(r2*m.cos(2*m.pi/5-m.atan(0.6))),#√
center_y_2 - int(r2*m.sin(2*m.pi/5-m.atan(0.6))),#√
#左下点
center_x_2 + int(r2*m.cos(m.pi/5-m.atan(0.6))),
center_y_2 + int(r2*m.sin(m.pi/5-m.atan(0.6))),
#顶点
center_x_2 - int(r2*m.cos(m.atan(0.6))), #√
center_y_2 + int(r2*m.sin(m.atan(0.6))), #√
#右下点
center_x_2 + int(r2*m.cos(m.pi/5+m.atan(0.6))),
center_y_2 - int(r2*m.sin(m.pi/5+m.atan(0.6))),
]
center_x_3 = 240 #副星二
center_y_3 = 80
star3=[
#左上点
center_x_3 - int(r2*m.cos(2*m.pi/5+m.atan(1/7))),#√
center_y_3 + int(r2*m.sin(2*m.pi/5+m.atan(1/7))),#√
#右上点
center_x_3 - int(r2*m.cos(2*m.pi/5-m.atan(1/7))),#√
center_y_3 - int(r2*m.sin(2*m.pi/5-m.atan(1/7))),#√
#左下点
center_x_3 + int(r2*m.cos(m.pi/5-m.atan(1/7))),#√
center_y_3 + int(r2*m.sin(m.pi/5-m.atan(1/7))), #√
#顶点
center_x_3 - int(r2*m.cos(m.atan(1/7))), #√
center_y_3 + int(r2*m.sin(m.atan(1/7))), #√
#右下点
center_x_3 + int(r2*m.cos(m.pi/5+m.atan(1/7))),
center_y_3 - int(r2*m.sin(m.pi/5+m.atan(1/7))),
]
center_x_4 = 240 #副星三
center_y_4 = 140
star4=[
#左上点
center_x_4 - int(r2*m.cos(2*m.pi/5-m.atan(2/7))),
center_y_4 + int(r2*m.sin(2*m.pi/5-m.atan(2/7))),
#右上点
center_x_4 - int(r2*m.cos(2*m.pi/5+m.atan(2/7))),#√
center_y_4 - int(r2*m.sin(2*m.pi/5+m.atan(2/7))),#√
#左下点
center_x_4 + int(r2*m.cos(m.pi/5+m.atan(2/7))),
center_y_4 + int(r2*m.sin(m.pi/5+m.atan(2/7))),
#顶点
center_x_4 - int(r2*m.cos(m.atan(2/7))), #√
center_y_4 - int(r2*m.sin(m.atan(2/7))), #√
#右下点
center_x_4 + int(r2*m.cos(m.pi/5-m.atan(2/7))),
center_y_4 - int(r2*m.sin(m.pi/5-m.atan(2/7))),
]
center_x_5 = 200 #副星四
center_y_5 = 180
star5=[
#左上点
center_x_5 - int(r2*m.cos(2*m.pi/5-m.atan(4/5))),#√
center_y_5 + int(r2*m.sin(2*m.pi/5-m.atan(4/5))),#√
#右上点
center_x_5 - int(r2*m.cos(2*m.pi/5+m.atan(4/5))),#√
center_y_5 - int(r2*m.sin(2*m.pi/5+m.atan(4/5))),#√
#左下点
center_x_5 + int(r2*m.cos(m.pi/5+m.atan(4/5))),#√
center_y_5 + int(r2*m.sin(m.pi/5+m.atan(4/5))), #√
#顶点
center_x_5 - int(r2*m.cos(m.atan(4/5))), #√
center_y_5 - int(r2*m.sin(m.atan(4/5))), #√
#右下点
center_x_5 + int(r2*m.cos(m.pi/5-m.atan(4/5))),
center_y_5 - int(r2*m.sin(m.pi/5-m.atan(4/5))),
]
stars=[star1,star2,star3,star4,star5]
for star in stars:
w.create_polygon(star,outline="",fill="yellow")
tk.mainloop()