[ create a new paste ] login | about

Link: http://codepad.org/3vnZaUv5    [ raw code | fork ]

Python, pasted on Jul 9:
import os
import Image, ImageDraw

WIDTH, HEIGHT = 1000, 1000

cSize = .23                             #Size of region in complex plane - default 4
cShiftReal, cShiftImag = -1.01, -.09    #Shifts the region in the complex plane -1.1, -.03
center = .3                             #Offset to center fractal on screen
ratio = cSize / WIDTH                   #Ratio to determine spacing when converting to screen size

img = Image.new( 'RGB', ( WIDTH, HEIGHT ), ( 0, 0, 0 ) )
idraw = ImageDraw.Draw( img )

for x in xrange( -WIDTH / 2, WIDTH / 2 ):
    for y in xrange( -HEIGHT / 2, HEIGHT / 2 ):
        z = 0
        diverged = 0
        C = complex( ( ratio * x ) + cShiftReal - center, ( ratio * y ) + cShiftImag )
        for k in xrange( 90 ):
            z = z * z + C
            if( abs( z ) > 2 ):
                idraw.point( ( x + WIDTH / 2, y + HEIGHT / 2 ), ( k * 6, k * 7, k * 3 ) )
                diverged = 1
                break
        if( diverged != 1 ):
            idraw.point( ( x + WIDTH / 2, y + HEIGHT / 2 ), ( int( abs(z) * 40 ) + 6, int( abs(z) * 40 ) + 12, int( abs(z) * 40 ) + 18 ) )
            
img.save( "C:/PythonWorkspace/Images/mandelbrot.png" )            
os.startfile( "C:/PythonWorkspace/Images/mandelbrot.png" )


Create a new paste based on this one


Comments: