Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image,ImageColor
- import math, cmath
- def compact(z):
- return str(round(50-50*math.exp(-4*(math.pow(abs(z),2)))))
- def deg(x):
- return int(math.degrees(x)+180)
- def Transform(z):
- try:
- W=cmath.log(z)
- return ImageColor.getrgb("hsl("+str(deg(cmath.phase(W)))+",100%,"+compact(W)+"%)")
- except ValueError:
- return ImageColor.getrgb("hsl(0,100%,100%)")
- A=1000
- B=1000
- I_min=-10
- I_max=10
- R_min=-10
- R_max=10
- def main():
- size = width, hieght = A,B;
- im=Image.new("RGB",size)
- for x in range(A):
- for y in range(B):
- 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)))
- im.show()
- im.save("ln(z).png")
- del im
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement