# Adding and Substracting Polygon or Image or Point Using Clickable Action

**URL:** <https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633>\
**Category:** Questions\
**Created:** [December 31, 2022, 9:11am UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633 "2022-12-31T09:11:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![maryamratna](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/maryamratna/32/4038_2.png) [@maryamratna](https://cl.desmos.com/u/maryamratna)\
**Post date:** [December 31, 2022, 9:11am UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/1 "2022-12-31T09:11:27Z")

</div>

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](https://www.desmos.com/calculator/0508221a7a?lang=id).

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

---

<div class="post-metadata">

**Author:** ![ianmcmeek](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/ianmcmeek/32/3966_2.png) [@ianmcmeek](https://cl.desmos.com/u/ianmcmeek)\
**Post date:** [December 31, 2022, 5:23pm UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/2 "2022-12-31T17:23:35Z")

</div>

Hello, I really like the activity so far!  
Try changing just line 4 to:  
 ![Screen Shot 2022-12-31 at 10.18.21 AM](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/7/79f5a9e28e88c850200913adc353096aac52bf06.png)

The key change is the part that says ‘for i=[…]’. Here is a [support article](https://help.desmos.com/hc/en-us/articles/4407889068557-Lists) that explains more about how it works in the section called ‘List Comprehension.’ I hope this helps!

---

<div class="post-metadata">

**Author:** ![maryamratna](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/maryamratna/32/4038_2.png) [@maryamratna](https://cl.desmos.com/u/maryamratna)\
**Post date:** [January 1, 2023, 6:52am UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/3 "2023-01-01T06:52:45Z")

</div>

Thank you! It works very well.

[Here’s](https://www.desmos.com/calculator/vwhiylwqcf?lang=id) 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)

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [January 1, 2023, 1:51pm UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/4 "2023-01-01T13:51:33Z")

</div>

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:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/c/cff6962432fd41efb3f86e192f642e6c230eb086.png)  
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:  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/1/18438466d0de38ea6c378046e75bcd6d6a911f42.png)

---

<div class="post-metadata">

**Author:** ![maryamratna](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/maryamratna/32/4038_2.png) [@maryamratna](https://cl.desmos.com/u/maryamratna)\
**Post date:** [January 1, 2023, 3:01pm UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/5 "2023-01-01T15:01:36Z")

</div>

It works perfectly! 😄  
Thank you so much for your guidance!

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [January 1, 2023, 10:34pm UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/6 "2023-01-01T22:34:10Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![maryamratna](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/maryamratna/32/4038_2.png) [@maryamratna](https://cl.desmos.com/u/maryamratna)\
**Post date:** [January 2, 2023, 9:44am UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/7 "2023-01-02T09:44:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [January 2, 2023, 2:15pm UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/8 "2023-01-02T14:15:29Z")

</div>

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:

> **[Desmos | Graphing Calculator](https://www.desmos.com/calculator/v4wukjza72)**
>
> Explore math with our beautiful, free online graphing calculator. Graph functions, plot points, visualize algebraic equations, add sliders, animate graphs, and more.

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

---

<div class="post-metadata">

**Author:** ![maryamratna](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/maryamratna/32/4038_2.png) [@maryamratna](https://cl.desmos.com/u/maryamratna)\
**Post date:** [January 3, 2023, 8:50am UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/9 "2023-01-03T08:50:14Z")

</div>

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](https://www.desmos.com/calculator/rzvhxo0bfz?lang=id).

I have a lot to learn though 😃

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [January 3, 2023, 10:30pm UTC](https://cl.desmos.com/t/adding-and-substracting-polygon-or-image-or-point-using-clickable-action/4633/10 "2023-01-03T22:30:24Z")

</div>

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.
