xxxxxxxxxx
26
var p;
function setup() {
createCanvas(400, 400);
background(220);
noStroke();
for (var i = 0; i < width; i++){
for (var j = 0; j < height; j++){
var c = noise(i * 0.01, j * 0.01);
fill(c * 255);
rect(i, j, 1, 1);
}
}
p = createVector(width/2, height/2);
}
function getFlow(pos){
var angle = noise(pos.x * 0.01, pos.y * 0.01) * TWO_PI;
return p5.Vector.fromAngle(angle);
}
function draw() {
fill(255);
ellipse(p.x, p.y, 1);
var v = getFlow(p);
p.add(v);
}