Advertisement
here2share

# Tk_star_polygon_demo.py

Jul 28th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. # Tk_star_polygon_demo.py -- Note: the points are rounded
  2.  
  3. from Tkinter import Tk, Canvas, BOTH
  4.  
  5. root = Tk()
  6. root.geometry("400x400+30+30")
  7.  
  8. root.title("Star Polygon")
  9. canvas = Canvas()
  10.  
  11. def star_5pt(x,y,s):
  12.     a,b,c,d,e,f,g,h,j,k,m,n,p = 0,   96,  157,  180,  192,  250,  294,  308,  340,  357,  402,  476,  500
  13.     #                           a     b     c     d     e     f     g     h     j     k     m     n     p
  14.     plot_xy = [(a, d), (e, d), (f, a), (h, d), (p, d), (j, g), (m, n), (f, k), (b, n), (c, g)]
  15.     nova=[]
  16.     for xy in plot_xy:
  17.             xy = (xy[0]*0.002)*s+x,(xy[1]*0.002)*s+y
  18.             nova.append(xy)
  19.     return nova
  20.  
  21. star = star_5pt(50,50,300)
  22.  
  23. canvas.create_polygon(star,outline='purple',fill='yellow',width=5)
  24.  
  25. canvas.pack(fill=BOTH,expand=1)
  26.  
  27. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement