xxxxxxxxxx
77
let stripes = [];
let lifeLength;
let dir;
function setup() {
createCanvas(windowWidth, windowHeight);
lifeLength = random(50);
for (let i = 0; i < 2; i++) {
stripes.push(new Stripe());
}
dir = random(.9, 1.1);
}
function draw() {
background(250);
for (let i = 0; i < stripes.length; i++) {
stripes[i].update();
}
lifeLength--;
if (lifeLength < 0) {
lifeLength = random(30);
//stripes = [];
if (stripes.length < 150) {
for (let i = 0; i < 3; i++) {
stripes.push(new Stripe());
}
}
dir = random(.99, 1.01);
}
}
class Stripe {
constructor() {
this.x1 = random(width);
this.y1 = random(height);
this.offsetAmt = 20;
this.x2 = this.x1 + random(-this.offsetAmt, this.offsetAmt);
this.y2 = this.y1 + random(-this.offsetAmt, this.offsetAmt);
this.sw = random(0, 3);
}
update() {
fill(30);
strokeWeight(floor(this.sw));
ellipse(this.x1, this.y1, 2, 2);
line(this.x1, this.y1, this.x2, this.y2);
// this.x2 *=random(.99,1.1);
this.x2 *= dir;
//spiderweb strings
this.y2 *= dir/2;
//this.y2 *=.4;
}
}