Adding and Substracting Polygon or Image or Point Using Clickable Action

Hello,
I just learned about CL and action on Desmos activity this week.
Currently, I’m trying to build an activity where the user can add an image or polygon by clicking a button (a clickable item on Graph).
Here’s the activity.

Can anyone help me with how the action should be that the button adding a new square instead of moving it?

Hello, I really like the activity so far!
Try changing just line 4 to:
Screen Shot 2022-12-31 at 10.18.21 AM

The key change is the part that says ‘for i=[…]’. Here is a support article that explains more about how it works in the section called ‘List Comprehension.’ I hope this helps!

Thank you! It works very well.

Here’s the activity I build by adding your line of code.

Is there any way to like ‘calling’ the item to appear? Because in the activity, I hid the first square behind another square.

And, can we set the list of polygon to be in different row and column? (just like shown in the folder Points)

Instead of creating a new polygon each time, you could use the lists of polygons you made in your first graph, and just use the n+1 and n-1 actions to reference only part of the list:


If you don’t want to fill a whole row at a time, you can make a list of the order you want to show them:

It works perfectly! :smile:
Thank you so much for your guidance!

You can also make a color list using rgb( ) or hsv( ) functions if you don’t want the same color for each one. Have fun!

Cool!
That’s the thing, I don’t know many function such that.
Do you know any page for reference?

I just googled color picker, and there’s a tool that pops up that lets you pick a color, and you can copy-paste the rgb numbers. Here’s an example of using a list of colors:

You’ll need enough elements in the color list to match your polygon list

Waw, join() that’s totally new for me as rgb(), polygon() (the very basic right?).

Anyway, thanks for your great help, I now manage to do the adding-substracting with image in this activity.

I have a lot to learn though :smiley:

join( ) is very handy. It literally joins 2 or more lists in the order entered. rgb( ) is the red green blue code. hsv( ) is hue, saturation, value which can allow for some gradients using lists for one of the first two parameters, but I haven’t messed with that.