File:Rotating black and white squares.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Rotating_black_and_white_squares.gif (500 × 500 pixels, file size: 2.52 MB, MIME type: image/gif, looped, 200 frames, 4.0 s)
File information
Structured data
Captions
Summary[edit]
DescriptionRotating black and white squares.gif |
Deutsch: Ineinander rotierende, schwarze und weiße Quadrate.
English: Rotating black and white squares. |
Date | |
Source | Own work |
Author | Jahobr |
GIF development InfoField | |
Source code InfoField | MATLAB codefunction Rotating_black_and_white_squares()
% source code for drawing the animation
%
% 2017-04-26 Jahobr
[pathstr,fname] = fileparts(which(mfilename)); % save files under the same name and at file location
fps = 50;
nFrames = 200;
rotShift = cos(linspace(0,pi,nFrames+1))*0.5+0.5;
rotShift = rotShift(1:end-1); % 0 and 2pi are the same image
xyLim = [-1 1];
figHandle = figure(15124455);
clf
axesHandle = axes;
hold(axesHandle,'on')
set(figHandle, 'Units','pixel');
set(figHandle, 'position',[1 1 1000 1000]); % big start image for antialiasing later [x y width hight]
set(axesHandle,'position',[0 0 1 1]); % stetch axis bigger as figure, easy way to get rid of ticks [x y width hight]
set(figHandle,'GraphicsSmoothing','on') % requires at least version 2014b
xlim(xyLim); ylim(xyLim); % set axis limits
axis equal; drawnow;
for iFrame = 1:nFrames
cla(axesHandle) % fresh frame
col = [0 0 0]; % start black
x =[-1 -1 1 1];
y =[-1 1 1 -1];
k = rotShift(iFrame);
while norm([x(1) y(1)]) > 0.5/900 % squares smaller than a pixel
patch([x x(1)],[y y(1)],col,'EdgeColor','none');
col = 1-col; % flip black and white
x = [k*x(1)+(1-k)*x(2) k*x(2)+(1-k)*x(3) k*x(3)+(1-k)*x(4) k*x(4)+(1-k)*x(1)]; % create next square
y = [k*y(1)+(1-k)*y(2) k*y(2)+(1-k)*y(3) k*y(3)+(1-k)*y(4) k*y(4)+(1-k)*y(1)]; % create next square
linearScale = 0.9;
constantOffset = 0.02;
cornerRadius = norm([x(1) y(1)]);
offsetScale = (cornerRadius-constantOffset)/cornerRadius;
% usedScale = offsetScale;
% usedScale = linearScale;
usedScale = mean([offsetScale linearScale]);
x = usedScale*x;
y = usedScale*y;
if usedScale<0
break
end
end
%% save animation
xlim(xyLim); ylim(xyLim); % set axis limits
drawnow % update figure window and execute pending callbacks
pause(0.01)
f = getframe(figHandle);
f.cdata = imresize(f.cdata,0.5); % the size reduction: adds antialiasing
if iFrame== 1
map=gray(8); % 8 colores % create color map % or use : [im,map] = rgb2ind(f.cdata,8,'nodither'); %
im = rgb2ind(f.cdata,map,'nodither'); % create first image
im(1,1,1,nFrames) = 0; % allocate
end
imtemp = rgb2ind(f.cdata,map,'nodither');
im(:,:,1,iFrame) = imtemp;
end
imwrite(im,map,fullfile(pathstr, [fname '.gif']),'DelayTime',1/fps,'LoopCount',inf) %
disp([fname '.gif has ' num2str(numel(im)/10^6 ,4) ' Megapixels']) % Category:Animated GIF files exceeding the 50 MP limit
end
|
Licensing[edit]
I, the copyright holder of this work, hereby publish it under the following license:
This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 22:28, 12 September 2017 | 500 × 500 (2.52 MB) | Jahobr (talk | contribs) | GraphicsSmoothing with matlab version 2017a, 8 colores, 500x500 px | |
09:06, 26 April 2017 | 450 × 450 (1.61 MB) | Jahobr (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following 4 pages use this file:
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on en.wikibooks.org