06 - More p5.js Variables

Learning About More p5.js Variables

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.

Get hands-on with 1200+ tech skills courses.