For your enjoyment :)

Run after running the noise.py from lecture…

Simple samples:

def circ(x,y): factor = 8 return factor*(round((math.sqrt((x-256)**2+(y-256)**2)))) % 256 C = synthetic(512,512,circ) C.display()

def sun(x,y): return (round(255*(4*cmath.phase ( complex (x -256 , y -256)))%256)) S = synthetic(512,512,sun) S.display()

And the crème de la crème, fun, and not so simple, but more famous sample :)

def mandelbrot_set(y0, x0, res_x = 512, res_y = 512): # ^ ^ # | | # we need These in that order #Credit - Wikipedia. Adaptation to python - me :) #"Basically" - We are testing if a given pixel is part of The Mandelbrot-Set. #From Wikipedia: #Mandelbrot set is the set of values of c in the complex plane for which #the orbit of 0 under iteration of the complex quadratic #polynomial z_n+1 = z_n ** 2 + c remains bounded. #That is, a complex number c is part of the Mandelbrot set if, #when starting with z_0 = 0 and applying the iteration repeatedly, #the absolute value of z_n remains bounded however large n gets. #We will use the bound of 4. bound = 4 #this is the set size x_min = -2.5 x_max = 1 y_min = -1 y_max = 1 #scale the pixel to the size of the set x0 = x_min + (x0 / (res_x/(x_max-x_min))) y0 = y_min + (y0 / (res_y/(y_max-y_min))) #Init X,Y and counters x=0 y=0 iteration = 0 #More iteration = better picture = slower computation max_iteration = 256 #should be divisible by 256 while x*x+y*y<bound and iteration < max_iteration: xtemp = x*x - y*y + x0 y = 2*x*y + y0 x = xtemp iteration = iteration + 1 return iteration % 256 #this will be the color of the pixel M = synthetic(512,512, mandelbrot_set) M.display()