zoukankan      html  css  js  c++  java
  • Canvas绘制五角星

     1 from tkinter import *
     2 import math as m
     3 
     4 root = Tk()
     5 
     6 w = Canvas(root, width=200, height=100, background="red")
     7 w.pack()
     8 
     9 center_x = 100
    10 center_y = 50
    11 r = 50
    12 
    13 points = [
    14     # 左上点
    15     center_x - int(r * m.sin(2 * m.pi / 5)),
    16     center_y - int(r * m.cos(2 * m.pi / 5)),
    17     # 右上点
    18     center_x + int(r * m.sin(2 * m.pi / 5)),
    19     center_y - int(r * m.cos(2 * m.pi / 5)),
    20     # 左下点
    21     center_x - int(r * m.sin(m.pi / 5)),
    22     center_y + int(r * m.cos(m.pi / 5)),
    23     # 顶点
    24     center_x,
    25     center_y - r,
    26     # 右下点
    27     center_x + int(r * m.sin(m.pi / 5)),
    28     center_y + int(r * m.cos(m.pi / 5))
    29     ]
    30 
    31 w.create_polygon(points, outline="", fill="")
    32 
    33 mainloop()

  • 相关阅读:
    纪念又一次ak
    hdu5618
    bzoj3393
    bzoj3438
    [JSOI2007]建筑抢修
    [CQOI2014]数三角形
    [BZOJ2662][BeiJing wc2012]冻结
    [NOIP2015]运输计划
    [ZJOI2006]超级麻将
    [APIO2009]抢掠计划
  • 原文地址:https://www.cnblogs.com/themost/p/6776438.html
Copyright © 2011-2022 走看看