xxxxxxxxxx
26
const W = 800, H = 800, S = 16, arrLength = 3;
let P, arr = [], buttonStep;
function setup() {
createCanvas(W, H);
for(let i = 0; i < arrLength; i++){
arr[i] = [floor(random(width)), floor(random(height))];
}P = [width/2, height/2];
//buttonStep = createButton("Step");
//buttonStep.mousePressed(step);
background(150);
fill(255); stroke(255);
arr.forEach(x => ellipse(x[0], x[1], S*width/600, S*height/600));
fill(0); stroke(0); strokeWeight(0.1);
}
function draw() {
ellipse(P[0], P[1], width/600, height/600);
step(1,1,1,1);
}
function step(a,b,c,d){
let r = arr[floor(random(arrLength))];
P = [(a*P[0]+b*r[0])/(a+b),(c*P[1]+d*r[1])/(c+d)];
}