/* Inspired by Frieder Nake's Zufälliger Polygonzug – 13/9/65 Nr. 7 (Random Polygon (1965) and A. Michael Noll's Gaussian-Quadratic (1963) */ let startX; let startY; let endX; let endY; let num = 0; let total = 40; function setup() { createCanvas(windowWidth, windowHeight); background(0); stroke(255); strokeWeight(2); getStartPoint(); getEndPoint(); } function draw() { while (num < total) { line(startX, startY, endX, endY); startX = endX; startY = endY; getEndPoint(); num++; } } function getStartPoint() { startX = random(10, width - 10); startY = random(10, height - 10); } function getEndPoint() { endX = random(10, width - 10); endY = random(10, height - 10); } /* ------------↓↓ My comment here ↓↓----------*/ /* Inspired by Frieder Nake's Zufälliger Polygonzug – 13/9/65 Nr. 7 (Random Polygon (1965) and A. Michael Noll's Gaussian-Quadratic (1963) */ let startX; let startY; let endX; let endY; let num = 0; let total = 40; function setup() { createCanvas(windowWidth, windowHeight); background(0); stroke(255); strokeWeight(2); //black background white stroke getStartPoint(); getEndPoint(); //call these two function } function getStartPoint() { startX = random(10, width - 10); startY = random(10, height - 10); //decide the start point //keep 10px away from the edge of the canvas } function getEndPoint() { endX = random(10, width - 10); endY = random(10, height - 10); //also decide the end point } function draw() { //end the loop when number no longer smaller than total while (num < total) { line(startX, startY, endX, endY); console.log("BEFORE:"+startX,endX); startX = endX; startY = endY; console.log("AFTER:"+startX,endX) getEndPoint(); //get a new end point by call the getEndPoint function again num++; } } /* !!!!!!!!!!!↓↓ Modify ↓↓!!!!!!!!!!!!*/ /* Inspired by Frieder Nake's Zufälliger Polygonzug – 13/9/65 Nr. 7 (Random Polygon (1965) and A. Michael Noll's Gaussian-Quadratic (1963) */ let startX; let startY; let endX; let endY; let num = 0; let total = 40; function setup() { createCanvas(windowWidth, windowHeight); getStartPoint(); getEndPoint(); //call these two function } function getStartPoint() { startX = random(10, width - 10); startY = random(10, height - 10); //decide the start point //keep 10px away from the edge of the canvas } function getEndPoint() { endX = random(10, width - 10); endY = random(10, height - 10); //also decide the end point } function draw() { background(0,80); //black background white stroke //end the loop when number no longer smaller than total for (let num=0; num < total;num++) { background(0,1); stroke(map(noise(num/40),0,1,150,200), map(noise(num/40),0,1,0,50), map(noise(num/40),0,1,30,150), 160); strokeWeight(map(noise(num/20),0,1,0.1,30)); line(startX, startY, endX, endY); // console.log("BEFORE:"+startX,endX); startX = endX; startY = endY; // console.log("AFTER:"+startX,endX) getEndPoint(); //get a new end point by call the getEndPoint function again } noLoop(); } function mousePressed() { loop(); }