xxxxxxxxxx
154
let i = 0;
let j = 0;
function setup() {
createCanvas(900, 900);
center = createVector(width / 2, height / 2);
cols = ["#9b5de5","#c65ccd","#f15bb5","#f8a07b","#fee440","#00bbf9","#00caf0","#00d8e7","#00e7de","#00f5d4"];
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 + 1), (height / 4) * (i + 1), 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 = 1000;
this.c = floor(this.index);
this.oc = this.c;
this.col = color(cols[this.c % cols.length]);
}
update(){
while(this.c == this.oc){}
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.sp.setMag(map(this.dist.mag(), 0, width * 2, 1, 20));
// this.con.y = this.con.y + 1;
// noiseSeed(1);
this.arm.setMag(this.arm.mag() + 1);
this.arm.setHeading(this.arm.heading() - 0.015);
// 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.sp.setHeading(this.sp.heading() + random(TWO_PI / 6));
this.pt2 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + random(TWO_PI / 6));
this.pt3 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + random(TWO_PI / 6));
this.pt4 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + random(TWO_PI / 6));
this.pt5 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + random(TWO_PI / 6));
this.pt6 = p5.Vector.add(this.a1, this.sp);
this.sp.setHeading(this.sp.heading() + random(TWO_PI / 6));
// 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.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);
}
if(this.v1 == 0 && this.v2 == 0 && this.v3 == 0 && this.v4 == 0 && this.v5 == 0 && this.v6 == 0 && this.chance > 0.2 && random(1) > 0.75){
// 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);
}
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.051);
this.c = this.c + 1;
this.col = color(cols[this.c % cols.length]);
this.timer = 0;
}
// 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;
// }
}
}
}