|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
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(2 * m.pi / 10)),center_y + int(r * m.cos(m.pi / 5))
]
w.create_polygon(points,outline="green",fill="yellow")
mainloop()
为什么上面的代码画出来的五角星,中心区域没有被填充成黄色,要怎么改进? |
|