📄 animatedgif.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document. --> <title>How to make an animated GIF</title> <meta name="generator" content="MATLAB 7.8"> <meta name="date" content="2008-10-30"> <meta name="m-file" content="AnimatedGif"><style type="text/css">body { background-color: white; margin:10px;}h1 { color: #990000; font-size: x-large;}h2 { color: #990000; font-size: medium;}/* Make the text shrink to fit narrow windows, but not stretch too far in wide windows. */ p,h1,h2,div.content div { max-width: 600px; /* Hack for IE6 */ width: auto !important; width: 600px;}pre.codeinput { background: #EEEEEE; padding: 10px;}@media print { pre.codeinput {word-wrap:break-word; width:100%;}} span.keyword {color: #0000FF}span.comment {color: #228B22}span.string {color: #A020F0}span.untermstring {color: #B20000}span.syscmd {color: #B28C00}pre.codeoutput { color: #666666; padding: 10px;}pre.error { color: red;}p.footer { text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;} </style></head> <body> <div class="content"> <h1>How to make an animated GIF</h1> <!--introduction--> <p>This example animates the vibration of a membrane, captures a series of screen shots, and saves the animation as a GIF image file. </p> <!--/introduction--> <p><img vspace="5" hspace="5" src="../DancingPeaks.gif" alt=""> </p> <p>The resulted animated GIF was embedded in this HTML page using the Image cell markup (see <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f6-30186.html#breug1i">help for markup formatting</a>). </p> <p>Here's the M code.</p><pre class="codeinput">Z = peaks;surf(Z)axis <span class="string">tight</span>set(gca,<span class="string">'nextplot'</span>,<span class="string">'replacechildren'</span>,<span class="string">'visible'</span>,<span class="string">'off'</span>)f = getframe;[im,map] = rgb2ind(f.cdata,256,<span class="string">'nodither'</span>);im(1,1,1,20) = 0;<span class="keyword">for</span> k = 1:20 surf(cos(2*pi*k/20)*Z,Z) f = getframe; im(:,:,1,k) = rgb2ind(f.cdata,map,<span class="string">'nodither'</span>);<span class="keyword">end</span>imwrite(im,map,<span class="string">'DancingPeaks.gif'</span>,<span class="string">'DelayTime'</span>,0,<span class="string">'LoopCount'</span>,inf) <span class="comment">%g443800</span></pre><img vspace="5" hspace="5" src="AnimatedGif_01.png" alt=""> <p>For more details about GIF settings <tt>DelayTime</tt> and <tt>LoopCount</tt> for desired effect see the <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/imwrite.html#f25-752355">help for <tt>imwrite/gif</tt></a>. </p> <p class="footer"><br> Published with MATLAB® 7.8<br></p> </div> <!--##### SOURCE BEGIN #####%% How to make an animated GIF
% This example animates the vibration of a membrane, captures a series of
% screen shots, and saves the animation as a GIF image file.
%%
% <<../DancingPeaks.gif>>
%%
% The resulted animated GIF was embedded in this HTML page using the Image
% cell markup (see
% <http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f6-30186.html#breug1i help for markup formatting>).
%%
% Here's the M code.
Z = peaks;
surf(Z)
axis tight
set(gca,'nextplot','replacechildren','visible','off')
f = getframe;
[im,map] = rgb2ind(f.cdata,256,'nodither');
im(1,1,1,20) = 0;
for k = 1:20
surf(cos(2*pi*k/20)*Z,Z)
f = getframe;
im(:,:,1,k) = rgb2ind(f.cdata,map,'nodither');
end
imwrite(im,map,'DancingPeaks.gif','DelayTime',0,'LoopCount',inf) %g443800
%%
% For more details about GIF settings |DelayTime| and |LoopCount| for desired
% effect see the
% <http://www.mathworks.com/access/helpdesk/help/techdoc/ref/imwrite.html#f25-752355 help for |imwrite/gif|>.
##### SOURCE END #####--> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -