So the first thing we need to understand, and here I'm going to add a little bit more of an additional piece of data that we will need to construct a class, are the elements that we need in a class. So we discussed that in the example that we were giving of a class of a dog, we would need some data. Initially, we would also have a series of functions, but in between those two, we'll offer the possibility for a constructor. A constructor is a method or a particular element within a class that allows us to initiate that class and assign some variables. And it's incredibly useful, especially when you want to have classes that begin having different kinds of information. So let's look at how will we construct our class dog? As you can see in the left, we have the class definition with the name of the class. Then we have a variable, a particular variable called the name, and we will assign the string max, right. So after that we could actually create an instance of that class. We are using the d1 variable here. Think of it as dog 1 =, and we initiate that class of the class Dog, we construct basically an instance of that class. And if we print now the variable d one name, the dot operator here is used to access the data that lives inside the class or inside the instance of the class. Actually, in this particular case, the printout will read Max, right, which is the name of this particular dog. But this class doesn't really have the chance that we could change the name of the dog. It's kind of hard coded into the class, the name of Max, right? So how would a constructor really operate? A constructor, we're using this particular line of code. You can read here def and init, and we can specify that this dog will actually have a name and an age. And here we use the self keyword to identify the variables that refer that are internal to the class. So we can say self.name = to the name, which is information that will be passed whenever we construct the class. We'll see that in a few lines below. Self.age, so the internal variable h to the class is assigned to whatever it's passed as an argument in the constructor. And then whenever we construct an instance of the class, as you can see here, d one, our dog one is a dog. But now instead of an empty parenthesis, would actually provide arguments for the constructor, in this case the name and the age, right. So Max refers to the name, and we use a comma to give the second argument for the age. So if we print d one name we will still get max, but we could construct a different dog with a different name, and we can construct any number of dogs with different names and different ages. So this is how the constructor is giving us in a way a template for the kind of information that will be passed on for that class to operate. It could be changing name changing any kind of data that we decide is important for that class. Let's look at another example. As we discuss here, we can actually use functions. So before our previous class didn't have any functions. In this case, we will maintain a very simple constructor that only receives the argument of a name, where we assign the name to the dog. But then we can actually create a function that lives inside the class. So this function lives inside the class, meaning that it's a function that belongs to the class. So the barking will be a print, spells out the word woof, right. So if we construct the dog, in this case, use d1 to assign a new dog called max, right. And we use the function d1.bark, the system will print out woof, will actually print out the function. So we can actually invoke functions of the class as well as accessing its data, right. So these are kind of the different ways in which we will start constructing one of these classes. We're going to jump into processing and write one together. So let's do that. Okay, so here we are in processing. Let's write our first class. But before I really want to give you some reference of how a class is written in context to some other functions, like the setup and the draw function. So let's start our script as we do often with the depth setup. And let's create a size of 1200 by 600 and a background. Okay, there we go. So we have here our canvas, right. Then we have also the possibility of our draw function. But we're not going to use a draw function just yet. So what we're going to do is write a class, but we're going to write it just before the setup. What it's important here is that a class is a completely autonomous entity, and we can think of it as an incredibly modular piece of. It's a block, like a function, that can be moved around, right? So we're going to write our first class here. We're going to start writing a class just above this setup area, right? So let's just use the keyword class. And we're going to write a class. We're going to aim to write a class of something that we've already written before, right. So let's start with the idea of a gradient rectangle, when I've spelled that correctly, a Gradient_Rectangle. And like so, we actually have a class defined as a gradient rectangle, right. So we can actually now create a constructor for the class. So I'm going to use the def and the_ _ init_ _. The first time I was learning Python, this kind of syntax felt relatively obscured or kind of complicated. It's something that you have to learn and get used to it and suddenly you'll be using it all the time, so it's not going to be much of a problem. So we are going to use the keyword self to identify that this class has in fact internal variables. And we are going to use a couple of, but we can create a couple of variables. We have been looking at things like vectors, we have been looking at things like integers. So let's just create a vector position and the rectangle size. So this is going to be the size of our rectangle. So we're going to use a position to mark the position of an entity in the screen and then a position, sorry, the size of the rectangle, right. So now after the constructor, we have to identify how, sorry, we needed this semicolon here. We are going to assign that the self.vec_position, Becomes, and again, this is something that I remember finding confusing. So this variable vec_position refers to the information passed from outside the class. Once we construct the class, we pass an argument, right? So this is a temporary value that is going to be passed on to the internal value, that is the self.vec_position, right. So you could name this something different, right. In some languages, in Java, for instance, if you do processing Java, a lot of people use the underscore beforehand to indicate that it's a temporary variable that is being passed on to the actual variable, right. But those are conventions, so we're going to just keep it this way. So self.rec_size is going to be rec_size, right. So just to reiterate, this rec size here, which is the argument passed in the constructor, it's not the same thing that here we're assigning them to be equal, but we could by all means call it r. Right, I'm going to undo that, but we are just passing the arguments into the internal variables, right. So at this point we should have a class, a gradient rectangle, that if we want to construct an instance of that class, we can do so by providing a vector and a size, right. So let's just create that rectangle now, in our setup here. So we can actually do something like gradient rectangle 01, some name for the variable that will be that gradient rectangle. Let's use the name of the class Gradient_Rectangle, just to make sure that we spell it correctly. Gradient_Rectangle, right. And then when we open parentheses, we need to provide two values, which are the values that we define as entities in, or arguments that are requirements for the class, right. So in this case we could do Pvector (50,50), and then we could also do 50, which will be there. So we have one vector as the vec_position, and we have 50 to be the rectangle size, right? So let's just double check this is running. So this is actually working. We have the arguments, we have constructed a gradient rectangle with those two pieces of arguments, right, or those two arguments. But sometimes you might have so many arguments that it might be difficult to keep track of them. So Python offers us a very interesting way. I'm going to just get a little bit more room here to write further down. We want to provide the vector position. So we could also make it a little bit easier for us. It's a bit more code, but it makes it a little bit more explicit. Vector positions equals this first argument, right? And in Python, we could also use the press Enter for jumping into a new line, and we can use the rectangle size = 50. So this is exactly the same of what we had before, but we are actually making it explicit, we're giving an explicit expression that the first argument is the vector position and the second one is the rectangle size, right. We do not need this material here. I'm adding it because it just makes it a little bit more clear as we are going for the first time through a class, that in fact, what we are providing is the first argument that refers to this vector position. And the second argument, which is a 50, refers to this second argument. I'm a personal fan sometimes of having slightly longer code that is more readable, especially when I'm teaching, especially when I'm learning certain things, just to make it very clear for myself. So at this point, we have constructed a class, but we haven't really seen any graphic content of the class, right? So let's go ahead and do a small function. So the function that we're going to create, it's going to be a draw function, a function where this kind of rectangle draws itself into the screen. So let's do the def draw function, it's not an inbuilt function. Maybe we could name it something different. Let's call it display. So the display function, it's going to be for us. We do need to pass on the self here for having access to all the variables that are belonging to the class. And here we can actually use things like noStroke and fill. Let's just do this rectangle red for now. We can pass a color later on and change the color of this rectangle, but for now, it's going to be all red. So rectangle here, we know that the rectangle requires the position, but we will use the self.position.x self.position.y. Because we know the rectangle requires two positions and two sizes. And then for the size, we're going to use the same size in x and y for those two variables, right. So now the display function of our rectangle basically draws itself, right? So I like sometimes just to remind ourselves that this area up here, between this section and this section here, and we're going to learn how to use multiple files and different tabs in processing and all these ways of organizing your code. But for now, I just wanted to make sure this is the definition of a class, right, all this area here. We have the constructor and we have the display, which is one of the first function. Once we've constructed one entity, we can invoke their functions. So let's just do the name of our instance. In this case, the gr_01 is an instance, and inside that gr_01 is the display function. So we actually can invoke the drawing of that class. So now we actually get the drawing of that class appearing in the screen, like so, right? So just to reiterate, we are starting to construct a class. We are going to be learning how to pass different arguments. How do we create multiple instances of classes and so on. But for now, we are actually just creating a modular block of the class. And we are kind of starting to learn how to create an instance of a class, which is in fact the way that class appears into the screen. So I'm going to take you through multiple instances of classes in the next session. I'll see you then.