% Back and forth
% David Worden
% thediscobar@gmail.com
% http://thediscobar.blogspot.com


Width = 32;
Height = 16;
Colors = 3;
Frames = 64;

animation = zeros(Width,Height,Colors,Frames);


%%  Red  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F=1;
for W=Width:-2:1
    for H=1:Height
        animation(W,H,1,F) = 255;
    end
    F=F+1;
end

F=33;
for W=2:2:Width
    for H=1:Height
        animation(W,H,1,F) = 255;
    end
    F=F+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%  Yellow  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F=1;
for W=Width:-1:1
    for H=1:Height
        animation(W,H,1,F) = 255;
        animation(W,H,2,F) = 255;
    end
    F=F+1;
end

F=33;
for W=1:1:Width
    for H=1:Height
        animation(W,H,1,F) = 255;
        animation(W,H,2,F) = 255;
    end
    F=F+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%  White  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F=1;
for W=2:2:Width
    for H=1:Height
        animation(W,H,1,F) = 255;
        animation(W,H,2,F) = 255;
        animation(W,H,3,F) = 255;
    end
    F=F+1;
end

F=33;
for W=Width:-2:2
    for H=1:Height
        animation(W,H,1,F) = 255;
        animation(W,H,2,F) = 255;
        animation(W,H,3,F) = 255;
    end
    F=F+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%  Green  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F=1;
for W=1:1:Width
    for H=1:Height
        animation(W,H,2,F) = 190;
    end
    F=F+1;
end

F=33;
for W=Width:-1:1
    for H=1:Height
        animation(W,H,2,F) = 190;
    end
    F=F+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%  Dark Orange  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F=1;
for H=1:1:Height
    for W=1:Width
        animation(W,H,1,F) = 255;
        animation(W,H,2,F) = 140;  
    end
    F=F+1;
end

F=17;
for H=Height:-1:1
    for W=1:Width
        animation(W,H,1,F) = 255;
        animation(W,H,2,F) = 140; 
    end
    F=F+1;
end

F=33;
for H=1:1:Height
    for W=1:Width
        animation(W,H,1,F) = 255;
        animation(W,H,2,F) = 140; 
    end
    F=F+1;
end

F=49;
for H=Height:-1:1
    for W=1:Width
        animation(W,H,1,F) = 255;
        animation(W,H,2,F) = 140; 
    end
    F=F+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%  Dark Violet  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F=1;
for H=Height:-1:1
    for W=1:Width
        animation(W,H,1,F) = 148;
        animation(W,H,2,F) = 0;
        animation(W,H,3,F) = 221;
    end
    F=F+1;
end

F=17;
for H=1:1:Height
    for W=1:Width
        animation(W,H,1,F) = 148;
        animation(W,H,2,F) = 0; 
        animation(W,H,3,F) = 221;
    end
    F=F+1;
end

F=33;
for H=Height:-1:1
    for W=1:Width
        animation(W,H,1,F) = 148;
        animation(W,H,2,F) = 0;
        animation(W,H,3,F) = 221;
    end
    F=F+1;
end

F=49;
for H=1:1:Height
    for W=1:Width
        animation(W,H,1,F) = 148;
        animation(W,H,2,F) = 0; 
        animation(W,H,3,F) = 221;
    end
    F=F+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%