xxxxxxxxxx
43
let vel = [];
let cols; let rows; let size = 10;
let xoff = 0; let yoff = 0; let zoff = 0; let inc = 0.01;
let particles = [];
function setup() {
createCanvas(400, 400);
cols = width/size;
rows = height/size;
for (let i=0; i<1000; i++){
particles.push(new Particle());
}
background(0);
}
function draw() {
background(0, 10);
yoff = 0;
for (let i=0; i<cols; i++){
xoff=0;
vel[i] = [];
for (let j=0; j<rows; j++){
let angle = noise(xoff, yoff, zoff) * TWO_PI;
vel[i][j] = createVector(cos(angle), sin(angle));
xoff+=inc;
// rect(i*size, j*size, size, size);
// textAlign(CENTER);
// text(round(angle, 2)+" "+round(vel[i][j].x, 2)+" "+round(vel[i][j].y, 2), size/2 + i*size, size/2 + j*size);
}
yoff+=inc;
zoff += 0.0003;
}
for (let i=0; i<particles.length; i++){
particles[i].drawParticle();
particles[i].moveParticle(vel, 10);
}
}