viewof ej_15minute_canvas = {
let alpha = 0.5;
const q5 = new Q5();
q5.createCanvas(width, height);
q5.randomSeed();
const el = html`${q5.canvas}`;
el.value = q5;
yield el;
q5.noStroke();
invalidation.then(() => q5.clear());
let x = width / 2;
let y = height / 2;
let px = x;
let py = y;
let circles = [];
const addCircle = function(i) {
circles.push({
x: chance.floating({ min: 50, max: width - 50 }),
y: height / 4 + chance.floating({ min: 0, max: height / 2 }),
fill: chance.pick(colors),
r: circleRadius * (i * 0.001)
});
};
for (let c = 0; c < 1200; c++) {
addCircle(c);
}
const simulation = d3
.forceSimulation(circles)
.force("charge", d3.forceManyBody().strength(-0.1));
while (true) {
q5.fill("rgba(255,255,255, 0.05)");
q5.rect(0, 0, width, height);
let now = moment(new Date());
let diffSeconds = moment(userdl).diff(now, "seconds");
let diffMinutes = moment(userdl).diff(now, "minutes");
let diffSecondHand = d3.max([0, diffSeconds - diffMinutes * 60]);
circles = circles.slice(0, +diffSeconds);
for (let i = 0; i < circles.length; i++) {
q5.fill(circles[i].fill);
q5.circle(circles[i].x, circles[i].y, circles[i].r);
if (chance.bool({ likelihood: i * 0.01 })) {
circles[i].x += chance.floating({
min: -circleStepMax,
max: circleStepMax
});
}
if (chance.bool()) {
circles[i].y += chance.floating({
min: -circleStepMax,
max: circleStepMax * 1.5
});
}
if (circles[i].y > height) {
circles[i].y -= circleRadius * 1.5;
}
if (circles[i].x > width) {
circles[i].x = 0;
}
}
q5.textSize(220);
q5.textSize(48);
yield el;
}
}