• Remix
  • Share
  • New Entry

  • VMM

  • /
  • wrinkles

on 2 Dec 2023
  • 8
  • 34
  • 0
  • 1
  • 1536
drawframe(1);
Write your drawframe function below
function drawframe(nn)
function lap = lapl(x,dist)
lap = (circshift(x,1,1)+circshift(x,-1,1)+circshift(x,1,2)+circshift(x,-1,2)-4*x)/dist^2;
end
range = 1/2+sin(linspace(pi/2,5*pi/2,48))/2;
persistent caps;
if(isempty(caps))
caps = [];
imgsz=128;
textImage = zeros(imgsz);
textImage = insertText(textImage, [20 20], ['MATLAB' newline 'MATLAB'], ...
'FontSize', 40, 'BoxOpacity',0, 'FontColor','white');
textImage=rgb2gray(textImage);
se = strel('disk', 1);
textImage = imdilate(textImage, se);
u = 1-textImage;
v = textImage;
ru = 0.25;
rv = 0.1;
f = 0.0980;
k = 0.0574;
Ts = 0.8684210526;
steps = 4000;
capsstep = floor(steps/24);
for i=1:steps
nu = ru*lapl(u,1)-u.*(v.^2)+f*(1-u);
nv = rv*lapl(v,1)+u.*(v.^2)-v*(f+k);
u = u+Ts*nu;
v = v+Ts*nv;
end
steps = 10000;
capsstep = floor(steps/3);
for i=1:steps
if(mod(i-1,capsstep) == 0)
caps{end+1} = u;
end
nu = ru*lapl(u,1)-u.*(v.^2)+f*(1-u);
nv = rv*lapl(v,1)+u.*(v.^2)-v*(f+k);
u = u+Ts*nu;
v = v+Ts*nv;
end
end
mu = sqrt([10, 5, 1]);
t = (range(nn));
Z = cos(mu(1)*t)*caps{1} + sin(mu(2)*t)*caps{2} + sin(mu(3)*t)*caps{3};
axes('CameraPosition', [-300 -300 420],...
'CameraTarget',[60 60 10], ...
'CameraUpVector',[0 0 1], ...
'CameraViewAngle',10, ...
'DataAspectRatio', [1 1 0.9],...
'Visible','off', ...
'XLim',[1 128], ...
'YLim',[1 128], ...
'ZLim',[0 1]);
surface(2*Z, ...
'EdgeColor','none', ...
'FaceColor',[0.9 0.75 0.7], ...
'FaceLighting','phong', ...
'AmbientStrength',0.2, ...
'DiffuseStrength',0.5, ...
'Clipping','off',...
'BackFaceLighting','lit', ...
'SpecularStrength',1, ...
'SpecularColorReflectance',1, ...
'SpecularExponent',5);
light('Position',[100 100 1], ...
'Color',[0.7 0.5 0.6]);
end
Animation
Remix Tree