Hi,
I was trying to create a slider controlled random distribution of points in a sketch. I wrote the code as shown below. Although it changes the number of random points when I update the slider value, it continuously produce new points and update position. I know it is happening because I kept the for loop inside the draw() function. How can I create only one collection of random point positions so that the points wont looks like they are flickering around .?
`import controlP5.*;
ControlP5 mycp5;
int number;
void setup() {
size(600, 600);
mycp5 = new ControlP5(this);
mycp5.addSlider("number")
.setPosition(300, 300)
.setSize(100, 20)
.setRange(0, 20)
.setValue(1)
;
}
void draw() {
background(250);
for (int i =0; i<number; i++) {
fill(200, 0, 0);
ellipse(random(10, 200)+i*2, random(0, 200)+i*10, 10, 10);
}
}
`