function make_mandelbrot_menu % make_mandelbrot_menu menu = { ... % name center width grid depth cmap 'full' -0.5+0i 3 512 256 'fringe' 'mini mandelbrot' -0.1280-0.9875i 0.010 1024 512 'sepia' 'plaza' -1.768397725+0.005538593i 2.8e-7 1024 768 'flags' 'seahorses' -0.7700-0.1300i 0.10 512 512 'jets' 'west wing' -1.6735-0.0003318i 1.5e-4 1024 160 'jets' 'dueling dragons' -1.673551933646202-0.000323631851006i 1.83e-8 1024 160 'jets' 'buzzsaw' 0.001643721971153+0.822467633298876i 4.0e-11 1024 2048 'hots' 'nebula' -0.737527770996094-0.128495483398438i 4.883e-5 1024 2048 'cmyk' 'vortex1' -1.74975914513036646-0.00000000368513796i 6.0e-12 1024 2048 'hots' 'vortex2' -1.74975914513271613-0.00000000368338015i 3.75e-13 1024 2048 'hots' 'vortex3' -1.74975914513272790-0.00000000368338638i 9.375e-14 1024 2048 'hots' 'deep detail' 0.28692299709-0.01218247138i 6.0e-10 1024 8192 'jets'}; clf shg [m,n] = size(menu); mcounts = zeros(160,160,m,'uint16'); for r = 1:m mcounts(:,:,r) = mandelbrotx(r); end save mandelbrot_menu menu mcounts clf text(.45,.5,'Done') axis off % ------------------------------------ function kz = mandelbrotx(r) center = menu{r,2}; width = menu{r,3}; grid = menu{r,4}; depth = menu{r,5}; cmapname = menu{r,6}; cmaps = {@jets, @hots, @sepia, @cmyk, @flags, @fringe}; for k = 1:length(cmaps) cf = char(cmaps{k}); cf = cf(max(strfind(cf,'/'))+1:end); if isequal(cmapname,cf) colormap(cmaps{k}(depth)); end end grid = 160-1; kz = zeros(grid+1,grid+1,'uint16'); z = complex(zeros(grid+1,grid+1)); iterate(0,depth); % ------------------------ function iterate(startdepth,finaldepth) s = width*(-1/2:1/grid:1/2); [u,v] = meshgrid(s+real(center),s+imag(center)); z0 = u + i*v; for d = startdepth:finaldepth if mod(d,32) == 0 plotit; end [z,kz] = mandelbrot_step(z,kz,z0,d); % mandelbrot_step is a c-mex file that does one step of: % z = z.^2 + z0; % kz(abs(z) < 2) = d; end depth = finaldepth; drawnow end % ------------------------ function cmap = jets(m) c = jet(16); e = ones(m/16,1); cmap = kron(e,c); end % ------------------------ function cmap = hots(m) c = flipud(hot(16)); e = ones(m/16,1); cmap = kron(e,c); end % ------------------------ function cmap = sepia(m) c = rot90(bone(16),2); e = ones(m/16,1); cmap = kron(e,c); end % ------------------------ function cmap = cmyk(m) % c = blue, green, red, cyan, magenta, yellow, gray, black. c = [0 0 3; 0 2 0; 3 0 0; 0 3 3; ... 3 0 3; 3 3 0; 1 1 1; 0 0 0]/4; e = ones(m/8,1); cmap = kron(e,c); end % ------------------------ function cmap = flags(m) c = flag(4); e = ones(m/4,1); cmap = kron(e,c); end % ------------------------ function cmap = fringe(m) cmap = zeros(min(m,256),3); cmap(end,1) = .5; cmap(1:12,:) = 1; end % ------------------------ function plotit pix = image(kz); truesize axis square axis off set(gca,'ydir','normal') drawnow end end % mandelbrotx end % make_mandelbrotpix