Changes

Jump to navigation Jump to search
no edit summary
(this page is a work in progress, this is a compagnon page to a MAPs article about the same subject).
== Introduction ==
If you wish to make an animation in your document, see the [[Animation]] page. This page will explain how to use [[MetaFun_-_MetaPost_in_ConTeXt|MetaFun]] to create a mp4 movie. Such movie can be embedded in a presentation, put on YouTube, etc, this will be a real movie !
The steps involved to realize such a movie are to (1) make a pdf such as each page is a frame of the movie, (2) convert the pdf pages to jpeg images, (3) assemble these images into a mp4 movie.
An animation is simply a series of images shown in order, one at a time. The number of images per unit of time determines the speed of the movie, a factor usually referred to as the ''framerate''. For instance, if we generate 300 images, we can create a 10-second movie at 30 frames per second, or a 20-second movie at 15 frames per second.
This tutorial will be to design and animate a movie showing particles moving along circles. The different images needed for the animation will be pages from the same PDF. The general structure of the code is as follows:
<texcode>
</texcode>
An ''MPpage'' has the size of the bounding box of all combined objects on the current page, so if objects move within the page, the page size will change. A solution to maintain control is to introduce a frame, which we can visualize as a camera frame. In the following, we refer to this frame as `TheFrame`. We can keep this frame fixed while subjects move within it, or we can keep subjects steady and move the frame, or even do both! In fact, if we think of a real camera, this is exactly the same concept. Let's consider a fixed square frame here, called `TheFrame`:
<texcode>
[[File:Project1_a-2.jpg|150px]]
[[File:Project1_a-3.jpg|150px]]
 
The number of frames needed for a movie can be large. For example, consider a five-minute movie at 30 frames per second: we would need 5 x 60 x 30 = 9,000 frames. If there are a lot of calculations for each frame, this could pose an issue. Therefore, during development, it could be useful to speed up the the processes : sometimes, it's possible to speed up or adjust the timing. For instance, assume the loop in the preceding code at line 12 is changed to:
<texcode>
currentframe := (#1-1)*100 ;
if currentframe == 0: currentframe := 1; fi;
</texcode>
 
The first page of the file will correspond to frame 1, the second to frame 100, the third to frame 200, and the last one, the fourth, to frame 300. This allows us to obtain a rough idea of the movie without generating every single page. However, as will become clear later, this approach is not always feasible.
Now that we have a PDF file, we need to convert the PDF pages to JPG images. This can be easily done with external tools like ImageMagick (https://imagemagick.org), a free open-source software for manipulating digital images. Once installed on your system, the command
currentpicture := currentpicture xysized (4096,2160);
</pre>
 
The number of frames needed for a movie can be large. For example, consider a five-minute movie at 30 frames per second: we would need 5 x 60 x 30 = 9,000 frames. If there are a lot of calculations for each frame, this could pose an issue. Therefore, during development, it could be useful to speed up the the processes : sometimes, it's possible to speed up or adjust the timing. For instance, assume the loop in the preceding code at line 12 is changed to:
<texcode>
currentframe := (#1-1)*100 ;
if currentframe == 0: currentframe := 1; fi;
</texcode>
 
The first page of the file will correspond to frame 1, the second to frame 100, the third to frame 200, and the last one, the fourth, to frame 300. This allows us to obtain a rough idea of the movie without generating every single page. However, as will become clear later, this approach is not always feasible.
 
== More animated objects ==
36

edits

Navigation menu