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 = 100;
//setup function init
function setup() {
//canvassize set to match window size
createCanvas(windowWidth, windowHeight);
//set background to black
background(255);
//set outline to white
stroke(0);
//set outline width to 2
strokeWeight(5);
//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 + 25;
startY = endY - 20;
//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(50, width - 50);
//set start y to random between 10 and end of canvas - 10
startY = random(50, height - 50);
}
//init find end point function
function getEndPoint() {
//set end x to random between 10 and end of canvas - 10
endX = random(50, width - 50);
//set end y to random between 10 and end of canvas - 10
endY = random(50, height - 50);
}