For this project, I wanted to test the variability of how string art can generate, so I made a random string generator that creates what eventually looks like TV static. Press down the mouse to generate more and more strings until the screen is completely covered!
csavitz_4
//Cole Savitz-Vogel
//csavitzv
//Section A
var x1;
var y1;
var x2;
var y2;
var x3;
var y3;
var x4;
var y4;
var x5;
var y5;
var x6;
var y6;
function setup() {
createCanvas(500, 500);
background(0);
}
function draw() {
if (mouseIsPressed){
strokeWeight(.5);
web();
push();
translate(random(0,500),random(0,500));
web();
pop();
push();
translate(random(0,500),random(0,500));
web();
pop();
push();
}
}
function web() {
x3 = random(1, 500);
y3 = random(1, 500);
x4 = random(1, 500);
y4 = random(1, 500);
x5 = random(1, 500);
y5 = random(1, 500);
x6 = random(1, 500);
y6 = random(1, 500);
x1 = x3;
y1 = y3;
x2 = x5;
y2 = y5;
line(x3, y3, x4, y4);
line(x5, y5, x6, y6);
strokeWeight(0.5);
for (var i = 0; i < 51; i+=1) {
var xdelta1 = (x4 - x3);
var ydelta1 = (y4 - y3);
var xdelta2 = (x5 - x6);
var ydelta2 = (y5 - y6);
noFill();
stroke(random(i,200), random(i,200), random(i,200));
arc(x1, y1, x2, y2, random(0,3), random(0,3));
x1 += xdelta1;
y1 += ydelta1;
x2 += xdelta2;
y2 += ydelta2;
}
}