Diese Datei stammt aus Wikimedia Commons und kann von anderen Projekten verwendet werden. Die Beschreibung von deren Dateibeschreibungsseite wird unten angezeigt.
functionAnalogClockAnimation2()% source code that produces a GIF and a SVG%% 2017-04-27 Jahobr%% create figurefigHandle=figure(15674455);clfaxesHandle=axes;hold(axesHandle,'on')set(figHandle,'Units','pixel');axisequal;set(axesHandle,'position',[-0.05-0.051.11.1]);% stretch axis bigger as figure, easy way to get rid of ticks [x y width height]set(figHandle,'position',[11900900]);% big start image for antialiasing later [x y width hight]xlim([-1.21.2]);ylim([-1.21.2]);map=gray(8);set(figHandle,'GraphicsSmoothing','on')% requires at least version 2014bangleOffPoints=linspace(0,2*pi,121);angleOffPoints(end)=angleOffPoints(end)+0.001;% fix small rendereing bug; otherwiese the line is not perfectly closed[X,Y]=pol2cart(angleOffPoints,1);plot(X,Y,'LineWidth',10,'color',[000])% outer line [pathstr,fname]=fileparts(which(mfilename));% save files under the same name and at file locationforminut=1:60% minute marksx_y=[00;... x0.90.95];% yx_y=rotateInMinutes(x_y,minut);plot(x_y(1,:),x_y(2,:),'LineWidth',8,'color',[000])% line endforminut=5:5:60% hour marksx_y=[00;... x0.750.95];% yx_y=rotateInMinutes(x_y,minut);plot(x_y(1,:),x_y(2,:),'LineWidth',12,'color',[000])% line end% hour handX_Y_hour=[00;... x-0.10.6];% ylinW_hour=20;h_hour=plot(X_Y_hour(1,:),X_Y_hour(2,:),'-k','LineWidth',linW_hour);%% minute handX_Y_minu=[00;... x-0.20.94];% ylinW_minu=12;h_minu=plot(X_Y_minu(1,:),X_Y_minu(2,:),'-k','LineWidth',linW_minu);%% second handX_Y_sec=[00;... x-0.20.94];linW_sec=8.0;h_sec=plot(X_Y_sec(1,:),X_Y_sec(2,:),'-k','LineWidth',linW_sec);%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2-hands %%%%%%%%%%%%%%%%%%%%%%%%%%%%set(h_sec,'xData',X_Y_sec(1,:),'yData',X_Y_sec(2,:)+10);% move second hand outticnFrames=12*60;foriFrame=1:nFramesminu=iFrame-1;x_y=rotateInMinutes(X_Y_hour,minu/60*5);set(h_hour,'xData',x_y(1,:),'yData',x_y(2,:));x_y=rotateInMinutes(X_Y_minu,floor(minu));set(h_minu,'xData',x_y(1,:),'yData',x_y(2,:));ifnFrames==60*60*12set(h_hour,'LineWidth',linW_hour*1.5);% thicker lines for the 12h 3Hands caseset(h_minu,'LineWidth',linW_minu*1.5);% thicker lines for the 12h 3Hands caseend%% save animation 1 "2 hands" 12-hourdrawnow;f=getframe(figHandle);f1=imresize(f.cdata,250/900);% the size reduction: adds antialiasingifiFrame==1% create variableim1=rgb2ind(f1,map,'nodither');im1(1,1,1,nFrames)=0;% allocateelseim1(:,:,1,iFrame)=rgb2ind(f1,map,'nodither');endimtemp1=rgb2ind(f1,map,'nodither');im1(:,:,1,iFrame)=imtemp1;%% save animation 2 "2 hands" 1-hourifminu<=60% 61 framesifiFrame==1% create variableim2=rgb2ind(f.cdata,map,'nodither');im2(1,1,1,61)=0;% allocateelseim2(:,:,1,iFrame)=rgb2ind(f.cdata,map,'nodither');endendendimwrite(im1,map,fullfile(pathstr,[fname'_2hands_12h_in_1min.gif']),'DelayTime',1/12,'LoopCount',inf)% (12*60)/12disp([fname'_2hands_12h_in_1min.gif has 'num2str(numel(im1)/10^6,4)' Megapixels'])% Category:Animated GIF files exceeding the 50 MP limitimwrite(im1,map,fullfile(pathstr,[fname'_2hands_12h_in_realtime.gif']),'DelayTime',60,'LoopCount',inf)%disp([fname'_2hands_12h_in_realtime.gif has 'num2str(numel(im1)/10^6,4)' Megapixels'])% Category:Animated GIF files exceeding the 50 MP limitimwrite(im2,map,fullfile(pathstr,[fname'_2hands_1h_in_6sec.gif']),'DelayTime',1/10,'LoopCount',inf)% 60/10disp([fname'_2hands_1h_in_6sec.gif has 'num2str(numel(im2)/10^6,4)' Megapixels'])% Category:Animated GIF files exceeding the 50 MP limitimwrite(im2,map,fullfile(pathstr,[fname'_2hands_1h_in_realtime.gif']),'DelayTime',60,'LoopCount',inf)%disp([fname'_2hands_1h_in_realtime.gif has 'num2str(numel(im2)/10^6,4)' Megapixels'])% Category:Animated GIF files exceeding the 50 MP limit%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3-hands %%%%%%%%%%%%%%%%%%%%%%%%%%%%ifnFrames==60*12msgbox(['Rendering for the full 12-hour-version will take about 'num2str(round(toc*60/60))' minutes.']);endset(h_hour,'LineWidth',linW_hour*1.5);% thicker lines for the 12h 3Hands caseset(h_minu,'LineWidth',linW_minu*1.5);% thicker lines for the 12h 3Hands caseset(h_sec,'LineWidth',linW_sec*1.5);% thicker lines for the 12h 3Hands casenFrames=60*60*12;foriFrame=1:nFramessecon=iFrame-1;x_y=rotateInMinutes(X_Y_hour,secon/60/60*5);set(h_hour,'xData',x_y(1,:),'yData',x_y(2,:));x_y=rotateInMinutes(X_Y_minu,floor(secon/60));set(h_minu,'xData',x_y(1,:),'yData',x_y(2,:));x_y=rotateInMinutes(X_Y_sec,secon);set(h_sec,'xData',x_y(1,:),'yData',x_y(2,:));%% save animation 1 "3 hands" 12-hourdrawnow;f=getframe(figHandle);f1=imresize(f.cdata,34/900);% the size reduction: adds antialiasingifiFrame==1% create variableim1=rgb2ind(f1,map,'nodither');im1(1,1,1,nFrames)=0;% allocateelseim1(:,:,1,iFrame)=rgb2ind(f1,map,'nodither');end%% save animation 2 "3 hands" 1-hourifsecon<=60*60% 3601 framesset(h_hour,'LineWidth',linW_hour);% normal linesset(h_minu,'LineWidth',linW_minu);% normal linesset(h_sec,'LineWidth',linW_sec);% normal linesdrawnow;f=getframe(figHandle);f2=imresize(f.cdata,115/1000);% the size reduction: adds antialiasingifiFrame==27*60+13if~isempty(which('plot2svg'))plot2svg(fullfile(pathstr,[fname'_still_frame.svg']),figHandle)% by Juerg Schwizerelsedisp('plot2svg.m not available; see http://www.zhinst.com/blogs/schwizer/');endendifiFrame==1% create variableim2=rgb2ind(f2,map,'nodither');im2(1,1,1,60*60+1)=0;% allocateelseim2(:,:,1,iFrame)=rgb2ind(f2,map,'nodither');endset(h_hour,'LineWidth',linW_hour*1.5);% thicker lines for the 12h 3Hands caseset(h_minu,'LineWidth',linW_minu*1.5);% thicker lines for the 12h 3Hands caseset(h_sec,'LineWidth',linW_sec*1.5);% thicker lines for the 12h 3Hands caseendendimwrite(im1,map,fullfile(pathstr,[fname'_3hands_12h_in_30min.gif']),'DelayTime',1/24,'LoopCount',inf)% (12*60*60)/24/60disp([fname'_3hands_12h_in_30min.gif has 'num2str(numel(im1)/10^6,4)' Megapixels'])% Category:Animated GIF files exceeding the 50 MP limitimwrite(im1,map,fullfile(pathstr,[fname'_3hands_12h_in_realtime.gif']),'DelayTime',1,'LoopCount',inf)%disp([fname'_3hands_12h_in_realtime.gif has 'num2str(numel(im1)/10^6,4)' Megapixels'])% Category:Animated GIF files exceeding the 50 MP limitimwrite(im2,map,fullfile(pathstr,[fname'_3hands_1h_in_4min.gif']),'DelayTime',1/15,'LoopCount',inf)% (60*60)/15/60disp([fname'_3hands_1h_in_4min.gif has 'num2str(numel(im2)/10^6,4)' Megapixels'])% Category:Animated GIF files exceeding the 50 MP limitimwrite(im2,map,fullfile(pathstr,[fname'_3hands_1h_in_realtime.gif']),'DelayTime',1,'LoopCount',inf)%disp([fname'_3hands_1h_in_realtime.gif has 'num2str(numel(im2)/10^6,4)' Megapixels'])% Category:Animated GIF files exceeding the 50 MP limitifispc;dos(['explorer 'pathstr]);end% open folder with files in itreturnfunctionx_y=rotateInMinutes(x_y,minut)anglee=-minut/60*2*pi;rotM=[cos(anglee)-sin(anglee);sin(anglee)cos(anglee)];x_y=rotM*x_y;
Lizenz
Ich, der Urheber dieses Werkes, veröffentliche es unter der folgenden Lizenz:
Die Person, die das Werk mit diesem Dokument verbunden hat, übergibt dieses weltweit der Gemeinfreiheit, indem sie alle Urheberrechte und damit verbundenen weiteren Rechte – im Rahmen der jeweils geltenden gesetzlichen Bestimmungen – aufgibt. Das Werk kann – selbst für kommerzielle Zwecke – kopiert, modifiziert und weiterverteilt werden, ohne hierfür um Erlaubnis bitten zu müssen.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse
Kurzbeschreibungen
Ergänze eine einzeilige Erklärung, was diese Datei darstellt.