Hi, welcome to this new video on our Python course. Today we're going to continue talking about primitives. It's something that we introduced in the last video. We've called this one advanced primitives. But it's not necessary that they're very advanced. It's just starting to think of primitives that might require a series of lines of code to actually construct the totality of the primitive. There again, very open ended constructs that are kind of available for us. Let's see what we mean by this. Let's imagine that we want to construct something like a polyline. Something that is not necessarily a particular line that is established between two points, but rather something that has an x number of points, maybe more or less points, so how would we do that? Well, we have a keyword here within the processing environment that's begin shape that would open up the possibility to start introducing vertices. Vertices will represent points in this line, and as you can see here, we can actually describe one point with one line called vertex. But then the system is understanding that this is a sequence. We will be talking about sequences of data in the future, but for now, our very first is starting to understand that the construct of this polyline is actually a sequence of vertices. The vertice is a point. Then we go to the second point, again thinking coordinates x and y in each one of those cases and then we finally go through four points and then whenever we feel like we are done with this line, we can do end shape. The end shape is also a keyword that would close not necessarily close, but end the operation of constructing this poly line. How many points can we have? We can have a very large number of points. That number is quite arbitrary in the sense that we could decide to do just a simple line between two points or something more complex. Obviously, we have a shortcut for a straight line that doesn't require vertices. But perhaps it's something that changes and we'll talk about adaptation in the future as well. This construct is quite open for us to add more vertices if we want to or perhaps a smaller number. There's also some options, and I'm going to show you one of them. You can actually look in the reference files and you'll see that there's a series of options regarding of how polylines actually behave. But for instance, if we specify the variable close in the end shape, like the last line, we will see that the segment of the line between the last point and the first point automatically gets generated for us. We could go around this rule and basically repeat the first vertex towards the end of the sequence and in that way, basically we don't need to specify close, but the close keyword would actually allow us to automatically not duplicate vertices, and suggest that the polyline closes in itself. We can use that form with fields. We can actually add a field to it, so it actually has a very specific shape that could have a background and also the stroke weight. Let's go into processing and write some of this together. We're going to start here on what I would call the boilerplate for our programming. We will most often need a set up and a canvas size which we can leap behind. You can save this as a template. We're going to be working within the draw function this time. There's no real reason for this. But as we go along, we're going to be working more and more with dynamic content and that dynamic content makes most sense to be working on it within the draw loop. Let's do begin shape, and we can skip a few lines and do end shape. Between these lines we know that we have to add some vertices, so the keyword is vertex, and you can do any value you want within the Canvas. You can actually do points outside the Canvas, but they might not really be visible. So you will see your shape going outside the Canvas. Sorry, I know I misspelled that, but we can actually go ahead and copy that line a few times as you can see here. Then we can actually start going through the numbers. Sometimes I really like sketching many times when I'm thinking of coordinates and I'm starting to think of a figure, sometimes I even use a cat package, something like rhino or any kind of drawing package that would allow you to see coordinates. If you want to create a specific geometry that then later you might want to manipulate. It might be worth considering measuring those things in another software package where you can just pre-draw those shapes, know your coordinates. Later in this series, we'll actually see how to export and import things from other content, from other kind of different forms of information that could be read by processing. If you have knowledge in other kind of software packages that might offer you those capabilities of exporting material, perhaps that would be also useful. But let's just do some shape attributes here and let's see what options we have. Again, here I'm trying to go for something that I couldn't do with just a rectangle. You can see here, this geometry. It's quite arbitrary. Eventually when we start learning about animation, we'll see that maybe one vertex is something that we want to maybe move this vertex or let it wander around perhaps and you'll see that you'll start getting an animation of the geometry. Sometimes when you have constructs and primitives that are already established to be a circle or to be a rectangle, you're locked into thinking of that geometry like that all the time. But when you're actually creating your own custom, perhaps more advanced geometry, like a polyline, in this case, like the geometry that emerges out of drawing this polyline, you have a lot of flexibility and it really opens up design possibilities that are quite interesting. Similarly to other primitives, you can actually style and color these geometries with fill. We could say, well, fill(0,200,200,50) just to give it some transparency. Let's see how that looks. You see we have some CN slightly transparent. Maybe we want to have a white stroke that would be 255. Let me just scroll down a little bit here so we have a bit more room to see. Also the stroke weight of two. As you can see, we can style these geometry is the same way we would do a rectangle and any other primitive. There's a lot of flexibility. As you can see, we're not getting the line as much as the geometry fill that it's closed. Let's just actually do a no field for a moment. Let's comment this out because the fill is suggesting, or it's giving us the wrong impression that in fact that geometry has been closed, so let's do a no fill. You see that we actually haven't closed that geometry yet. Let's just do the option close here. You'll see that now the line appears on the other side. Again, I really like this technique, you'll hear it a lot from me during this course, like commenting out a line, lines that I know that it might want to evaluate while I'm designing, so you might just have a version of that line. Maybe you're still deciding if you want to use a fill or no fill, and that's something that you can evaluate later as you can intuitively work through your design iterations. You'll see me doing this quite a bit. Leaving lines that I might use as a comment, so commenting out a line, it's very useful. Again, this is what we're doing with more advanced primitives. There's a series of even more advanced primitives, I would say, that allow you to base your type of curves that you could specify not only vertices but anchor points and create curvature between those. I'll leave those for you to explore. It really behaves the same way we can see here with the polylines but I'll continue showing you more content in the next video. I'll see you then.