Intro
In the previous chapter, we learned about the p5.js frameCount variable that provides us with a number that represents the number of times the draw function is called. There are bunch of other highly useful variables that we could be using in p5.js. We will be learning about a few more in this chapter.
mouseIsPressed
mouseIsPressed is the first p5.js variable that we will see, that will allow us to add some interactivity to our programs. mouseIsPressed is a p5.js variable that assumes the value true when the mouse is clicked on the canvas area and false for every other time. Let’s alter our example from the previous chapter to quickly see how we can use this variable.
Clicking on the canvas area will now display the rectangle inside the circle. By ...
Access this course and 1800+ top-rated courses and projects.