xxxxxxxxxx
57
function setup() {
createCanvas(900, 900);
count = 250;
layers = 30;
layerWidth = 20;
angle = TWO_PI / count;
center = createVector(width / 2, height / 2);
rads = [];
cols = ["#001219","#005f73","#0a9396","#94d2bd","#e9d8a6","#ee9b00","#ca6702","#bb3e03","#ae2012","#9b2226"];
for(i = 0; i < count; i++){
rads[rads.length] = new Rad(i * angle);
}
}
function draw() {
background(30);
center = createVector(noise(frameCount * 0.0001) * width, noise((frameCount + 1000) * 0.001) * height)
for(i = 0; i < rads.length; i++){
rads[i].update();
}
}
class Rad{
constructor(angle){
this.pos = [];
this.sp = createVector(10, 0)
this.sp.setHeading(angle);
this.pos[0] = p5.Vector.add(center, this.sp);
this.i = 0;
this.col = color(cols[0]);
for(this.i = 0; this.i < layers; this.i++){
this.pos[this.i] = createVector(0, 0);
}
}
update(){
// this.sp.setHeading(this.sp.heading() + 0.001);
for(this.i = 0; this.i < layers; this.i++){
this.col = color(cols[this.i % cols.length])
stroke(this.col);
strokeWeight(this.i * 0.75 + 1)
this.sp.setMag(layerWidth * this.i + noise(sin(this.sp.heading() + frameCount * 0.001), this.pos[this.i].x * 0.01 + frameCount * 0.01, this.pos[this.i].y * 0.01 + frameCount * 0.01) * 100);
this.pos[this.i] = p5.Vector.add(this.sp, center);
if(this.i > 0){
line(this.pos[this.i].x, this.pos[this.i].y, this.pos[this.i - 1].x, this.pos[this.i - 1].y);
} else {
line(this.pos[this.i].x, this.pos[this.i].y, center.x, center.y);
}
// point(this.pos[this.i].x, this.pos[this.i].y);
}
}
}