Hi, welcome to this new video. This is the final video of week four. We're going to be learning how to save animations. So we're going to jump directly into processing to discuss how we're going to do this. And we're going to continue working on the script and the folder that we have from last session. So if you haven't covered the last two sessions, we develop a simple script, a composition that we started to learn how to save frames from it, right, using the keyPressed function. So if you haven't covered that video, go back, check that one first, and then resume here. So we're going to discuss how we can actually save an animation. So I've tried different techniques for saving animations. You might want to just get an MP4 file or an AVI file or MOV, right, directly a video that you can execute, right? And while that might be great, it might also not play and perform as the way you expect it, right? Many times processing, depending on how much content you have in the screen, might slow down and might kind of play at a suboptimal frame rate, right? So what we want to do is save every frame and then reconstruct that video in different packages, things like premiere automatically kind of understand sequence of images as an animation, right? So I'll show you how to do that, how to create a sequence of images that then you could actually import into a video editing package to kind of produce a final video. So let's do that. We're going to use the same technique, but this time, we're going to assign to a different key the recording of an animation. And what we're going to do is basically the idea that we can press a button, in this case the button r in the keyboard. And that will turn on a recording state or a variable that would be a Boolean, true or false, that would be recording. While we are recording, we are saving every frame. So at the end of the draw loop there would be a line saving frame, right? So let's start by creating that variable. Let's call it a Boolean. A recording equals false. So there's going to be a Boolean because we identify it as a false state to start with, right? And we're going to copy that, and then here in the draw loop, we're going to use it. So let's declare it first as a global recording, and towards the end, and you have to be clear and careful with your indentation. Towards the end of the draw loop, we're going to say, if recording, right? So if recording, this is a shorter way of saying is true, right? You can omit the is true part by saying, if recording, the language would automatically understand if this is true, right, that's just for explicit reasons. Let's just do this, but many times you'll see code without that equals true, right? Something happens, so what happens? What we've done before is, we save the frame. And in this case, let's save it into animation folder, and let's give it an animation, the name of the frame, the number of the frame, right? So, currently, our recording variable starts as false, but if it's true, we start recording and basically saving every frame, right? Notice that the software or the program will start running a little bit slower once we start saving every frame, right, because every frame, we are kind of recording data to the drive, right? So you might see the performance drop of your animation. But don't worry, because once you reconstruct your animation, you're not going to notice that slowdown. The animation would play as if it was perfectly smooth at, let's say, 30 frames per second or whatever frame rate you decide that your animation should be playing at, right? You can define that in your video editing package. So let's go into if. So here, if key, Equals r, because what we're missing at this point is like how do we turn on the recording, right? So we're going to create this with another key, or the key equals to R. In this case, instead of putting the safe frame function and the print, we can say recording equals not recording. And this line might be confusing, so what is this line saying? It's saying, well, we're using the not-operator, and not is kind of flipping a Boolean state from true to false or from false to true. So if this is false, this will become true. And if it's true, it will become false, right? So it's kind of an inversion, and we could say, print recording. We have a little bit of an exclamation mark for the drama there, right? But as you can see, we are activating this Boolean at this point that would trigger here. We might also want to make sure that, We're using, in fact, the recording from global variable here. Let's see if this works. So we have our composition. I'm going to press R. So recording starts being true. As you can see, my canvas starts coming a little bit slower. And when I'm done, I could press R again, or just close it. Let's go into the folder. And we have an animation folder. And as you can see here, we've created a series of files. All of these files are simple images, right? But if we try to open these files in something like premiere, after effects, and many other packages, just by locating this folder, you will see the option to understand all these files as a sequence that's already an animation, right? So that shouldn't be too much trouble to kind of edit using this sequence of images as an animation. So I got very good results from this technique. It actually works very well. So I invite you to try it. So with that, we're going to be concluding week 4. I'll see you in our final week, week 5. See you then.