Last active
March 1, 2023 21:54
-
-
Save hlorand/a6649d8e8a2e744b3511c6bad88ba435 to your computer and use it in GitHub Desktop.
3D rotating cube in Python - only 15 lines of code https://imgur.com/87vnopo.gif
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 3D rotating cube in Python - only 15 lines of code https://imgur.com/87vnopo.gif | |
| import tkinter, math, time | |
| c = tkinter.Canvas(tkinter.Tk(), width=600, height=600) | |
| c.pack() | |
| while t := int(time.time()*60) : | |
| c.update() | |
| c.delete("all"); n = [] | |
| for p in range( t % 157, 628, 157 ): | |
| x = 180 * math.cos(p/100) + 300 | |
| y = 60 * math.sin(p/100) | |
| n.extend([[x,y+190],[x,y+410]]) | |
| for i in range(-2,len(n)-2): | |
| c.create_line(n[i], n[i+abs(i%2-1)], n[i], n[i+2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment