-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathRiver.m
44 lines (33 loc) · 870 Bytes
/
River.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
animateFrames();
function animateFrames()
animFilename = 'River.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)
persistent C h i n
if f == 1
n = 48;
C = rand(n);
h = pcolor(C);
i = 1:n^2;
end
h.CData(mod(i+1,n^2)+1) = h.CData(mod(i,n^2)+1);
i = i+1;
end