Python 3 code ################################## # 2D Julia set random generation # (graphics module) ################################## # specify the absolute path of mod graphics folder (depends on user's choice) import sys sys.path.append("/Users/strumia/Library/Python/3.6/site-packages/graphics/") from graphics import* # import graphics module import random # import random module Radius = 10 # set escape rate threshold Cx = 0.7454294 # set c parameter real part value Cy = 0.0 # set c parameter imaginary part value Side = 1.7 # set square area side M = 300 # set side number of elementary squares N = 1 # set color map scale factor Num = 256*N # set number of cycles sT=2 # set step jump win = GraphWin("Julia set", 5*M/3,5*M/3) # set window title def rectCol(p,q,w): # define elementary cell Rect = Rectangle(Point(int(p-sT/2),int(q-sT/2)), Point(int(p+sT/2),int(q+sT/2))) Rect.draw(win).setOutline(color_rgb(int(10*w%255), int((128-10*w)%255),int((128+10*w)%255))) # Alternative values Cx 0.1747, 0.1747 Cy -.072,-1.072 # Side 0.0015, 0.00015 Num 1024 i = 1 # set non-zero index value while i > 0: # set random co-ordinates choice cycles p = random.randrange(1,M) q = random.randrange(1,M) Incx = - Side + 2*Side/M*q # set x increment Incy = - Side + 2*Side/M*p # set y increment x = Incx y = Incy w = 0 # set starting escape modulus value for n in range(1,Num): xx = x*x - y*y - Cx yy = 2*x*y - Cy x = xx y = yy if x*x + y*y > Radius: # escape rate condition w = n/N # escape modulus normalization rectCol(int(M/3+q),int(M/3+p),int(w)) # plot elementary cell break # interrupt cycle