|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- from tkinter import *
- import math as m
- root = Tk()
- w = Canvas(root, width=200, height=100, background="red")
- 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="", fill="")
- mainloop()
复制代码
左上點的y座標,我想不懂,為什麼是中心點減去r*cos ?我看圖形,認為應該是用加。
請闆:我是什麼東西想錯了?
|
|