-
Notifications
You must be signed in to change notification settings - Fork 0
/
spectrumgui.py
52 lines (43 loc) · 1.3 KB
/
spectrumgui.py
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
import tkinter as tk
from tkinter import *
import time
import pyautogui
import math
s = 900
r = s//6
resolution = 3
t = tk.Tk()
t.geometry(str(s)+'x'+str(s))
t.title('Screenshot')
c = Canvas(t, width=s, height=s)
c.pack()
filler = []
for i in range(0,49,1):
if i%4==0:
filler.append((255, 0, 0))
elif i%4==1 or i%4==3:
filler.append((128,0,128))
else:
filler.append((0, 0, 255))
def rgb_to_hex(rgb):
return '#{:02x}{:02x}{:02x}'.format(rgb[0], rgb[1], rgb[2])
def gradient(color1, color2):
gradient = []
diff = (color2[0] - color1[0],color2[1] - color1[1],color2[2] - color1[2])
for i in range(0, r, resolution):
color = (color1[0] + diff[0]*i//(r), color1[1] + diff[1]*i//(r), color1[2] + diff[2]*i//(r))
gradient.append(color)
return gradient
num = 0
for y in range(0, s, r):
for x in range(0, s, r):
gl = gradient(filler[num], filler[num+7])
gr = gradient(filler[num+1], filler[num+8])
for k in range(0, r, resolution):
g = gradient(gl[k//resolution],gr[k//resolution])
for j in range(0, r, resolution):
c.create_rectangle(x+j, y+k, x+j+resolution, y+k+resolution, fill = rgb_to_hex(g[j//resolution]), outline = "")
a = 1
num+=1
num+=1
t.mainloop()