I'm working on a music visualization and draw a curveVertex based on the songs amplitude. Therefore I'm using the p5.js sound library.
When the vertex hits the right end of the canvas, I want to force a line break but keep the lines above as single shapes. My current version only moves the whole vertex shape in the next line. Where is my thinking error?
const lineHeight = 30;
const paddingTop = lineHeight;
let currentLine = 1;
function draw() {
background(0);
amplitudeHistory.push(amplitude.getLevel());
stroke(255);
noFill();
beginShape();
for(let i = 0; i < amplitudeHistory.length; i++) {
let y = map(amplitudeHistory[i], 0, 1, lineHeight + (paddingTop * currentLine) , lineHeight * (-1) + (paddingTop * currentLine));
curveVertex(i, y);
}
endShape();
if(amplitudeHistory.length > width * currentLine) {
currentLine++;
}
}