from kandinsky import set_pixel, fill_rect from math import * from random import random for n in range(223): for m in range(320): x,y,z,u,v = 0,-.1,-3,(m-159.9)/160,(.8*n-92.9)/111 w = 1/sqrt(u*u+v*v+1) u *= w v *= w i = 0 if u == 0 else copysign(1, u) b, k = 0, 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, b = 1, 1 x += t*u y += t*v z += t*w e,f,p = x-i,y-i,2*(u*e+v*f+w*z) u -= p*e v -= p*f w -= p*z i = -i if v < 0: p = (y+2)/v b = (int(x-u*p)+int(z-w*p)) % 2 set_pixel(m, 222-n, (255*b,)*3)