xxxxxxxxxx
const noiseScale = 0.001;
const noiseSpeed = 0 //0.05;
let walkers = [];
let colours = [
'#FF00E4',
'#ED50F1',
'#FDB9FC',
'#FF008E'
]
function setup() {
createCanvas(windowWidth, windowHeight);
background('#FFEDED');
noStroke()
// noLoop()
createWalkers()
}
function createWalkers() {
for (let i = 0; i < 500; i++) {
const walker = {
pos: createVector(random(0, windowWidth), random(0, windowHeight)),
// const frac = map(n, 0.2, 0.8, 0, 1, true);
// fill(lerpColor(c1, c2, frac));
size: map(random(20,50), 30, 40, 3, 30, true),
colour: random(colours)
}
walkers.push(walker)
}
}
function draw() {
// background(5, 7)
manageWalkers(walkers)
}
function manageWalkers(wArr) {
for (let walker of wArr) {
drawWalker(walker)
moveWalker(walker)
}
}
function drawWalker(w) {
fill(w.colour)
circle(w.pos.x, w.pos.y, w.size)
}
function moveWalker(w) {
// Calc noise angle at walker's x and y
const angle = calculateAngle(w.pos.x, w.pos.y)
// move walker some distance in that angle
const vel = p5.Vector.fromAngle(angle, 1)
w.pos.add(vel)
// w.pos.x += vel.x
// w.pos.y += vel.y
}
function drawArrow(x, y, angle) {
push()
translate(x, y)
rotate(angle)
stroke(255)
line(-10, 0, 10, 0)
fill(255)
circle(10, 0, 5)
pop()
}
function calculateAngle(x, y) {
return noise(x * noiseScale, y * noiseScale, frameCount * noiseSpeed) * TWO_PI * 3
}