├── README.md
├── linerenderprogram.py
├── pointplotter.py
├── squareroot.py
└── turtlecard.circ
/README.md:
--------------------------------------------------------------------------------
1 | # Turtle Card 200X3D
2 |
3 | https://www.youtube.com/watch?v=rxjLSylOIGc
4 |
5 | You can find the instructions to simulate it down below
6 |
7 | 
8 |
9 | Before you try it out, I recommend watching my youtube video first if you have no idea what you're doing
10 |
11 | (If you are stuck and don't know what to do in any of these steps, make sure to rewatch my youtube video or leave a comment with your problem or ask me in my discord https://discord.gg/rczqRyqnyR)
12 |
13 | # Update: pointplotter.py file has an easy to use UI instead of having to use a list to make your shapes.
14 |
15 | 
16 |
17 | # How to run the Graphics Card
18 | 1. Make sure you have Logisim Evolution installed.
19 | 2. Open 16bitGPU3.circ using Logisim.
20 | 3. Select the "multicore" circuit.
21 |
22 | 
23 |
24 | 4. Go to the "Simulate" tab and make sure Auto-Tick is enabled, and is set to 2048.0 KHz.
25 |
26 |
27 | 5. Go from the Design to the Simulate tab on the left and Enable Clock Ticks
28 |
29 |
30 | 6. Press the "RST" button to reset the graphics card and press "1" to start rendering.
31 |
32 |
33 | Optional: You can use these two DIP switches to set the position of the light source in binary.
34 | 
35 |
36 | # How to change the object it renders (outdated instructions, use the UI)
37 |
38 | 1. Open pointplotter.py and replace the output file location to your preferred location. (make sure it is a .hex file)
39 | 
40 |
41 | 2. Select which of the template shapes you want to render by uncommenting them or create your own.
42 | 
43 | 
44 |
45 | 3. Run the program.
46 |
47 | 4. Open the turtle card in Logisim Evolution, and make sure to import the output hex files A, B, and types into the corresponding ROMs.
48 | 
49 |
50 | 5. Follow the "How to run the Graphics Card" instructions
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/linerenderprogram.py:
--------------------------------------------------------------------------------
1 | #make sure to replace this with the location of the .hex file you want the program to be outputed to.
2 | output_folder = ''
3 |
4 |
5 | #Control Bits
6 | # 1 - Pulse yi
7 | # 2 - yi CLR
8 | # 3 - DY < 0 yi--
9 | # 4 - DY STR
10 | # 5 - DY < 0 invert
11 | # 6 - D IN
12 | # 7 - X CLR
13 | # 8 - X UP
14 | # 9 - X LD
15 | # 10 - PLT
16 | # 11 - RST screen
17 | # 12 - Y IN
18 | # 13 - Y y1/yi
19 | # 14 - Y sub IN
20 | # 15 - D sub IN
21 | # 16 - D sub/d2
22 | # 17 - D+(2*(dy-dx))/D+2*dy
23 | # 18 - Comparator WE
24 |
25 | #
26 | #
27 | #
28 | #
29 | #00000000000000000
30 |
31 | program = ["CLR","YIUP","YI--CHK","0","YI--CHK","-DY","DIN","DSUB","YIN","YSUB","LDX","PLT",
32 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
33 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
34 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
35 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
36 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
37 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
38 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
39 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
40 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
41 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
42 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
43 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
44 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
45 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
46 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
47 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
48 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
49 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
50 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
51 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
52 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
53 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
54 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
55 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
56 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
57 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
58 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
59 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
60 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
61 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
62 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
63 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
64 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
65 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
66 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
67 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
68 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
69 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
70 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
71 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
72 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
73 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
74 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
75 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
76 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
77 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
78 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
79 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
80 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
81 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
82 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
83 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
84 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
85 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
86 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
87 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
88 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP","PLT",
89 | "D>0yi","YSUB","D>0d1","D>0d2","DSUB","XUP"]
90 |
91 |
92 | output = []
93 |
94 | for i in program:
95 | if i == "CLR":
96 | output.append(hex(int("000110110001100010", 2)))
97 | elif i == "YIUP":
98 | output.append(hex(int("00000000000000001", 2)))
99 | elif i == "YI--CHK":
100 | output.append(hex(int("00000000000000100", 2)))
101 | elif i == "0":
102 | output.append(hex(int("00000000000000000", 2)))
103 | elif i == "-DY":
104 | output.append(hex(int("00000000000011000", 2)))
105 | elif i == "DSUB":
106 | output.append(hex(int("00100000000000000", 2)))
107 | elif i == "YSUB":
108 | output.append(hex(int("00010000000000000", 2)))
109 | elif i == "DIN":
110 | output.append(hex(int("00000000000100000", 2)))
111 | elif i == "YIN":
112 | output.append(hex(int("00000100000000000", 2)))
113 | elif i == "LDX":
114 | output.append(hex(int("00000000110000000", 2)))
115 | elif i == "PLT":
116 | output.append(hex(int("00000001000000000", 2)))
117 | elif i == "D>0yi":
118 | output.append(hex(int("00001100000000000", 2)))
119 | elif i == "D>0d1":
120 | output.append(hex(int("01000000000100000", 2)))
121 | elif i == "D>0d2":
122 | output.append(hex(int("11000000000100000", 2)))
123 | elif i == "XUP":
124 | output.append(hex(int("00000000010000000", 2)))
125 |
126 |
127 |
128 |
129 |
130 | with open(output_folder, 'w') as f:
131 | for e in output:
132 | f.write(e + "\n")
133 | print(output)
134 | f.close()
--------------------------------------------------------------------------------
/pointplotter.py:
--------------------------------------------------------------------------------
1 | import tkinter as tk
2 | from tkinter import messagebox
3 | from tkinter import ttk
4 | from tkinter import font as tkFont
5 | from tkinter import colorchooser
6 | #make sure to replace this with the location of the .hex file you want the A points to be outputed to.
7 | output_folderA = ''
8 |
9 | #make sure to replace this with the location of the .hex file you want the B points to be outputed to.
10 | output_folderB = ''
11 |
12 | #make sure to replace this with the location of the .hex file you want the color values to be outputed to.
13 | output_color = ''
14 |
15 | vc = 0
16 | cnt = 0
17 | bcnt = 0
18 |
19 | v = []
20 | lines = []
21 | colors = []
22 |
23 | out1 = []
24 | out2 = []
25 |
26 | #v = [[31,31,0],[34,31,0],[31,32,0],[34,32,0],[31,33,0],[34,33,0],
27 | #[1,1,0],[4,1,0],[1,2,0],[4,2,0],[1,3,0],[4,3,0]]
28 | #lines = [v[0],v[1],v[2],v[3],v[4],v[5],
29 | #v[6],v[7],v[8],v[9],v[10],v[11]]
30 |
31 | #v = [[1,1,0],[9,1,0],[1,9,0],[9,9,0]]
32 | #lines = [v[0],v[1],v[0],v[2],v[2],v[3],v[1],v[3]]
33 |
34 | #pyramid 1
35 | #v = [[4,6,0],[20,6,0],[4,54,0],[20,54,0],[48,30,12]]
36 | #lines = [v[0],v[1],v[0],v[2],v[1],v[3],v[2],v[3],v[4],v[0],v[4],v[1],v[4],v[3],v[4],v[2]]
37 |
38 | #pyramid 2
39 | #v = [[32,32,0],[8,24,0],[56,24,0],[32,22,32],[32,8,16]]
40 | #lines = [v[2],v[0],v[1],v[0],v[3],v[1],v[3],v[2],v[4],v[0],v[4],v[1],v[4],v[3],v[4],v[2]]
41 |
42 | #cube 1
43 | #v = [[32,44,0],[8,36,0],[56,36,0],[32,34,32],[32,14,0],[8,6,0],[56,6,0],[32,2,32]]
44 | #lines = [v[2],v[0],v[1],v[0],v[3],v[1],v[3],v[2],v[6],v[4],v[5],v[4],v[7],v[5],v[7],v[6],
45 | #v[0],v[4],v[1],v[5],v[2],v[6],v[3],v[7]]
46 |
47 |
48 |
49 | #v = [[5,56,0], [5,56,56], [56,56,0], [56,56,56]]
50 | #lines = [v[0],v[1],v[1],v[3],v[2],v[3],v[2],v[0]]
51 |
52 | #room
53 | #v = [[5,5,0],[16,16,35]] WIP
54 | #lines = [v[0], v[1]] WIP
55 |
56 | #v = [[0,0,0],[128,128,0]]
57 | #lines = [v[0],v[1]]
58 |
59 | def plotLineLow(x0,y0,x1,y1,lis):
60 | x0 = int(x0)
61 | y0 = int(y0)
62 | x1 = int(x1)
63 | y1 = int(y1)
64 | dx = x1-x0
65 | dy = y1-y0
66 | yi = 1
67 | if dy < 0:
68 | yi = -1
69 | dy = -dy
70 | D = (2*dy)-dx
71 | y = y0
72 |
73 | for x in range(x0,x1):
74 | lis.append([x,y])
75 | if D > 0:
76 | y = y + yi
77 | D = D + (2*(dy-dx))
78 | else:
79 | D = D + 2*dy
80 |
81 | def plotLineHigh(x0,y0,x1,y1,lis):
82 | x0 = int(x0)
83 | y0 = int(y0)
84 | x1 = int(x1)
85 | y1 = int(y1)
86 | dx = x1-x0
87 | dy = y1-y0
88 | xi = 1
89 | if dx < 0:
90 | xi = -1
91 | dx = -dx
92 | D = (2*dx)-dy
93 | x = x0
94 |
95 | for y in range(y0,y1):
96 | lis.append([x,y])
97 | if D > 0:
98 | x = x + xi
99 | D = D + (2*(dx-dy))
100 | else:
101 | D = D + 2*dx
102 |
103 | def plotLine(x0,y0,x1,y1,lis):
104 | if abs(y1-y0) < abs(x1-x0):
105 | if x0 > x1:
106 | plotLineLow(x1,y1,x0,y0,lis)
107 | else:
108 | plotLineLow(x0,y0,x1,y1,lis)
109 | else:
110 | if y0 > y1:
111 | plotLineHigh(x1,y1,x0,y0,lis)
112 | else:
113 | plotLineHigh(x0,y0,x1,y1,lis)
114 |
115 | def Line(x0,y0,z0,x1,y1,z1,lis,fov):
116 | #print("A: [" + str(x0) + "," + str(y0) + "," + str(z0) + "]")
117 | #print("B: [" + str(x1) + "," + str(y1) + "," + str(z1) + "]")
118 | x_zero = (x0*fov)/(fov+z0)
119 | y_zero = (y0*fov)/(fov+z0)
120 | x_one = (x1*fov)/(fov+z1)
121 | y_one = (y1*fov)/(fov+z1)
122 | plotLine(x_zero,y_zero,x_one,y_one,lis)
123 |
124 |
125 |
126 |
127 | def shaded_plane(a,b,c,d,colorLight,colorDark):
128 | Line(a[0]+1,a[1],a[2],c[0]+1,c[1],c[2],out1,256)
129 | Line(b[0],b[1],b[2],d[0],d[1],d[2],out2,256)
130 | global vc
131 | global cnt
132 | global bcnt
133 | v.append(a) #0
134 | v.append(b) #1
135 | v.append(c) #2
136 | v.append(d) #3
137 | lines.append(v[0+cnt+vc])
138 | lines.append(v[1+cnt+vc])
139 | colors.append(1)
140 | lines.append(v[0+cnt+vc])
141 | lines.append(v[2+cnt+vc])
142 | colors.append(1)
143 | lines.append([v[2+cnt+vc][0]+1,v[2+cnt+vc][1],v[2+cnt+vc][2]])
144 | lines.append(v[3+cnt+vc])
145 | colors.append(1)
146 | lines.append(v[1+cnt+vc])
147 | lines.append(v[3+cnt+vc])
148 | colors.append(1)
149 | for i in range(len(out1)):
150 | if i == 0:
151 | bcnt += 1
152 | continue
153 | v.append([out1[bcnt][0],out1[bcnt][1],0])
154 | v.append([out2[bcnt][0],out2[bcnt][1],0])
155 | #print("First: ", out1[bcnt][0],out1[bcnt][1],0)
156 | #print("Second: ", out2[bcnt][0],out2[bcnt][1],0)
157 | lines.append(v[4+cnt+vc])
158 | lines.append(v[5+cnt+vc])
159 | colors.append(0)
160 | cnt += 2
161 | bcnt += 1
162 | vc += 4
163 | bcnt = 0
164 | #print("Output 1: ", out1)
165 | #print("Output 2: ", out2)
166 | out1.clear()
167 | out2.clear()
168 |
169 |
170 | '''
171 | def shaded_triangle(a,b,c):
172 | global vc
173 | global cnt
174 | bcnt = 0
175 | v.append(a) #0
176 | v.append(b) #1
177 | v.append(c) #2
178 | lines.append(v[0+vc])
179 | types.append(1)
180 | lines.append(v[1+vc])
181 | types.append(1)
182 | lines.append([v[0+vc][0]+1,v[0+vc][1],v[0+vc][2]])
183 | types.append(1)
184 | lines.append(v[2+vc])
185 | types.append(1)
186 | lines.append(v[1+vc])
187 | types.append(1)
188 | lines.append(v[2+vc])
189 | types.append(1)
190 | Line(b[0]+1,b[1],b[2],a[0]+1,a[1],a[2],out1,256)
191 | Line(b[0],b[1],b[2],c[0],c[1],c[2],out2,256)
192 | for i in out1:
193 | v.append([out1[bcnt][0],out1[bcnt][1],0])
194 | v.append([out2[bcnt][0],out2[bcnt][1],0])
195 | lines.append(v[3+cnt])
196 | types.append(0)
197 | lines.append(v[4+cnt])
198 | types.append(0)
199 | cnt += 2
200 | bcnt += 1
201 | vc += 4
202 | out1.clear()
203 | out2.clear()
204 |
205 | '''
206 |
207 | # code for UI
208 |
209 | pointAX = 0
210 | pointAY = 0
211 | pointAset = False
212 |
213 | pointBX = 0
214 | pointBY = 0
215 | pointBset = False
216 |
217 | pointCX = 0
218 | pointCY = 0
219 | pointCset = False
220 |
221 | pointDX = 0
222 | pointDY = 0
223 | pointDset = False
224 |
225 | color_code = "ffffff"
226 |
227 | pointsAB = []
228 |
229 |
230 |
231 | window = tk.Tk()
232 |
233 | window.minsize(705,675)
234 | window.maxsize(705,675)
235 |
236 | canvas = tk.Canvas()
237 | window.title("Point Plotter (Preview may not always be accurate) (Shaded objects can be buggy)")
238 |
239 | window.rowconfigure(0,weight=1)
240 | window.columnconfigure(1,weight=1)
241 |
242 | helv16 = tkFont.Font(family='Helvetica', size=16, weight='bold')
243 | helv16_nobold = tkFont.Font(family='Helvetica', size=16)
244 |
245 | def drawLine(a,b,c,d):
246 | global pointsAB
247 | plotLine(a, b, c, d, pointsAB)
248 | colors.append(color_code)
249 | for m in pointsAB:
250 | drawpixel(m[0],m[1])
251 | pointsAB = []
252 |
253 | def pickColor():
254 | global color_code
255 | color_code = str((colorchooser.askcolor(title ="Choose color"))[1]).replace('#','')
256 | linfo['text'] = "Point A: (" + str(pointAX) + "," + str(pointAY) + ") \n Point B: (" + str(pointBX) + "," + str(pointBY) + ") \n Point C: (" + str(pointCX) + "," + str(pointCY) + ") \n Point D: (" + str(pointDX) + "," + str(pointDY) + ") \n Color: " + color_code
257 |
258 | def CreateLine():
259 | global vc
260 | global pointAset
261 | global pointBset
262 | global pointAX
263 | global pointAY
264 | global pointBX
265 | global pointBY
266 | global pointsAB
267 | drawLine(pointAX,pointAY,pointBX,pointBY)
268 | v.append([pointAX, pointAY, 0])
269 | v.append([pointBX, pointBY, 0])
270 | lines.append(v[0+vc])
271 | lines.append(v[1+vc])
272 | vc+=2
273 | pointAX = 0
274 | pointAY = 0
275 | pointBX = 0
276 | pointBY = 0
277 | pointAset = False
278 | pointBset = False
279 | pointsAB = []
280 | linfo['text'] = "Point A: (0,0) \n Point B: (0,0) \n Point C: (0,0) \n Point D: (0,0) \n Color: " + color_code
281 |
282 |
283 | def CreatePlane():
284 | global pointAset
285 | global pointBset
286 | global pointCset
287 | global pointDset
288 | global pointAX
289 | global pointAY
290 | global pointBX
291 | global pointBY
292 | global pointCX
293 | global pointCY
294 | global pointDX
295 | global pointDY
296 | global pointsAB
297 | shaded_plane([pointAX, pointAY,0],[pointBX, pointBY,0],[pointCX, pointCY,0],[pointDX, pointDY,0],str(color_code),"222222")
298 | for e in range(0,len(v),2):
299 | drawLine(v[e][0],v[e][1],v[e+1][0],v[e+1][1])
300 | print("draw line: " + str(v[e][0]) + "-" + str(v[e][1]) + " " + str(v[e+1][0]) + "-" + str(v[e+1][1]) + "")
301 | print(v)
302 | pointAX = 0
303 | pointAY = 0
304 | pointBX = 0
305 | pointBY = 0
306 | pointCX = 0
307 | pointCY = 0
308 | pointDX = 0
309 | pointDY = 0
310 | pointAset = False
311 | pointBset = False
312 | pointCset = False
313 | pointDset = False
314 | pointsAB = []
315 | linfo['text'] = "Point A: (0,0) \n Point B: (0,0) \n Point C: (0,0) \n Point D: (0,0) \n Color: " + color_code
316 | '''
317 | def CreateTriangle():
318 | global pointAset
319 | global pointBset
320 | global pointCset
321 | global pointDset
322 | global pointAX
323 | global pointAY
324 | global pointBX
325 | global pointBY
326 | global pointCX
327 | global pointCY
328 | global pointDX
329 | global pointDY
330 | global pointsAB
331 | shaded_triangle([pointAX, pointAY,0],[pointBX, pointBY,0],[pointCX, pointCY,0])
332 | for e in range(0,len(v),2):
333 | drawLine(v[e][0],v[e][1],v[e+1][0],v[e+1][1])
334 | print("draw line: " + str(v[e][0]) + "-" + str(v[e][1]) + " " + str(v[e+1][0]) + "-" + str(v[e+1][1]) + "")
335 | print(v)
336 | pointAX = 0
337 | pointAY = 0
338 | pointBX = 0
339 | pointBY = 0
340 | pointCX = 0
341 | pointCY = 0
342 | pointDX = 0
343 | pointDY = 0
344 | pointAset = False
345 | pointBset = False
346 | pointCset = False
347 | pointDset = False
348 | pointsAB = []
349 | linfo['text'] = "Point A: (0,0) \n Point B: (0,0) \n Point C: (0,0) \n Point D: (0,0) \n Color: " + color_code
350 |
351 | '''
352 |
353 | frm_buttons = tk.Frame(window, relief=tk.RAISED, bd=2)
354 | btn_1 = tk.Button(frm_buttons, text="Line", font=helv16, width=14,command=CreateLine)
355 | btn_2 = tk.Button(frm_buttons, text="Shaded Plane", font=helv16, width=14,command=CreatePlane)
356 | btn_3 = tk.Button(frm_buttons, text="Shaded Triangle", font=helv16, width=14,state="disabled")
357 | btn_4 = tk.Button(frm_buttons, text="Color Picker", font=helv16, width=14,command=pickColor)
358 |
359 |
360 |
361 |
362 | btn_1.grid(row=0, column=0, sticky="ew", padx=5, pady=5)
363 | btn_2.grid(row=1, column=0, sticky="ew", padx=5, pady=5)
364 | btn_3.grid(row=2, column=0, sticky="ew", padx=5,pady=5)
365 | btn_4.grid(row=3, column=0, sticky="ew", padx=5,pady=5)
366 |
367 |
368 | l2 = tk.Label(window, text = "X",font=helv16)
369 | l2.grid(row=1,column=0,sticky="es", pady=5)
370 | l3 = tk.Label(window, text = "Y",font=helv16)
371 | l3.grid(row=2,column=0,sticky="en", pady=5)
372 |
373 | linfo = tk.Label(window, text = "Point A: (0,0) \n Point B: (0,0) \n Point C: (0,0) \n Point D: (0,0) \n Color: #ffffff",font=helv16)
374 | linfo.grid(row=2,column=1,sticky="se")
375 |
376 | bkg = canvas.create_rectangle(0,0,500,500,outline="black",fill="black")
377 | canvas.grid(row=0,column=1,sticky="nsew")
378 |
379 | def drawpixel(x,y):
380 | canvas.create_rectangle(int(x)*7.8125,int(y)*7.8125,(int(x)*7.8125)+7.8125,(int(y)*7.8125)+7.8125,outline="#"+color_code,fill="#"+color_code)
381 |
382 |
383 | def plot():
384 | global pointAset
385 | global pointBset
386 | global pointCset
387 | global pointDset
388 | global pointAX
389 | global pointAY
390 | global pointBX
391 | global pointBY
392 | global pointCX
393 | global pointCY
394 | global pointDX
395 | global pointDY
396 | global color_code
397 | if cordx.get() == "" or cordy.get() == "":
398 | messagebox.showerror("Error","There needs to be an X and Y value set.")
399 | if int(cordx.get()) < 0 or int(cordx.get()) > 63:
400 | messagebox.showerror("Error","X value needs to be an integer between 0 and 63.")
401 | if int(cordy.get()) < 0 or int(cordy.get()) > 63:
402 | messagebox.showerror("Error","Y value needs to be an integer between 0 and 63.")
403 | drawpixel(int(cordx.get()), int(cordy.get()))
404 | if pointCset == True:
405 | pointDX = int(cordx.get())
406 | pointDY = int(cordy.get())
407 | pointDset = True
408 | linfo['text'] = "Point A: (" + str(pointAX) + "," + str(pointAY) + ") \n Point B: (" + str(pointBX) + "," + str(pointBY) + ") \n Point C: (" + str(pointCX) + "," + str(pointCY) + ") \n Point D: (" + str(pointDX) + "," + str(pointDY) + ") \n Color: " + color_code
409 | return
410 | if pointBset == True:
411 | pointCX = int(cordx.get())
412 | pointCY = int(cordy.get())
413 | pointCset = True
414 | linfo['text'] = "Point A: (" + str(pointAX) + "," + str(pointAY) + ") \n Point B: (" + str(pointBX) + "," + str(pointBY) + ") \n Point C: (" + str(pointCX) + "," + str(pointCY) + ") \n Point D: (0,0) \n Color: " + color_code
415 | return
416 | if pointAset == True:
417 | pointBX = int(cordx.get())
418 | pointBY = int(cordy.get())
419 | pointBset = True
420 | linfo['text'] = "Point A: (" + str(pointAX) + "," + str(pointAY) + ") \n Point B: (" + str(pointBX) + "," + str(pointBY) + ") \n Point C: (0,0) \n Point D: (0,0) \n Color: " + color_code
421 | return
422 | if pointAset == False:
423 | pointAX = int(cordx.get())
424 | pointAY = int(cordy.get())
425 | pointAset = True
426 | linfo['text'] = "Point A: (" + str(pointAX) + "," + str(pointAY) + ") \n Point B: (0,0) \n Point C: (0,0) \n Point D: (0,0) \n Color: " + color_code
427 | return
428 |
429 |
430 |
431 |
432 |
433 |
434 | btn_plot = tk.Button(window, text="Plot", font=helv16, width=6,command=plot)
435 | btn_plot.grid(row=1,column=1,sticky="ws",padx=100)
436 |
437 |
438 | cordx = tk.Entry(window,font=helv16_nobold,width=5)
439 | cordx.grid(row=1,column=1,sticky="ws", pady=5)
440 |
441 | cordy = tk.Entry(window,font=helv16_nobold,width=5)
442 | cordy.grid(row=2,column=1,sticky="wn", pady=5)
443 |
444 |
445 |
446 | frm_buttons.grid(row=0, column=0, sticky="ns")
447 |
448 |
449 |
450 |
451 |
452 | window.mainloop()
453 |
454 | #shaded_plane([5,45,64],[37,45,64],[5,52,0],[37,52,0])
455 | #shaded_plane([0,0,0],[64,0,0],[0,64,0],[64,64,0])
456 |
457 | #shaded_plane([8,6,0],[32,14,0],[8,36,0],[32,44,0])
458 | #shaded_plane([8,6,0],[32,2,32],[32,14,0],[56,6,0])
459 |
460 |
461 |
462 |
463 | #shaded_plane([16,24,0],[48,24,0],[8,40,0],[56,40,0],"red")
464 |
465 | #shaded_plane([8,40,0],[56,40,0],[10,63,0],[54,63,0],"red")
466 |
467 |
468 | #shaded_plane([30,30,0],[34,30,0],[30,34,0],[34,34,0], "")
469 |
470 |
471 |
472 |
473 | #shaded_triangle([0,32,0],[16,0,0],[32,32,0])
474 |
475 | #shaded_triangle([0,12,0],[8,0,0],[16,12,0])
476 |
477 | #shaded_plane([2,2,0],[7,2,0],[2,7,0],[7,7,0], "")
478 |
479 |
480 |
481 | program = []
482 |
483 | side = "B"
484 |
485 | num = 1
486 |
487 | for o in lines:
488 | eee = str(o[0]) + "-" + str(o[1]) + "-" + str(o[2])
489 | if num >= 2:
490 | program.append(eee)
491 | #program.append("0-0-0")
492 | #program.append("0-0-0")
493 | num = 1
494 | else:
495 | program.append(eee)
496 | num += 1
497 |
498 |
499 |
500 |
501 |
502 | outputA = []
503 | outputB = []
504 |
505 | for i in program:
506 | nums = []
507 | e = i.split("-")
508 | for k in e:
509 | l = bin(int(k))[2:]
510 | if len(l) < 16:
511 | l = "0"*(16-len(l)) + l
512 | nums.append(l)
513 | x = nums[0]
514 | y = nums[1]
515 | z = nums[2]
516 | if side == "B":
517 | side = "A"
518 | outputA.append(hex(int(str(z)+str(y)+str(x), 2)))
519 | elif side == "A":
520 | side = "B"
521 | outputB.append(hex(int(str(z)+str(y)+str(x), 2)))
522 |
523 |
524 |
525 |
526 | with open(output_folderA, 'w') as f:
527 | for e in outputA:
528 | f.write(e + "\n")
529 | f.close()
530 |
531 | with open(output_folderB, 'w') as f:
532 | for e in outputB:
533 | f.write(e + "\n")
534 | f.close()
535 |
536 | with open(output_color, 'w') as f:
537 | for e in colors:
538 | f.write(str(e) + "\n")
539 | f.close()
540 |
541 |
542 | print(outputA)
543 | print(outputB)
544 | print(colors)
545 |
546 |
547 |
548 |
549 |
550 |
551 |
--------------------------------------------------------------------------------
/squareroot.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | output_folder = ''
4 |
5 | output = []
6 |
7 | for i in range(8192):
8 | output.append(hex(round(math.sqrt(i))))
9 |
10 |
11 | with open(output_folder, 'w') as f:
12 | for e in output:
13 | f.write(e + "\n")
14 | print(output)
15 | f.close()
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------