ai v pizdu
This commit is contained in:
parent
236be7bb2a
commit
29f3563e49
BIN
__pycache__/algrebra.cpython-310.pyc
Normal file
BIN
__pycache__/algrebra.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/grad.cpython-310.pyc
Normal file
BIN
__pycache__/grad.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/test.cpython-310.pyc
Normal file
BIN
__pycache__/test.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/window.cpython-310.pyc
Normal file
BIN
__pycache__/window.cpython-310.pyc
Normal file
Binary file not shown.
23
grad.py
23
grad.py
|
|
@ -22,11 +22,16 @@ def rgb_to_hex(color):
|
|||
|
||||
|
||||
def main(wind):
|
||||
wind.points = [(0, 0)] + wind.points + [(wind.width, wind.height)]
|
||||
|
||||
[print(wind.points)]
|
||||
|
||||
L = interpol(wind.points)
|
||||
dL = L.diff()
|
||||
N = len(wind.points)
|
||||
perp = []
|
||||
|
||||
|
||||
for p in wind.points:
|
||||
k = dL.value(p[0])
|
||||
if k==0:
|
||||
|
|
@ -36,18 +41,21 @@ def main(wind):
|
|||
b = p[1] - k*p[0]
|
||||
perp.append(Poly([b, k]))
|
||||
|
||||
colors = [(0, Vector(0, 0, 0))]
|
||||
colors = []
|
||||
for i in range(N):
|
||||
colors.append((wind.points[i][0], Vector(randint(0, 255), randint(0, 255), randint(0, 255))))
|
||||
colors.append((width, Vector(255, 255, 255)))
|
||||
#colors.append((width, Vector(255, 255, 255)))
|
||||
|
||||
print(colors)
|
||||
|
||||
#colors = [(0, Vector(0, 0, 0))] + colors + []
|
||||
|
||||
color_func = interpol(colors).tuple()
|
||||
|
||||
step = 0.5
|
||||
step = 0.1
|
||||
for dx in range(round(width/step)):
|
||||
x=dx*step
|
||||
color = color_filter(comp.value(x) for comp in color_func)
|
||||
print(x, color)
|
||||
"""
|
||||
k = dL.value(x)
|
||||
if k == 0:
|
||||
|
|
@ -58,8 +66,9 @@ def main(wind):
|
|||
for y in range(width*2):
|
||||
wind.canvas.create_line(y/2, k*y/2+b, y/2+1, k*(y/2+1)+b, fill=rgb_to_hex(color))
|
||||
"""
|
||||
wind.canvas.create_line(x, L.value(x), x+step, L.value(x+step), fill=rgb_to_hex((color)), width=5)
|
||||
wind.canvas.create_line(x, L.value(x), x+step, L.value(x+step), fill=rgb_to_hex((color)), width=10)
|
||||
|
||||
wind.points = wind.points[1:-2]
|
||||
|
||||
for i in range(N):
|
||||
wind.canvas.create_oval(colors[i][0] - 3, L.value(colors[i][0]) - 3, colors[i][0] + 3, L.value(colors[i][0]) + 3, fill=rgb_to_hex(colors[i][1].tuple()))
|
||||
|
|
@ -69,8 +78,8 @@ def main(wind):
|
|||
|
||||
if __name__ == "__main__":
|
||||
title = 'Huy'
|
||||
width = 1000
|
||||
height = 500
|
||||
width = 1200
|
||||
height = round(width*1080/1920)
|
||||
wind = window(title, width, height)
|
||||
|
||||
def on_enter_pressed(event):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user