Skip to content

Instantly share code, notes, and snippets.

@pollend
Last active September 21, 2017 01:02
Show Gist options
  • Save pollend/e457dfbe3fdd2fbc4cf4dc1339bbd957 to your computer and use it in GitHub Desktop.
Save pollend/e457dfbe3fdd2fbc4cf4dc1339bbd957 to your computer and use it in GitHub Desktop.
h = figure;
set(h, 'Position', [0 0 (1280+100) (720 + 100)])
WIDTH = 1280;
HEIGHT = 720;
center = [-.73659007459575,-.69270903692418];
[XX,YY] = meshgrid(linspace(0,1,720),linspace(0,1,1280));
Z = ones(size(XX));
%frame = 1;
for frame = 1:.05:43
scale = (1/2^frame);
%[X,Y] = meshgrid(linspace(center(1) - scale,center(1) + scale,1280),linspace(center(2) - scale,center(2) + scale,720));
X = linspace(center(1) - scale,center(1) + scale,1280);
Y = linspace(center(2) - scale,center(2) + scale,720);
for x_ = 1: 1280
for y_ = 1: 720
u = [X(x_),Y(y_)];
for i = 1:2000
% julian set
% v = [u(1) * u(1) - u(2) * u(2) + frame, u(2) * u(1) + u(2) * u(1)+ frame];
% mandelbrot set
% v = [(u(1) * u(1) - u(2) * u(2)) + X(x_,y_) , (u(2) * u(1) + u(2) * u(1)) + Y(x_,y_)];
v = [(u(1) * u(1) - u(2) * u(2)) + .3, (u(2) * u(1) + u(2) * u(1)) ];
if((v(1) * v(1) + v(2) * v(2)) > 4)
break
end
u = v;
Z(x_,y_) = i;
end
end
end
imagesc(Z)
ax = gca
set(ax,'xtick',[])
set(ax,'ytick',[])
%set(ax,'Position',[ax.OuterPosition(1),ax.OuterPosition(2),ax.OuterPosition(3),ax.OuterPosition(4)])
drawnow
result = getframe(h);
im = frame2im(result);
[imind,cm] = rgb2ind(im,256);
if frame == 1
imwrite(imind,cm,'final.gif','gif', 'Loopcount',inf);
else
imwrite(imind,cm,'final.gif','gif','DelayTime',0.1,'WriteMode','append');
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment