Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Before we leave this section, I wanted to introduce you to one other topic of things that you can use from your sketches to facilitate interaction between the user and the data. What there are are several contributed libraries that exist to provide a former graphical user interface to your sketches. And fortunately, these ones are all accessible through Processing's Add Library function. So what I'm going to do is, form a Processing sketch, it's just a blank one, I'm going to come over here to where it says Sketch and come down to Import Library. From there I go to Add Library at the top.
And Processing 2.0 has a new Library Manager that really facilitates a lot of this. And what I'm going to do is I'm going to come back up to the top and there are few libraries in particular that I want to look at. The first one, I can just go straight down to the GUI category. I want to get the first three of these; I want to get ControlP5 which has a range of controllers to build custom graphical user interfaces inside a sketch or separate windows. And I click Install, and that one's going to show up in just a moment. It's downloading and it's installing.
By the way, you may have noticed we've got a lot of red type down at the bottom which would make you think that things are falling apart. I assume this is due to some sort of incompatibility between some of the libraries and some of the alpha function in the Processing. Most of this will have no effect of what we're doing, so feel free to go ahead and just try running your sketches. I haven't had any trouble. I've been working this way for months. Next is GUI Components, a set of 2D GUI, which of course stands for graphical user interface, controls and multiple windows support. I'm going to install that.
It's starting and downloading. There we go. And the last one is Guido here, because that starts with GUI and that's a cross mode GUI library, so I'm going to install that one. I just want to show you examples from each of these things. I'm going to need to quit Processing and then open it back up. Let's go to File > Quit, and now that we're back open I can go to File > Examples, get the window here on this side. And now if I hit Contributed Libraries, you'll see that the three new libraries are all there, and I'm going to show you some very quick examples from each one of them and what they're able to do for your Processing sketch.
And the basic idea here is that all of them contain classes of objects that can be used, like buttons and sliders and knobs and rotators, that you can then integrate as objects into your own drawings. So let's take a quick look at ControlP5 first. By the way, P5 is from an old sort of abbreviation for Processing. At one point, the creators spelled Processing with fives instead of the Ss and the P5 came from that. But it has been a while since that one. First off, let's look at controllers. We have for instance check boxes, and I'm just going to click on this example, so you can see what it looks like.
And see what we're doing we're importing the library and then you create the class and an object within that class both for the CP5 and then we have a check box that gets created in this one. And these are the parameters that can be adjusted, and voila! You see that when I click on it, it changes the color in the circle. Also we get messages in the console. This makes it possible for you to click on a box, assign functionality to it, and affect another part of your drawing.
Let's come over here and try another one. I will close that and we'll just look at the slider. And in this case, it's just a matter of being able to assign values and you see how the background is changing from black up to white as we go through. Similarly, the slider down here is made to decode only discrete values as it slides across. Same for this one. And so three different kinds of sliders and what's kind of nice is they all fit very well with the aesthetics that usually go in Processing.
These are very clear, clean ones, and they give you a lot of options for incorporating new functionality in your own drawings. I'll close the ControlP5 and take a quick look at GUI components. What we have here is knob configurations, and we have some neat arc knobs that we're able to include. By moving these around you'll see how the values change on the bottom-left. We can also make it so that you actually have to move it in the angle, and make the code and it appears down at the bottom.
So this is a great way of including some of these controllers in your own things. These are all objects that are instantiations of custom classes for the knobs. Take a look at one other here, the timer, kind of a comical one, and what she creates what it calls the Balls of Vesuvius. And what we're able to control is how fast things fly out. And then they become much faster, and now they stop. And so an illustration of a way that you can use the buttons on the sliders to effect the interactive elements of your own sketch, so I'm going to close both of those, and just run through one more example in the Guido.
Let's take a look at button boxes and all this is, is indicating whether you have selected a button or not. You see I click on it; it stays clicked until you go back. Very fundamental things, but it's nice to be able to use the shortcut classes and objects as opposed to having to create each of these from scratch. It makes a little easier to incorporate the interactive functionality. Can I suggest that you spend a little bit of time with each of these three libraries finding out how well they work for you and how well you are able to incorporate them to add extra functionality to your own sketches.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101646 Viewers
61 Video lessons · 88404 Viewers
71 Video lessons · 72239 Viewers
56 Video lessons · 103980 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.