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()

  • 相关阅读:
    CoreLocation
    通知(NSNotificationCenter)
    加载xib文件
    UITextField
    UIButton
    UILabel
    UIAlertController
    layoutSubviews
    Java AQS详解(转)
    Java中synchronized
  • 原文地址:https://www.cnblogs.com/themost/p/6776438.html
Copyright © 2011-2022 走看看