• Remix
  • Share
  • New Entry

  • ME

  • /
  • Changing logo - with varying light

on 17 Nov 2023
  • 6
  • 3
  • 0
  • 0
  • 913
drawframe(1);
Write your drawframe function below
function drawframe(f)
% Get membrane data for MATLAB logo and create axes
Z = 160*membrane(1,100);
ax = axes;
% Create surf plot of MATLAB logo
s = surf(Z,'EdgeColor','none');
set(ax,'XLim',[-101 301],...
'YLim',[-101 301],...
'ZLim',[-153.4 260],...
'CameraPosition',[-145.5 -229.7 283.6],...
'CameraTarget',[77.4 60.2 63.9],...
'CameraUpVector',[0 0 1],...
'CameraViewAngle',36.7,...
'Position',[0 0 1 1],...
'DataAspectRatio',[1 1 .9]);
% Choose light properties
l1 = light;
set(l1,'Position',[160 400 80],...
'Style','local');
if f<=24
l1.Color = (f/24)*[0 0.8 0.8];
else
l1.Color = (1-((f-24)/24))*[0 0.8 0.8];
end
% Choose light properties
l2 = light;
set(l2,'Position',[.5 -1 .4]);
if f<=24
l2.Color = (f/24)*[0.8 0.8 0];
else
l2.Color = (1-((f-24)/24))*[0.8 0.8 0];
end
% Set properties of the surf plot
if f<=24
s.FaceColor = (f/24)*[0.9 0.2 0.2];
else
s.FaceColor = (1-((f-24)/24))*[0.9 0.2 0.2];
end
set(s,'FaceLighting','gouraud',...
'AmbientStrength',0.3,...
'DiffuseStrength',0.6,...
'BackFaceLighting','lit',...
'SpecularStrength',1,...
'SpecularColorReflectance',1,...
'SpecularExponent',7);
% Change axis properties
set(gca,'XTick',[],'YTick',[],'ZTick',[],'Color','k');
end
Animation
Remix Tree