forked from mathworks/awesome-matlab-students
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Midnight_Marathon__Apartment_Edition.m
51 lines (43 loc) · 1.16 KB
/
Midnight_Marathon__Apartment_Edition.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
animateFrames();
function animateFrames()
animFilename = 'Midnight_Marathon__Apartment_Edition.gif'; % Output file name
firstFrame = true;
framesPerSecond = 24;
delayTime = 1/framesPerSecond;
% Create the gif
for frame = 1:48
drawframe(frame);
fig = gcf();
fig.Units = 'pixels';
fig.Position(3:4) = [300,300];
im = getframe(fig);
[A,map] = rgb2ind(im.cdata,256);
if firstFrame
firstFrame = false;
imwrite(A,map,animFilename, 'LoopCount', Inf, 'DelayTime', delayTime);
else
imwrite(A,map,animFilename, 'WriteMode', 'append', 'DelayTime', delayTime);
end
end
end
function drawframe(f)
axes(Color='k',Pr='p')
hold
h=ones(9,2)*2+.4; % building heights
b=bar3(h,.5);
set(b,FaceC=[.3,.3,.3]);
axis equal
camva(30)
campos([1.5 10 .2])
for i=1:9 %rows of buildings 1:size(h,1)
for j=1:2 %L/R buildings
c=.1:.2:h(i,j)-.2;
d=[c;c];
z=d(:)'+[0;0;.1;.1];
y=i-[15;5;5;15]*.01+[0,.2];
y=repmat(y,1,numel(c));
patch((.75+j/2*(z*0+1)),y+0.1*f,z,[.8,.8,.8])
end
end
camlight
end