void setup() { size(600, 600); background(255); stroke(0); strokeWeight(2); noFill(); generateContinuousLine(); } void draw() { // Static image - no need to update continuously } // Function to generate the continuous line that covers the canvas void generateContinuousLine() { float x = 0; float y = 0; float stepSize = 40; // Step length for each move int cols = int(width / stepSize); // Explicit cast to int int rows = int(height / stepSize); // Explicit cast to int beginShape(); vertex(x, y); boolean directionRight = true; // Controls zigzag movement for (int j = 0; j < rows; j++) { for (int i = 0; i < cols; i++) { if (directionRight) { x += stepSize; } else { x -= stepSize; } x = constrain(x, 0, width); // Ensure the line stays within bounds // Occasionally make a triangular detour if (random(1) > 0.7) { float angle = random(-PI / 3, PI / 3); float detourX = x + cos(angle) * stepSize; float detourY = y + sin(angle) * stepSize; vertex(detourX, detourY); // Extra point for triangle effect } vertex(x, y); } y += stepSize; // Move down a row directionRight = !directionRight; // Flip movement direction } endShape(); }