• Remix
  • Share
  • New Entry

on 29 Nov 2023
  • 7
  • 13
  • 0
  • 0
  • 702
drawframe(1);
Write your drawframe function below
function drawframe(f)
%% Function gradually increases max number of iterations for divergence
%% Heavily inspired by https://blbadger.github.io/julia-sets.html
res = 800; %resolution
res_down = 400;
maxIter = (linspace(sqrt(10),sqrt(1420),48)).^2;
a=-0.29609091+0.62491i;
img = julia_set(res, maxIter(f), a);
cmap = parula;
indexed_img = ind2rgb(img, cmap);
resultImage = imresize(indexed_img, [res_down, res_down], 'method', 'bilinear');
imshow(resultImage);
function numIter = julia_set(res, maxIter, a)
%%
% A function to determine the values of the Julia set.
%%
xlim = [-1.4 1.4];
ylim = [-1.4 1.4];
% complex grid
y = linspace(xlim(1),xlim(2), res);
x = linspace(ylim(1),ylim(2), res);
[X, Y] = meshgrid(x, y);
Z = complex(X,Y);
% number of iterations for divergence
numIter = zeros(res);
% "still iterating" logical array
notDiverged = true(res);
for i = 1:maxIter
divergingNow = false(res);
Z(notDiverged) = Z(notDiverged).^2 + a;
divergingNow(notDiverged) = abs(Z(notDiverged)) > 4;
numIter(divergingNow) = i;
notDiverged = ~divergingNow & notDiverged;
end
end
end
Animation
Remix Tree