Advertisement
here2share

# OnePointPerspectiveCube.py

Oct 17th, 2018
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.09 KB | None | 0 0
  1. # OnePointPerspectiveCube.py
  2.  
  3. from Tkinter import *
  4.  
  5. def shape(event):
  6.     global line_one, line_two, line_three, line_four, polygon_bottom, polygon_top, polygon_left, polygon_right
  7.     canvas.delete(line_one, line_two, line_three, line_four,polygon_bottom, polygon_top, polygon_left, polygon_right)
  8.  
  9.     # A HORRIBLE MESS OF VARIABLES. DON'T LOOK. IT MIGHT BURN YOUR EYES.
  10.     x = event.x
  11.     y = event.y
  12.     x1 = x-50
  13.     y1 = y-50
  14.     x2 = x+50
  15.     y2 = y+50
  16.     x3 = (300+x1)/2
  17.     y3 = (300+y2)/2
  18.     x4 = (300+x1+100)/2
  19.     y4 = (300+y2)/2
  20.     x5 = (300+x1)/2
  21.     y5 = (300+y1)/2
  22.     x6 = (300+x1)/2
  23.     y6 = (300+y2)/2
  24.     x7 = (300+x1+100)/2
  25.     y7 = (300+y1)/2
  26.  
  27.  
  28.     # UNCOMMENT FOR A FREE COOKIE!
  29.     # line_one = canvas.create_line(300,300,x1,y1, fill='white')
  30.     # line_two = canvas.create_line(300,300,x1+100,y1, fill='white')
  31.     # line_three = canvas.create_line(300,300,x2-100,y2, fill='white')
  32.     # line_four = canvas.create_line(300,300,x2,y2, fill='white')
  33.  
  34.     polygon_bottom = canvas.create_polygon(x3, y3, x4, y4, x2, y2, x2 - 100, y2, outline='red', fill='', width=4)
  35.     polygon_left = canvas.create_polygon(x5, y5, x6, y6, x2 - 100, y2, x1, y1, outline='red', fill='', width=4)
  36.     polygon_top = canvas.create_polygon(x5, y5, x1, y1, x1+100, y1, x7, y7, outline='red', fill='', width=4)
  37.     polygon_right= canvas.create_polygon(x2,y2,x1+100,y1,x7,y7, x4, y4, outline='red', fill='', width=4)
  38.  
  39.  
  40. tk = Tk()
  41. tk.title("OnePointPerspectiveCube")
  42. tk.configure(background='black')
  43. label = Label(text = "Click and Drag to See the Shape",background='black',foreground='white')
  44. label.pack()
  45. canvas = Canvas(width=600, height=600, bg='black')
  46. canvas.pack()
  47.  
  48. line_one = canvas.create_line(0,0,0,0)
  49. line_two = canvas.create_line(0,0,0,0)
  50. line_three = canvas.create_line(0,0,0,0)
  51. line_four = canvas.create_line(0,0,0,0)
  52. polygon_bottom = canvas.create_polygon(0,0,0,0,0,0)
  53. polygon_top = canvas.create_polygon(0,0,0,0,0,0)
  54. polygon_left = canvas.create_polygon(0,0,0,0,0,0)
  55. polygon_right = canvas.create_polygon(0,0,0,0,0,0)
  56.  
  57. canvas.bind("<B1-Motion>",shape)
  58.  
  59. tk.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement