xxxxxxxxxx
41
function setup() {
createCanvas(400, 400);
strokeWeight(2);
}
function draw() {
background(200);
const w = width/3;
const f = 1/50;
let pCosX = 0;
let pSinX = 0;
let cosX = 0;
let sinX = 0;
const offset = int(millis()/10);
for(let i = 0; i < height; i ++) {
pCosX = cosX;
pSinX = sinX;
cosX = cos(PI/6 + (i + offset) * f) * w/2 + width/2;
sinX = sin((i + offset) * f) * w/2 + width/2;
if(i === 0) {
continue;
}
if((i + offset) % 20 === 0) {
stroke(0, 0, 255);
line(sinX, i, cosX, i);
}
stroke(255, 0, 0);
line(cosX, i, pCosX, i - 1);
stroke(0, 255, 0);
line(sinX, i, pSinX, i - 1);
}
}