xxxxxxxxxx
33
// Start of line
let sx, sy;
// Where line is now
let x, y;
function setup() {
createCanvas(windowWidth, windowHeight);
// Start and end line at same point
sx = 0.05*width;
sy = 0;
x = sx;
y = sy;
}
function draw() {
background(255);
// Restart the line
if(x > width) {
x = sx;
y = sy;
}
// Move endpoint of line
x += 0.1;
y += 0.05;
// Draw the line
strokeWeight(5);
line(sx, sy, x, y);
}