xxxxxxxxxx
57
var inc = 0.1;
var scl = 10;
var cols, rows;
var zoff = 0;
var particles = [];
var flowfield;
function setup() {
createCanvas(1200, 800);
colorMode(HSB, 360, 100, 100, 100);
// background(360, 0, 100, 100);
// background(360, 0, 0);
background(color(354, 91, 4));
cols = floor(width / scl);
rows = floor(height / scl);
flowfield = new Array(cols * rows);
for (var i = 0; i < 1100; i++) {
particles[i] = new Particle();
}
// background(0, 0, 0);
// createLoop({ duration: 8, gif: true });
}
function draw() {
var yoff = 0;
for (var y = 0; y < rows; y++) {
var xoff = 0;
for (var x = 0; x < cols; x++) {
var index = x + y * cols;
var angle = noise(xoff, yoff, zoff) * TWO_PI * 4;
var v = p5.Vector.fromAngle(angle);
v.setMag(1);
flowfield[index] = v;
xoff += inc;
}
yoff += inc;
zoff += 0.0003;
}
for (var i = 0; i < particles.length; i++) {
particles[i].follow(flowfield);
particles[i].update();
particles[i].edges();
particles[i].show();
}
}
// function mousePressed() {
// save("petlja.jpg");
// }