xxxxxxxxxx
56
/*
Inspired by Frieder Nake's Zufälliger Polygonzug – 13/9/65 Nr. 7 (Random Polygon (1965) and A. Michael Noll's Gaussian-Quadratic (1963)
*/
//define initial variables
let startX;
let startY;
let endX;
let endY;
let num = 0;
let total = 40;
//setup function init
function setup() {
//canvassize set to match window size
createCanvas(windowWidth, windowHeight);
//set background to black
background(0);
//set outline to white
stroke(255);
//set outline width to 2
strokeWeight(2);
//call functions for getting starting and ending points of line
getStartPoint();
getEndPoint();
}
//init draw loop
function draw() {
//init while loop. runs until num reaches total.
while (num < total) {
//create line with vars
line(startX, startY, endX, endY);
//change start points to the previous end points
startX = endX;
startY = endY;
//function to find new end points
getEndPoint();
//add 1 to num
num++;
}
}
//init find start point function
function getStartPoint() {
//set start x to random between 10 and end of canvas - 10
startX = random(10, width - 10);
//set start y to random between 10 and end of canvas - 10
startY = random(10, height - 10);
}
//init find end point function
function getEndPoint() {
//set end x to random between 10 and end of canvas - 10
endX = random(10, width - 10);
//set end y to random between 10 and end of canvas - 10
endY = random(10, height - 10);
}