Moving Pictures Animation

Pictures Wandering Around





In diesem Animationsprogramm wandern Bilder innerhalb eines für den Betrachter unsichtbaren Gitters auf dem Bildschirm umher. Es können auch Bilder benutzt werden, die der Anwender des Programms in geeigneter Form bereitstellt. Anzahl und Darstellungsgröße der Bilder können frei gewählt werden. Das Programm kann kostenlos heruntergeladen werden.  (s. unten)





In this animation program, images are wandering around on the screen within an invisible grid. It is possible that the user lets the animation show his own choice of images, on condition that he provides them in suitable form. The number of the pictures can be chosen rather freely, as well as their display size. The program can be downloaded free of charge. (See bottom of this page)




Program Features


The pictures you see on the screen are arranged within an imaginary grid. Most of the cells in this grid are occupied by pictures but there are also cells with nothing in them (“gaps”). In the beginning, when the pictures are loaded from the hard disk, each column of the grid contains exactly one gap. The rows of these initial gaps are chosen at random.


During program execution there are always some of the pictures moving around whereas the others are standing still. Movement is motivated by filling gaps. A gap is filled by moving a picture of a neighbored cell into it. Every time a gap is being filled a new gap is emerging in the cell of the gap-filling picture. And this cell will have to be filled afterwards.


The program works in rounds. In the first round the initial gaps are filled. In every round following the first, those gaps will be filled which are the consequence of filling the gaps of the previous round.  Thus movement continues and it will not come to an end until the user stops the program.


In the left picture below you see a 4-by-4 grid in the initial state. There is exactly one gap in every column. Movement has not yet begun. The picture on the right shows the same grid in a much later phase. Most of the pictures and gaps have changed their places, and some of the images are right in the midst of their wandering from one position to another.





How to use the program




The images shown on the screen are loaded from a folder called 'picsR' which resides in the folder of this workbook. There are already images in picsR so that you can test the program using them. But normally you will want to use your own pictures.


You can easily replace the pictures in picsR by your own picture collection. Be sure to obey the following rules:


  • There should be enough pictures in the folder to fill the grid. For a grid of n rows and m columns you need n * m - m pictures. In principle, we would need one picture for each of the cells, but as there is one gap in every column we need m less than n * m.

  • The maximum number of pictures that can be managed by the program is 999.

  • All pictures should have the same width-to-height ratio. If this is not the case for your own pictures you should first give them similar proportions by adding margins. Irfan or another imaging software will do this for you.

  • Don't use high resolution images. Use a resolution which is just as high as necessary.

  • Pictures have to be numbered p001, p002, .... Again, let Irfan do this for you.




Set parameters and run the program


Open the movingPicturesV1.xlsm workbook. Be sure that macros are allowed to be executed. There are three visible worksheets in the workbook :


  •  Worksheet show is empty in the beginning. It will be used to display the animation.

  • Worksheet about provides a short introduction into the use of the application.

  • Worksheet start contains a form where you can input the necessary parameters and start the program.



There is another worksheet (default) which is used by the program to store the parameter settings. This worksheet is invisible to the user.


Change to worksheet start in order to get to the input form:





 First adjust the parameters in the form according to your needs. Try which values suit you best. There are only two rules you should strictly obey:


  • The size of the pictures must not be larger than the cells of the grid.

  •  Cell width and cell height should be divisible by 10

When you have found a suitable parameter constellation you may store it using button <save as default>. You can later restore these settings by pressing button <restore default>. Please note that pressing the save button has only the effect of saving the parameters on worksheet default (see above), not on the disc.


After having set the parameters you can start program execution by pressing the <start animation> button.


As the program uses an infinite loop, it will not stop by itself. But don't take rigorous action like switching off the computer. There is a method to stop it softly. Just press the <shift> key and hold it down for a while. Let it free again as soon as the images have stopped moving..


When you close the Excel workbook don't forget to save the changes. Otherwise, your default settings will be lost, even if you pressed button <save as default>




Program Architecture


The program has a three-layer mixed architecture. ‘Mixed’ means that an object-oriented kernel is used by a traditional module-based user interface.






Module Show contains the essential parts of the user interface. For every button in the input form of worksheet show there is an event procedure in this module containing the code that is executed when the button in question has been pressed.  There is also a function validationOK in the module which helps the event procedures in determining whether the input in the text fields above the buttons is correct. Function validationOK does not all the validation work itself but makes use of module Validation which provides commonly used validation routines like integer checking.


When the user has pressed button <start animation> module Show creates an instance of the MovingPicsAnimator class and puts it in charge of the execution by calling the class’ procedure doAnimation. This procedure controls the animation task with the help of some private procedures and functions which are also contained in the class. It works in rounds. In the first round, those gaps are filled which are inserted into the grid at random when it is filled with pictures. In every round following the first, those gaps will be filled which are the consequence of filling the gaps of the previous round.


The MovingPicsAnimator Object uses an instance of the GridManager class in order to keep track of the positions of the pictures within the grid. Actually, this instance does the principal part of the logical work. At the end of every animation round it produces for the MovingPicsAnimator object a compilation of the necessary gap-filling movements of the round to come.


As has already been indicated above, the animation is executed within an infinite loop which can be stopped by pressing the <Shift> key. In principle, there are means to catch a key stroke in VBA, but they do not work reliably. This is why I used a Windows API function instead. This function is declared in the Declarations module.


Please note that, although the methods of output play a dominant role in this animation, there is nonetheless what software engineers call separation of program logic and user interface. Program logic resides in the GridManager class, whereas the UI is contained in the other modules and classes.






MovingPictures Animation, Excel workbook + folder containing sample pictures
Komprimiertes Archiv im ZIP Format 21.2 MB