pro colorfrac,x,y,a,b,intensity ; ; The actual root-finding computation ; n = 0 ;; ;; If we don't get outside the |Z|=2 circle after 100 iterations, ;; then we "converge." (|Z| > 2 is the "escape criterion") ;; while (n lt 100) and ((x^2 + y^2) lt 4) do begin ;; ;; X is real part, Y is imaginary part. ;; A is real part of C, B is imaginary part. ;; xx = x^2 - y^2 + a y = 2*x*y + b x = xx n = n + 1 endwhile ; ; Reverse so image is "amount of divergence". ; intensity=100.-n return end pro mandelbrot,idim,acorner,bcorner,side,set1 ; ; Compute the Mandelbrot set, a map on the complex C plane of the ; convergence under iteration of the expresion z^2 + c, Z is initialized ; to zero. ; ; Z = X + iY ; Z^2 = X^2 - Y^2 + 2iXY ; ; Inputs: ; ; IDIM Number of pixels on a side for the image ; ACORNER Bottom left corner X value ; BCORNER Bottom left corner Y value ; SIDE Length of a side ; ; Outputs: ; SET1 Resultant image ; ; Example: ; IDL> mandelbrot,128,-2,-1.5,3,set1 ; IDL> loadct,22 ; COMMON COLORS, R_orig, G_orig, B_orig, R_curr, G_curr, B_curr loadct,4 gamma_ct,8 set1 = fltarr(idim,idim) gap = float(side)/idim a = acorner for j = 0,idim-1 do begin a = a + gap b = bcorner for k = 0,idim-1 do begin x = 0.0 y = 0.0 b = b + gap colorfrac,x,y,a,b,intensity set1(j,k) = intensity ;print,'set1(j,k) = ',set1(j,k) ; tvscl,set1 endfor endfor ;tvscl,rebin(set1,irebin,irebin) tvscl,set1 fout = 'mandelbrot_'+strtrim(string(round(systime(/julian,/utc)),FORMAT='(i10)'),2)+'.png' print,'Writing image to file '+fout write_png,fout,bytscl(set1),R_orig,G_orig,B_orig return end