Python 3 code ############################################################## # Sequential ordered steps of 2D Mandelbrot set 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 Radius = 10 # set escape rate threshold x0 = .5 # set initial x co-ordinate shift y0 = 0.0 # set initial y co-ordinate shift Side = 1.2 # 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 win = GraphWin("Mandelbrot set", int(5*M/3),int(5*M/3)) # set window title win.setBackground("white") # set background color 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).setFill(color_rgb(int(w),int(128-w/2), int(128+w/2))) for p in range(1,M,sT): # column scanning cycle Incy = y0 - Side + 2*Side/M*p # define column scanning function for q in range(1,M,sT): # raw scanning cycle Incx = x0 - Side + 2*Side/M*q # define raw scanning function x = 0.0 # set starting x co-ordinate y = 0.0 # set starting y co-ordinate w = 0 # set starting escape modulus value for n in range(1,Num): # recursion cycle xx = x*x - y*y - Incx yy = 2*x*y - Incy 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 win.getMouse() # wait for mouse click win.close() # close window