• Remix
  • Share
  • New Entry

on 30 Nov 2023
  • 20
  • 27
  • 0
  • 0
  • 1268
drawframe(1);
Write your drawframe function below
function drawframe(f)
% draw logo
figure
L = 160*membrane(1,100);
fig = figure;
ax = axes;
s = surface(L);
s.EdgeColor = 'none';
view(3);
ax.XLim = [1 201];
ax.YLim = [1 201];
ax.ZLim = [-53.4 160];
ax.CameraPosition = [-145.5 -229.7 283.6];
ax.CameraTarget = [77.4 60.2 63.9];
ax.CameraUpVector = [0 0 1];
ax.CameraViewAngle = 36.7;
ax.Position = [0 0 1 1];
ax.DataAspectRatio = [1 1 .9];
l1 = light;
l1.Position = [160 400 80];
l1.Style = 'local';
l1.Color = [0 0.8 0.8];
l2 = light;
l2.Position = [.5 -1 .4];
l2.Color = [0.8 0.8 0];
s.FaceColor = [0.9 0.2 0.2];
s.FaceLighting = 'gouraud';
s.AmbientStrength = 0.3;
s.DiffuseStrength = 0.6;
s.BackFaceLighting = 'lit';
s.SpecularStrength = 1;
s.SpecularColorReflectance = 1;
s.SpecularExponent = 7;
axis off
fig.Color = [0 0.4470 0.7410]./1.2;
% convert to image array
F = getframe(gcf);
[X, map] = frame2im(F);
close;
% low-rank approximation
rank = round(exp(f/12));
[Ur,Sr,Vr,apxErrr] = svdsketch(double(X(:,:,1)),1e-6,'MaxSubspaceDimension',rank);
[Ug,Sg,Vg,apxErrg] = svdsketch(double(X(:,:,2)),1e-6,'MaxSubspaceDimension',rank);
[Ub,Sb,Vb,apxErrb] = svdsketch(double(X(:,:,3)),1e-6,'MaxSubspaceDimension',rank);
Xr = uint8(Ur*Sr*Vr');
Xg = uint8(Ug*Sg*Vg');
Xb = uint8(Ub*Sb*Vb');
X = cat(3,Xr,Xg,Xb);
label = sprintf('RANK %02d \nAPPROXIMATION',rank);
position = [10 10];
X = insertText(X,position,label,FontSize=14,...
BoxOpacity=0.,TextColor="white");
figure
imshow(X,"Border","tight");
end
Animation
Remix Tree