xxxxxxxxxx
53
let forces = [];
let cols; let rows; let size = 10;
let xoff = 0; let yoff = 0; let zoff = 0; let inc = 0.1;
let particles = [];
function setup() {
createCanvas(400, 400);
cols = width/size;
rows = height/size;
for (let i=0; i<100; i++){
particles[i] = new Particle();
}
rectMode(CENTER);
background(5);
}
function draw() {
yoff = 0;
for (let i=0; i<rows; i++){
xoff=0;
forces[i] = [];
for (let j=0; j<cols; j++){
let angle = noise(xoff, yoff, zoff) * TWO_PI * 4;
let v = p5.Vector.fromAngle(angle);
forces[i][j] = v;
xoff+=inc;
// stroke(0, 50);
push();
translate(i*size, j*size);
rotate(v.heading());
// strokeWeight(1);
// line(0, 0, size, 0);
pop();
}
yoff+=inc;
zoff+=0.0003;
}
for (let i=0; i<particles.length; i++){
particles[i].follow(forces, cols, rows, size);
particles[i].update();
particles[i].edges();
particles[i].show();
}
}