Changing Colors on Clickable Polygon

Hello, I’m new to the forum.
I was wondering if there’s a way to make a polygon change color upon click.
This is on the graph.

What I’ve done so far is create a color with multiple conditions:

D = B_{lue} {t=0}, R_ed{t=1}
B_{lue} = (0,0255)
R_{ed} = (255,0,0)
t = mod(a,2)

Where the clickable action on an object is
a_1 → a_1 + 1

So far the color will change from blue to red, but the object turns blue to black.

You’re on the right track. Here is an example: clickable polygon | Desmos

It’s always helpful if you post a link to the thing you are working on, because it can be hard in the plain text to see what’s working or not. Like I wasn’t clear if your issue was that you left off rgb from the color functions, or if there is a missing {} from the conditional, etc.

1 Like

There are a few ways to do this. Looks like you were trying to get to Method 1, but didn’t quite have the conditional syntax correct. I like the second method because it will leave your color palette less cluttered.

1 Like