Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. from PIL import Image,ImageColor
  2. import math, cmath
  3.  
  4. def compact(z):
  5.     return str(round(50-50*math.exp(-4*(math.pow(abs(z),2)))))
  6.  
  7. def deg(x):
  8.     return int(math.degrees(x)+180)
  9.  
  10. def Transform(z):
  11.     try:
  12.         W=cmath.log(z)
  13.         return ImageColor.getrgb("hsl("+str(deg(cmath.phase(W)))+",100%,"+compact(W)+"%)")
  14.     except ValueError:
  15.         return ImageColor.getrgb("hsl(0,100%,100%)")
  16.  
  17. A=1000
  18. B=1000
  19. I_min=-10
  20. I_max=10
  21. R_min=-10
  22. R_max=10
  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("ln(z).png")
  36.     del im
  37.  
  38. if __name__ == '__main__':
  39.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement