I am trying to build an activity for my students to start to visualize the pattern x^2. I wanted a slider where students could see one block when the slider was at n=1, and then they could move it over to n=2 and see 4 blocks, n=3 and see 9 blocks, etc.

Is there a way to have a slider attached to specific polygons appearing, rather than just attached to a graph?

I’ve made an activity like this. I did it using list comprehensions to generate sets of polygons, which is what you are probably looking for. Take a look and let me know if you have questions about it.

I have two versions. The first one was made for my Math 1 students so the interface is more scaffolded. The second one was adapted for my Math 2 students, and it only has quadratic patterns. In either case, the template is fairly easy to modify to make new problems once you understand how the list comprehensions work.