xxxxxxxxxx
52
function setup() {
createCanvas(600, 200);
barra = createSlider(2,500,5)
}
let temps = 0;
let wave = [];
let path = [];
function draw() {
background(255);
translate(150,100)
let x = 0
let y = 0
for (let i=1; i<barra.value();i++) {
let antx = x
let anty = y
let n = i
let radi = 100*2*7/22*(-1)**(n+1)/(n)
x += radi * cos(n * temps)
y += radi * sin(n * temps)
stroke(100)
noFill()
ellipse(antx,anty,2*radi)
//
stroke(200)
line(antx,anty,x,y)
}
wave.unshift(y);
translate(200, 0);
line(x - 200, y, 0, wave[0]);
beginShape();
noFill();
for (let i = 0; i < wave.length; i++) {
vertex(i, wave[i]);
}
endShape();
temps += 0.05;
}