Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The third primitive shape that we're going to deal with in Processing is circles, or more properly ellipses, because, Processing does not have a built in circle function. Instead, if you want a circle all you need to do is draw an ellipse that has the same height and width. But let's show you some of the things that we can do with these basic shapes in Processing. The first thing I'm going to do, like all the others, is I'm going to put the name of the file as a comment at the top. I'll Save the file by hitting Ctrl+ S on the PC or Cmd+S on the Mac.
Then I'm going to put in the size of the window. Like the others, I'm going to use a 600 x 200 window, an arbitrary choice, the one that I'm using for this course. I'm going to turn on anti- aliasing to smooth in the shapes. Then I'm going to put in a background color. I'm using hex codes from palettes that I have developed elsewhere. This particular one is 678C8B and be a teal color, in fact, I can Run it and there you see.
Now, what I'm going to do is I'm going to draw my ellipses. Now, this is the first shape that we're going to do, first primitive shape that has a border that is separate from the inside, because points and lines theoretically have no internal components, at least internal colors. So, if I simply draw an ellipse, the command is ellipse, remember if I want a circle, I just make the height and the width the same. First, I need to position it, and what I've done is I put the center of the ellipse 100 pixels over, 100 pixels down.
Then I'm going to make it 150 pixels wide and just for fun, I'm going to make it 100 pixels tall, so it actually is going to be an ellipse. If I press Run, what you see is the default, at white Fill with a black Outline. Now, in this particular sketch, I don't want the outlines, and the way you get rid of those is by the Stroke command. And actually, now if I want to get rid of this stroke entirely, instead of just changing its color, there is a special command for that, it's noStroke. Please notice the BumpyCaps, where I have to have a capital S in the middle of this.
And then because it's a function, I do need the open and closing parenthesis () and a semicolon (;). Now in this case, I also want the center of the ellipse to not be at the default white, I'm going to use a different color from the palette that I put together. So, I type in the fill command, I'm using the hex code again, this one is 8FA89B, in parenthesis with semicolon at the end (;). And actually, if I just Cmd+R right now, you can see that's really how it looks like. There's a slightly lighter ellipse on the background. I'm going to do one other thing though, because, you also have the option of making your shapes transparent through the addition of another parameter in these, it is called the Alpha.
And it starts with 0, which means it's completely see through; you can't see it all up to 255, which means it is completely opaque. In this case, I'm going to choose a mostly opaque value of 200, which means you will actually see some of the background through it, so it's going to be a slightly different color than what it was before. Then I'm going to draw a few other ellipses. I'll just copy this text and make a few changes to these. I'm going to be using different colors for each one of them.
I'm also going to change the coordinates for each one of these and move them over to just 100 pixels each. Otherwise, they all stay at the same Y level, 100 pixels down, and they'll have the same height and width. So, I Save it and Run the sketch. And, now we have four overlapping ellipses. You can see that they are slightly transparent, you can see through each of them. Now, there is one interesting thing I mentioned earlier; all of these were drawn from their center coordinates, that's the first two coordinates I give in the ellipse command, are the X and the Y for the center of the ellipse.
There are other ways of placing the ellipse. If for instance, you had a situation where you wanted to place it by the top left corner, if you drew a bounding box around the ellipse, you could do that as well. Let me show you how that works. I'm going to come down here and I'm going to type in ellipseMode and that means how it is positioned. And I put in parenthesis now, I have to put this one in all caps and put CORNER; and then I'm going to put in the Fill again for another ellipse and then I'll put the coordinates.
But, this time I'm drawing it from the top left of the bounding box. And this one, I'm going to make circular. I'll Save it all and press Run. Now, you can see a couple of interesting things here. Number one, it is circular. Number two, it goes off of the display window. You can give coordinates that are completely off the window. Processing will still draw them, you just won't see them. Similarly, you have the option of drawing a display window that's much bigger than your screen, again Processing will do it, you just won't be able to see it.
So you do need to be careful about how you position things, because it will go ahead and do it, even if theoretically it wouldn't be visible. Anyhow, this is the third of the primitive shapes that we're doing with Processing, circles or ellipses which can also be drawn as circles.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 103171 Viewers
61 Video lessons · 89863 Viewers
71 Video lessons · 73486 Viewers
56 Video lessons · 105024 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.