• Remix
  • Share
  • New Entry

on 15 Oct 2024
  • 19
  • 415
  • 0
  • 5
  • 1872
Cite your audio source here (if applicable):
Cool, Cool Mountain Remake by Joshua Milo
Licenced under: https://creativecommons.org/licenses/by-nc/3.0/ - No changes made
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent x y o ax ax2
n=200;
if f==1
rng(7)
x=rand(1,n)*5;
y=rand(1,n)*7;
o=rand(1,n)*.04+.06;
ax=axes(Pos=[0 0 1 1],Vis=0,NextP='add');
end
m=96;
x1=linspace(0,3.07,m);
x2=linspace(5,3.13,m);
y1=linspace(-2,-.24,m);
y2=linspace(6,-.18,m);
sx=[-.075 .075 0 -.053 .053 0 0 0 0 -.053 .053];
sy=[0 0 0 -.053 .053 0 -.075 .075 0 .053 -.053];
H=sin(2*pi*(1:m)/m)*.6;
% Photo frame coordinates
xf=[3.07 3.13];
yf=[-.24 -.18];
axes(ax) % Returns the focus to the main axes
cla
% Draw the background
rectangle(Pos=[-1,-3,7,10],FaceC='b');
% Draw the snow hill
rectangle(Pos=[-1,-5,8,5],Curv=[1,1],FaceC=[1,1,1]*.94);
% Draw the chimney smoke
t=linspace(0,2*pi,100);
for l=0:25
r=-.01+l*.01+.06*f/m;xc=r*cos(t)+2.98+l*.02+.13*f/m;yc=r*sin(t)-1.25+l*.3+2*f/m;
fill(xc,yc,[.8,.8,.8],LineW=.001,EdgeC=[0.8,0.8,0.8]);
end
% Draw the house
fill([2.2 2.9 3.6],[.2 .6 .2],[1 1 1]*.95); % Roof
fill([3.04 3.16 3.16 3.04],[.28 .28 .6 .6],'k'); % Upper chimney part
fill([2.4 3.4 3.4 2.4],[-.6 -.6 .2 .2],[.6 .3 0]); % Walls
fill([2.96 3.24 3.24 2.96],[-.4 -.4 -.12 -.12],[1 1 0]); % Window
fill([2.52 2.8 2.8 2.52],[-.6 -.6 -.2 -.2],[.4 .2 0]); % Door
% Draw the chimney & fireplace
s=.2;
r=s/2.5;
fill([-.6 .6 .6 -.6]*(s/2)+3.1,[s/1.25 s/1.25 .28 .28]-.4,[.8 .62 .25]); % Middle chimney part
fill([-1 1 1 -1]*(s/2)+3.1,[0 0 s/1.25 s/1.25]-.4,[.8 .52 .25]); % Lower chimney part
t=linspace(0,pi,100);fill(r*cos(t)+3.1,r*sin(t)-s-.2,[.1 .1 .1]); % Fireplace
% Draw the fire
p=H(f)*.019;
t=linspace(0,2*pi,100);
a=1;b=2;fill(a*(1-sin(t)).*cos(t+H(f)+.3)*.02+3.1-p,(b*(sin(t)-1))*.02-.32,[1 0 0]); % Outer layer
a=.7;b=1.4;fill(a*(1-sin(t)).*cos(t+H(f))*.02+3.1-p,(b*(sin(t)-.4)-2)*.02-.32,[1 .4 0]); % Middle layer
a=.5;b=1;fill(a*(1-sin(t)).*cos(t+H(f)-.3)*.02+3.1-p,(b*(sin(t)-.9)-2)*.02-.32,[1 1 0]); % Inner layer
% Draw the photo frame
fill([3.066 3.134 3.134 3.066],[-.24 -.24 -.175 -.175],[.8 .52 .25]); % Outer frame
fill([xf,flip(xf)],yf([1,1,end,end]),'k'); % Inner frame
% Draw the falling snow
for i=1:n
% Delay start
y(i)=y(i)-2*o(i);
if y(i)<-7.2
y(i)=-.2;
end
plot(x(i)+sx,y(i)+sy+6.2,'w',LineW=1.5);
end
% Zoom in and update axes
axis([x1(f) x2(f) y1(f) y2(f)]);
lims=axis;
pos=ax.Position;
% This keeps the relative position of the 2 axes constant
pos=[pos(1)+diff([lims(1),xf(1)])/diff(lims(1:2))*pos(3) pos(2)+diff([lims(3),yf(1)])/diff(lims(3:4))*pos(4) diff(xf(1:2))/diff(lims(1:2))*pos(3) diff(yf(1:2))/diff(lims(3:4))*pos(4)];
if f==1
% Create axes for the photo frame containing the first frame graphic objects
ax2=copyobj(ax,gcf);
else
% Adjust the relative position
ax2.Position=pos;
end
axes(ax2) % Shifts the focus to the frame axes
end
Movie
Audio
Remix Tree