-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3D_CANVAS.py
More file actions
186 lines (100 loc) · 4.67 KB
/
3D_CANVAS.py
File metadata and controls
186 lines (100 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import tkinter as tk
import time
import numpy as np # py -m pip install (wtv package)
import random
import os
from Utilities import my_range, Canvas_2D, Point, beautiful_colors
# Access utilities.py
colors = os.path.join("tkinter_sound_colors", "colors.py")
# Access soundtrack.mp3
"""
TODO:
animation func
transparent option
camera , accessing z axis view?
"""
root = tk.Tk()
root.geometry('600x400')
root.title('3D Engine')
#transparency
# makes overall window transparent
# root.attributes("-alpha", 0.5)
#removes titlebar and close buttons
# root.overrideredirect(True)
# brings window to top of the window stack
# root.lift()
#ensures window stays on top all of other windows
# root.wm_attributes("-topmost", True)
#disabes user interaction w window
# root.wm_attributes("-disabled", True)
#any part of the window w the specific color becomes transparent
root.wm_attributes("-transparentcolor", "snow")
root.minsize(600, 400)
root.maxsize(1536, 864)
# root.attributes("-toolwindow", True)
#need to resize canvas so it fits with window size
#get new coordinates of window by winfo_screenwidth() and winfo_screenheight()
points = []
#cube
p1 = Point(1, 1, 1)
p2 = Point(1, 1, -1)
p3 = Point(1, -1, 1)
p4 = Point(1, -1, -1)
p5 = Point(-1, 1, 1)
p6 = Point(-1, 1, -1)
p7 = Point(-1, -1, 1)
p8 = Point(-1, -1, -1)
bg = random.choice(colors)
bg2 = random.choice(beautiful_colors)
canvas = Canvas_2D(root, 600, 400, 'white')
canvas.draw_axes()
canvas.draw_ticks()
# #choose size 1-10
canvas.create_cube(0, 0, 3)
# canvas.create_octahedron(3, 3, 8)
# canvas.create_triprism(0,0,7)
# canvas.create_triprism(1,0,7)
# canvas.create_cube(0, 0, 3)
canvas.place(relx = 0, rely = 0, relwidth = 1, relheight = 1)
# for i in range(9): #fun
# canvas.create_triprism(i, i, random.uniform(1,9))
# canvas.create_triprism(-i, -i, random.uniform(1,9))
# canvas.create_star(0,0,1)
#create object class for the auto rotate, put all these objects into it ig
"""
experimentation time!
"""
# color_button = tk.Button(root, text="Good color!", command=lambda: canvas.append_color(canvas.color))
# color_button.pack(side='top')
# switch_color_button = tk.Button(root, text="Different bg color!", command=lambda: canvas.switch_bg_color())
# switch_color_button.pack(side='top')
# canvas.auto_rotate(x=0, y=0, speed = .2, left=1) #type x to rotate x axis, type y to rotate y axis
#also speed argument
#command=lambda : btn1click()
# start_rotate_bt = tk.Button(root, text="Start rotation", activebackground="white", command=lambda: canvas.auto_rotate(x=0, y=0, left=1))
# start_rotate_bt.pack(side="left")
# stop_rotate_bt = tk.Button(root, text="Stop rotation", activebackground="white", command=lambda: canvas.stop_rotate())
# stop_rotate_bt.pack(side="right")
# initial_state_bt = tk.Button(root, text="Reset", activebackground="white", command=lambda: canvas.initial_state())
# initial_state_bt.pack(side="bottom")
# incspeed_bt = tk.Button(root, text="+ speed", command=lambda: canvas.increase_rotate_speed())
# incspeed_bt.pack(side="left")
# decspeed_bt = tk.Button(root, text="- speed", command=lambda: canvas.decrease_rotate_speed())
# decspeed_bt.pack(side="left")
# hide_cplane_bt = tk.Button(root, text="hide coordinate plane", command=lambda: canvas.hide_cordplane())
# hide_cplane_bt.pack(side="top")
# color_button = canvas.create_button(root, "Good color!", canvas.append_color(canvas.color), 'top', False)
hide_btns = canvas.create_button(root, "☰", lambda: canvas.hide_buttons(), 'top', 'nw', False)
glitch_bt = canvas.create_button(root, "glitch", lambda: canvas.glitch_effect(), 'top', 'nw', False)
switch_color_button = canvas.create_button(root, "Different bg color!", lambda: canvas.switch_bg_color(), 'top', 'nw', False)
start_rotate_bt = canvas.create_button(root, "Start rotation", lambda: canvas.auto_rotate(x=1, y=1, right=1), 'top', 'nw', False)
stop_rotate_bt = canvas.create_button(root, "Stop rotation", lambda: canvas.stop_rotate(),'top', 'nw', False)
initial_state_bt = canvas.create_button( root, "Reset", lambda: canvas.initial_state(), 'top', 'nw', False)
#user slider widget for speed
incspeed_bt = canvas.create_button(root, "+ speed", lambda: canvas.increase_rotate_speed(), 'top', 'nw', True)
decspeed_bt = canvas.create_button(root, "- speed", lambda: canvas.decrease_rotate_speed(), 'top', 'nw', True)
music_bt = canvas.create_button(root, "change_music", lambda: canvas.switch_music(), 'top', 'nw', True)
mute_bt = canvas.create_button(root, "pause music", lambda: canvas.pause_music(), 'top', 'nw', True)
hide_cplane_bt = canvas.create_button(root, "hide coordinate plane", lambda: canvas.hide_cordplane(), 'top', 'nw', False)
# canvas.update()
root.mainloop()