Use action button to create points

Hello,

I’m brand new to CL (I just learned about it this week). I’m trying to create an action button that adds points to the line y=2x when pressed. I’ve been able to get it to plot random points on that line using the following code:

r = randomGenerator(btn1.pressCount)

number(“c”): r.float(-3,3)

And my graph has the following point:

(c, c*2)

However, every time I press the action button, the old point goes away and a new point appears. I would like the old point to stay and a new point appear. In other words, as I press the button more, the line starts to fill out.

Is this possible?

You can capture the history of the random numbers. Add these things to what you already have:

Graph

numberList("C"): btn1.history("C")

Button

capture("C"): graph.number("c")

Then create a new point in the graphing calculator of (C, 2C).

That worked perfectly! Thank you.

I love how much the computation layer allows you to do. But, its also a lot to learn :slight_smile: