Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import time
- from tkinter import Tk, Label, PhotoImage
- from math import log
- w = 1000; h = 800
- t1 = time()
- root = Tk()
- label = Label(root)
- label.pack()
- img = PhotoImage(width=w,height=h)
- label.config(image=img)
- root.wait_visibility()
- xc = -0.6; yc = 0.005; m = 0.65
- imax = 100; zmax = 50
- for y in range(h):
- hexdata = ""
- for x in range(w):
- c = complex(xc + (2 * x - w) / (w * m), -yc - (2 * y - h) / (w * m))
- z = complex(0.0, 0.0)
- for i in range(imax):
- z = z * z + c
- if abs(z) >= zmax: break
- if i >= imax - 1:
- hexdata += "#000000 "
- else:
- zlog = (i - log(log(abs(z)),2)) * 0.7;
- v = log(max(1.0, zlog * 1.5 + 1.0)) * 0.3;
- if v <= 1.0:
- rgb = (v ** 4, v ** 2.5, v)
- else:
- v = max(0.0, 2.0 - v)
- rgb = (v, v ** 1.5, v ** 3)
- hexdata += '#' + ''.join(['%02x' % int(n * 255) for n in rgb]) + ' '
- data = '{ ' + hexdata + ' }'
- img.put(data, to=(0,y))
- root.update()
- print( "Elapsed time:", '%7.2f' % (time() - t1), "s" )
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement