- /
-
The Mathworks nebula in flux
on 24 Oct 2024
- 39
- 280
- 0
- 2
- 897
Cite your audio source here (if applicable): Danse Macabre by Saint Saens via Abydos music
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent R2 G2 B2
if f==1
a=508;
s=@rescale;
p=@repmat;
l=@imgaussfilt3;
h=@reshape;
X=linspace(-1,1,a);
g=[1 .9 .1 %yellow
.5 .1 .1 %red
.8 .4 .1 %orange
.4 .7 .7 %teal
0 0 0 ]; %black
for j=1:8
I=zeros(a,a,3);
g(1:4,4)=rand(4,1);
g(5,4)=1;
g=sortrows(g,4);
for k=1:5
f1=.5*(rand-.5);
f2=.5*(rand-.5);
[t,r]=cart2pol(X+f1,X'+f2);
if k<5
U=1.2;
else
U=.6;
end
T=rescale(abs(ifft2(r.^-1.65.*cos(7*rand(a)))),-0.6,U);
T(T<0)=0;
M=rescale(-r.^.7,0,1).*T;
M2=p(M,1,1,3).*p(h(g(k,1:3),1,1,3),a,a,1);
I=I+M2;
end
I1{j}=s(I,0,1.2);
R1(:,:,j)=I1{j}(:,:,1);
G1(:,:,j)=I1{j}(:,:,2);
B1(:,:,j)=I1{j}(:,:,3);
end
%96 frames containing 8 nebula
i=h(p(1:8,[12, 1]),[],1);
R1=R1(:,:,i);
G1=G1(:,:,i);
B1=B1(:,:,i);
R1=cat(3,R1(:,:,85:end),cat(3,R1,R1(:,:,1:12)));
G1=cat(3,G1(:,:,85:end),cat(3,G1,G1(:,:,1:12)));
B1=cat(3,B1(:,:,85:end),cat(3,B1,B1(:,:,1:12)));
%temporal blending
R2=l(R1(:,:,12:120), [.0001 .0001 8]);
G2=l(G1(:,:,12:120), [.0001 .0001 8]);
B2=l(B1(:,:,12:120), [.0001 .0001 8]);
end
Im(:,:,1)=R2(:,:,f);
Im(:,:,2)=G2(:,:,f);
Im(:,:,3)=B2(:,:,f);
image(Im)
camva(4.5) %creats a zoomed in effect so there is no border visible
end