Much more cool structure

This commit is contained in:
clerie 2021-10-30 16:09:47 +02:00
parent d3202f30d1
commit 3faf247aca

View File

@ -9,8 +9,36 @@ PORT = 1234
W = 1920
H = 1080
s_w = 10
s_c = "FFC0CB"
s_w = 100
s_c = "BFFFD4"
s_c2 = "FFBFEA"
def color_to_tuple(color):
return (int(color[0:2], 16), int(color[2:4], 16), int(color[4:6], 16))
def merge_tuple(a, b, o):
return (o(a[0], b[0]),o(a[1], b[1]),o(a[2], b[2]))
def tuple_to_color(tuple):
return (str(hex(tuple[0]))[2:] + str(hex(tuple[1]))[2:] +str(hex(tuple[2]))[2:]).upper()
from_c = color_to_tuple(s_c)
to_c = color_to_tuple(s_c2)
diff_c = merge_tuple(from_c, to_c, lambda a,b : (b-a) // s_w)
print(from_c)
colors = []
for i in range(s_w):
c = merge_tuple(from_c, diff_c, lambda a,b: a + (b * i))
print(c)
colors.append(tuple_to_color(c))
print(to_c)
print(from_c, to_c, diff_c, colors)
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.connect((IP_ADDRESS, PORT))
@ -44,6 +72,6 @@ while True:
for i in range(s_w):
j = i - s_w//2
s.send("PX {} {} {}\n".format(x+j,y+j, s_c).encode("utf-8"))
s.send("PX {} {} {}\n".format(x+j,y+j, colors[i]).encode("utf-8"))
c -= 1