https://humanshader.com/ shaderin koodi
- 📅 2023-07-20T19:46:23.887Z
- 👁️ 148 katselukertaa
- 🔓 Julkinen
import os, sys
from PIL import Image
def round_to(a, b):
return round(a/(10**b))
def shader(x, y):
u = x - 36
v = 18 - y
h = u**2 + v**2
if h < 200: # B
R = 420
B = 520
t = 5000 + 8*h
p = round_to(t*u,2)
q = round_to(t*v,2)
s = 2*q
w = round_to(1000+p-s, 2)+8
if w > 0:
R = R+w**2
o = s + 2200
R = round_to(R*o, 4)
B = round_to(B*o, 4)
if p > -q:
w = round_to(p+q, 1)
R = R+w
B = B+w
elif v < 0: # C
R = 150+2*v
B = 50
p = h + 8*v**2
c = 240*(-v)-p
if c > 1200:
o = round_to(6*c, 1)
o = c*(1500-o)
o = round_to(o, 2)-8360
R = round_to(R*o, 3)
B = round_to(B*o, 3)
r = c+u*v
d = 3200-h-2*r
if d > 0:
R = R+d
else: # D
c = x+4*y
R = 132+c
B = 192+c
if R > 255:
R = 255
if B > 255:
B = 255
G = round_to(7*R+3*B, 1)
return (R, G, B)
img = Image.new(mode="RGB", size=(71, 40))
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
print(i, j, "=", shader(i, j))
pixels[i, j] = shader(i, j)
img.save("test.png")