To change the object shape characteristics

Hi. Please tell me how to make the figure of the object and clicking on it with the mouse to change its characteristics ? In the documentation there is an example, but there is a mouse click focused on the position of the figure. And how to simply specify the object and change the color for example ?

Hi @online, can you share what you have tried so far?

there is a more advanced example in the documentation that morphs a shape from a square, to a circle. This is a great example to modify. Hope this helps.


No, you are referring to an example without interactivity. I am interested in how to create an object from a figure and refer to this object to change its characteristics. For example, there is code:

w = innerWidth;
h = innerHeight;

var value = 0
min = 0
max = 255

function setup()

function draw()

function mousePressed()
	value = Math.floor(Math.random() * (255 - 0 + 1)) + 0 

How to change the color of the shape by clicking on it, not across the screen. But only without tracking its coordinates.

We make a class for it: :nerd_face:

We then add a property to that class for each characteristic we need to track down.
Plus we define methods that deal w/ those properties: :cowboy_hat_face:

Here’s an online sketch using a class which represents a colorful bouncing Ball: :balloon: