• Remix
  • Share
  • New Entry

on 6 Nov 2023
  • 7
  • 27
  • 0
  • 0
  • 509
drawframe(1);
a = 100
Write your drawframe function below
function drawframe(f)
img = zeros(1000,1000,3,'uint8');
f = f./10;
a = 100
fireflyX = 500 + round(a .* cos(f) ./ (1+sin(f).^2));
fireflyY = 500 + round(a.*sin(f).*cos(f) ./ (1+sin(f).^2));
img(fireflyX,fireflyY,1) = 255;
img(fireflyX,fireflyY,2) = 255;
img(fireflyX,fireflyY,3) = 0;
theta = 0;
for dist = 1:200
for theta = 0:0.001:(2.*pi)
xDist = round(dist.*cos(theta));
yDist = round(dist.*sin(theta));
updateX = fireflyX + xDist;
updateY = fireflyY + yDist;
img(updateX,updateY,1) = 255./(dist./20);
img(updateX,updateY,2) = 255./(dist./20);
end
end
imshow(img)
end
Animation
Remix Tree