const frameRateNumber = 60 const cycleLenght = 600 let pointArray1 let pointArray2 function setup() { createCanvas(windowWidth, windowHeight); frameRate(frameRateNumber) } function draw() { const currentCyclePos = frameCount % cycleLenght switch (true) { case (currentCyclePos === 1): pointArray1 = [] //pointArrStart = [{x:1, y: 1},{}]; background(255) strokeWeight(10) x1 = windowWidth / 2 y1 = windowHeight x2 = windowWidth / 2 y2 = windowHeight * 3 / 4 pointArray1.push({x: x1, y: y1}) pointArray1.push({x: x2, y: y2}) console.log(pointArray1) line(x1, y1, x2, y2) break case (currentCyclePos < cycleLenght * 3 / 4): const lastPoint = pointArray1[pointArray1.length-1] console.log(lastPoint) x1 = lastPoint.x y1 = lastPoint.y x2 = y1 = console.log(x1 + " " + y1) break default: background(255) break } }