xxxxxxxxxx
269
let i = 0;
let j = 0;
function setup() {
createCanvas(900, 900);
center = createVector(width / 2, height / 2);
cols = ["#8ecae6","#57afd2","#219ebc","#1f6a92","#023047","#ffb703","#ff9d00","#fb8500","#ff6f00","#fb5f0a"];
d = pixelDensity();
curves = [];
count = 1;
ch = height / count;
r1 = random(100, 200);
r2 = random(100, 200);
r3 = random(100, 200);
r4 = random(100, 200);
r5 = random(100, 200);
r6 = random(100, 200);
r7 = random(100, 200);
r8 = random(100, 200);
for(i = 0; i < count; i++){
curves[i] = new Curve((width / 4) * (i + 2), (height / 4) * (i + 2), curves.length);
}
noFill();
strokeWeight(1);
background(0);
}
function draw() {
loadPixels();
for(j = 0; j < curves.length; j++){
curves[j].update();
}
}
class Curve {
constructor(x, y, index){
this.index = index;
this.center = createVector(x, y);
this.a1 = createVector(width / 2, height / 2);
this.arm = createVector(1, 0);
this.start = createVector(1, 0);
this.a2 = createVector(width / 2, y * index * ch + ch);
this.con = createVector(width / 2, y * index * ch + ch / 2 - height);
this.sp = createVector(100, 0);
this.dist = p5.Vector.sub(this.a1, center);
this.chance = 0;
this.check = 0;
this.test = 50;
this.c2 = createVector(0, 0);
this.rate = index;
this.pt1 = createVector(0, 0);
this.pt2 = createVector(0, 0);
this.pt3 = createVector(0, 0);
this.pt4 = createVector(0, 0);
this.pt5 = createVector(0, 0);
this.pt6 = createVector(0, 0);
this.s1 = 0;
this.s1 = 0;
this.s1 = 0;
this.s1 = 0;
this.s1 = 0;
this.s1 = 0;
this.timer = 0;
this.tover = 900;
this.sight = 0;
this.fail = false;
this.size = 0;
this.c1 = floor(this.index);
this.c2 = (this.c1 + 1) % cols.length;
this.oc = this.c;
this.col = color(cols[this.c1 % cols.length]);
}
update(){
this.c2 = (this.c1 + 1) % cols.length;
this.col = lerpColor(color(cols[this.c1]), color(cols[this.c2]), map(this.timer, 0, this.tover, 0, 1));
// this.col = color(255);
stroke(this.col);
fill(this.col);
this.a1 = p5.Vector.add(this.center, this.arm);
this.dist = p5.Vector.sub(this.a1, this.center);
this.size = map(sin(this.dist.mag() * 0.1), -1, 1, 1, 10)
this.sp.setMag(this.size);
// this.con.y = this.con.y + 1;
// noiseSeed(1);
this.arm.setMag(this.arm.mag() + 1);
this.arm.setHeading(this.arm.heading() + sin(this.dist.mag() * 0.001) * 0.02);
// this.a1 = createVector(width / 2, height / 2);
this.sp.setHeading(random(TWO_PI));
// this.sp.setMag((sin(this.con.y * 0.001 + this.index) + 1) * 50);
this.pt1 = p5.Vector.add(this.a1, this.sp);
this.sight = this.size;
if(this.pt1.x >= 0 && this.pt1.x <= width && this.pt1.y >= 0 && this.pt1.y <= height){
while(this.sight > 0){
this.pt1 = p5.Vector.add(this.a1, this.sp);
this.s1 = 4 * (d * floor(this.pt1.y)) * (d * width) + 4 * (d * floor(this.pt1.x));
this.v1 = pixels[this.s1];
if(this.v1 == 0){
this.sp.setMag(this.sp.mag() - 1);
this.sight = this.sight - 1;
} else{
this.sight = 0;
this.fail = true;
}
}
}
this.sp.setMag(this.size);
this.pt1 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + TWO_PI / 3);
this.pt2 = p5.Vector.add(this.a1, this.sp);
this.sight = this.size;
if(this.pt2.x >= 0 && this.pt2.x <= width && this.pt2.y >= 0 && this.pt2.y <= height){
while(this.sight > 0){
this.pt2 = p5.Vector.add(this.a1, this.sp);
this.s1 = 4 * (d * floor(this.pt2.y)) * (d * width) + 4 * (d * floor(this.pt2.x));
this.v1 = pixels[this.s1];
if(this.v1 == 0){
this.sp.setMag(this.sp.mag() - 1);
this.sight = this.sight - 1;
} else{
this.sight = 0;
this.fail = true;
}
}
}
this.sp.setMag(this.size);
this.pt2 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + TWO_PI / 3);
this.pt3 = p5.Vector.add(this.a1, this.sp);
this.sight = this.size;
if(this.pt3.x >= 0 && this.pt3.x <= width && this.pt3.y >= 0 && this.pt3.y <= height){
while(this.sight > 0){
this.pt3 = p5.Vector.add(this.a1, this.sp);
this.s1 = 4 * (d * floor(this.pt3.y)) * (d * width) + 4 * (d * floor(this.pt3.x));
this.v1 = pixels[this.s1];
if(this.v1 == 0){
this.sp.setMag(this.sp.mag() - 1);
this.sight = this.sight - 1;
} else{
this.sight = 0;
this.fail = true;
}
}
}
this.sp.setMag(this.size);
this.pt3 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + TWO_PI / 3);
this.pt4 = p5.Vector.add(this.a1, this.sp);
this.sight = this.size;
if(this.pt4.x >= 0 && this.pt4.x <= width && this.pt4.y >= 0 && this.pt4.y <= height){
while(this.sight > 0){
this.pt4 = p5.Vector.add(this.a1, this.sp);
this.s1 = 4 * (d * floor(this.pt4.y)) * (d * width) + 4 * (d * floor(this.pt4.x));
this.v1 = pixels[this.s1];
if(this.v1 == 0){
this.sp.setMag(this.sp.mag() - 1);
this.sight = this.sight - 1;
} else{
this.sight = 0;
this.fail = true;
}
}
}
this.sp.setMag(this.size);
this.pt4 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + TWO_PI / 3);
this.pt5 = p5.Vector.add(this.a1, this.sp);
this.sight = this.size;
if(this.pt5.x >= 0 && this.pt5.x <= width && this.pt5.y >= 0 && this.pt5.y <= height){
while(this.sight > 0){
this.pt5 = p5.Vector.add(this.a1, this.sp);
this.s1 = 4 * (d * floor(this.pt5.y)) * (d * width) + 4 * (d * floor(this.pt5.x));
this.v1 = pixels[this.s1];
if(this.v1 == 0){
this.sp.setMag(this.sp.mag() - 1);
this.sight = this.sight - 1;
} else{
this.sight = 0;
this.fail = true;
}
}
}
this.sp.setMag(this.size);
this.pt5 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + TWO_PI / 3);
this.pt6 = p5.Vector.add(this.a1, this.sp);
this.sight = this.size;
if(this.pt6.x >= 0 && this.pt6.x <= width && this.pt6.y >= 0 && this.pt6.y <= height){
while(this.sight > 0){
this.pt6 = p5.Vector.add(this.a1, this.sp);
this.s1 = 4 * (d * floor(this.pt6.y)) * (d * width) + 4 * (d * floor(this.pt6.x));
this.v1 = pixels[this.s1];
if(this.v1 == 0){
this.sp.setMag(this.sp.mag() - 1);
this.sight = this.sight - 1;
} else{
this.sight = 0;
this.fail = true;
}
}
}
this.sp.setMag(this.size);
this.pt6 = p5.Vector.add(this.a1, this.sp);
// this.rate = this.rate - 1;
// this.rate = this.rate % 50;
// this.s1 = 4 * (d * floor(this.pt1.y)) * (d * width) + 4 * (d * floor(this.pt1.x));
// this.v1 = pixels[this.s1];
// this.s2 = 4 * (d * floor(this.pt2.y)) * (d * width) + 4 * (d * floor(this.pt2.x));
// this.v2 = pixels[this.s2];
// this.s3 = 4 * (d * floor(this.pt3.y)) * (d * width) + 4 * (d * floor(this.pt3.x));
// this.v3 = pixels[this.s3];
// this.s4 = 4 * (d * floor(this.pt4.y)) * (d * width) + 4 * (d * floor(this.pt4.x));
// this.v4 = pixels[this.s4];
// this.s5 = 4 * (d * floor(this.pt5.y)) * (d * width) + 4 * (d * floor(this.pt5.x));
// this.v5 = pixels[this.s5];
// this.s6 = 4 * (d * floor(this.pt6.y)) * (d * width) + 4 * (d * floor(this.pt6.x));
// this.v6 = pixels[this.s6];
// this.s7 = 4 * (d * floor(this.a1.y)) * (d * width) + 4 * (d * floor(this.a1.x));
// this.v7 = pixels[this.s7];
// this.chance = map(this.dist.mag(), 0, width + height, 0, 600);
// if(this.timer % this.test == true){
// this.test = this.timer + floor(random(50) + 50);
// this.chance = random(1);
// }
// print(this.fail);
if(this.fail == false && random(1) > 0){
// this.c = floor(random(cols.length));
// this.col = color(cols[this.c % cols.length]);
beginShape();
vertex(this.pt1.x, this.pt1.y);
vertex(this.pt2.x, this.pt2.y);
vertex(this.pt3.x, this.pt3.y);
vertex(this.pt4.x, this.pt4.y);
vertex(this.pt5.x, this.pt5.y);
vertex(this.pt6.x, this.pt6.y);
endShape(CLOSE);
// circle(this.a1.x, this.a1.y, this.sp.mag() / 2)
this.fail = false;
}
this.timer = this.timer + 1;
if(this.timer > this.tover){
this.arm.setMag(1);
this.arm.setHeading(this.start.heading());
this.start.setHeading(this.start.heading() + (TWO_PI / cols.length) + 0.11111);
this.c1 = (this.c1 + 1) % cols.length;
this.col = color(cols[this.c1 % cols.length]);
this.timer = 0;
}
this.fail = false;
// bezier(this.a1.x, this.a1.y, this.c1.x, this.c1.y, this.c2.x, this.c2.y, this.a2.x, this.a2.y);
// bezier(this.a1.x, this.a1.y, this.c1.x + width / 2, this.c1.y, this.c2.x + width / 2, this.c2.y, this.a2.x, this.a2.y);
// circle(this.a1.x, this.a1.y, sin(this.con.y * 0.0023169 + this.index * 0.15) * 100)
// bezier(this.a3.x, this.a3.y, this.c1.x, this.c1.y, this.c2.x, this.c2.y, this.a4.x, this.a4.y);
// if(this.con.y - ch / 2 > height){
// this.con.y = 0 - ch / 2;
// }
this.oc = this.c1;
}
}