Python 3 code ################################################################## # 2D Julia set generation by a cellular automaton (c = 0.7454294) # (graphics module) ################################################################## # mod graphics in /Users/strumia/Library/Python/3.6/site-packages/graphics/ import sys sys.path.append("/Users/strumia/Library/Python/3.6/site-packages/graphics/") from graphics import * # import graphics module Radius = 30 # set escape rate threshold Cx = 0.7454294 # set c parameter real part value Cy = 0.0 # set c parameter real 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=5 # set step jump w = 0 # set starting escape modulus value x = 0.0 #set x co-ordinate initial value y = 0.0 #set y co-ordinate initial value import random # import random module p = M/2+random.randrange(-M/2,M/2) q = M/2+random.randrange(-M/2,M/2) win = GraphWin("Julia set", int(5*M/3),int(5*M/3)) def rectCol(p,q,w): Rect = Rectangle(Point(int(p-sT/2),int(q-sT/2)), Point(int(p+sT/2),int(q+sT/2))) Rect.draw(win).setFill(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 = p+random.randrange(-1,2)*sT q = q+random.randrange(-1,2)*sT if p < 0: p = p+2 elif p > M: p = p-2 if q < 0: q = q+2 elif q > M: q = q-2 Incx = - Side + 2*Side/M*q Incy = - Side + 2*Side/M*p x = Incx y = Incy w = 0 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 rectCol(int(M/3+q),int(M/3+p),int(w)) break win.getMouse() win.close()