xxxxxxxxxx
var field = [];
var particles = new Array(1000);
var sca = 20;
var cols, rows;
var zoff = 0;
function setup(){
createCanvas(400, 400, P2D);
pixelDensity(1);
background(30);
colorMode(HSB, 255);
cols = width/sca;
rows = height/sca;
field = [];
for(var i = 0; i < particles.length; i++){
var x = random(0, width);
var y = random(0, height);
particles[i] = new Particle(createVector(x, y), createVector(0, 0), createVector(0, 0));
}
}
function draw(){
field = [];
for(var i = 0; i < cols + 1; i++){
field[i] = [];
for(var j = 0; j < rows + 1; j++){
field[i][j] = p5.Vector.fromAngle(map(noise(i/10, j/10, zoff), 0, 1, 0, TWO_PI*2));
}
}
zoff += 0.005;
for(var part of particles){
part.show();
part.addForce(field);
part.update();
}
}