from kandinsky import set_pixel from math import * from random import random for n in range(223): for m in range(320): x,y,z,u,v = 0,0,-.8,(m-159.9)/160,(.8*n-85.9)/111 w = 1/sqrt(u*u+v*v+1) u *= w v *= w i = copysign(1, u) k = 1 while k !=0: k,e,f = 0, x-i,y-i p = u*e+v*f+w*z d = p*p-e*e-f*f-z*z+1 if d > 0: t = -p-sqrt(d) if t > 0: k = 1 x += t*u y += t*v z += t*w e,f,p = x-i,y-i,1.3*(u*e+v*f+w*z) u -= p*e v -= p*f w -= p*z i = -i cc = max(0,min(255,20*int(12*w-7*v-5*u+random()))) set_pixel(m, 222-n, (cc,)*3)