xxxxxxxxxx
49
let positions = [];
let colors = [];
let col = 0;
let lerp = 0.05;
function setup() {
createCanvas(400, 400);
noStroke();
// positions.push(createVector(width/3, height/2))
// positions.push(createVector(100,20))
}
function draw() {
colorMode(RGB)
background(220);
colorMode(HSB)
col++;
// draw
for (let i = 0; i < positions.length; i++) {
fill(colors[i] , 250, 250);
// col++;
circle(positions[i].x, positions[i].y, 15)
}
if (mouseIsPressed) {
colors.push(col % 255)
positions.push(createVector(mouseX,mouseY))
}
if (col > 255) col = 1;
const mouse = createVector(mouseX, mouseY);
if (keyIsPressed) {
for (let i = 0; i < positions.length; i++) {
positions[i].lerp(mouse, lerp)
}
lerp += 0.05
if (lerp > 1) {
lerp = 0;
}
}
}