Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. from PIL import Image,ImageColor
  2. import math, cmath
  3.  
  4. def compact(x,y):
  5.     return int(50-50*math.exp(-4*(math.pow(x,2)+math.pow(y,2))))
  6.  
  7. def deg(x):
  8.     return int(math.degrees(x)+180)
  9.  
  10. def Color(x,y):
  11.     return ImageColor.getrgb("hsl("+str(deg(math.atan2(y,x)))+",100%,"+str(compact(x,y))+"%)")
  12.  
  13. def Transform(x,y):
  14.     Z=cmath.sin(z)
  15.     return Color(Z.real,Z.imag)
  16.  
  17. A=500
  18. B=500
  19. I_min=-2*math.pi
  20. I_max=2*math.pi
  21. R_min=-2*math.pi
  22. R_max=2*math.pi
  23.  
  24. def main():
  25.  
  26.     size = width, hieght = A,B;
  27.  
  28.     im=Image.new("RGB",size)
  29.  
  30.     for x in range(A):
  31.         for y in range(B):
  32.             im.putpixel((x,y),Transform(complex((x-A/2)/(A/2)*(R_max-R_min)/2,(y-B/2)/(B/2)*(I_max-I_min)/2)))
  33.  
  34.     im.show()  
  35.     im.save("test.png")
  36.     del im
  37.  
  38.  
  39.  
  40. if __name__ == '__main__':
  41.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement