createCanvas(windowWidth, windowHeight);
colorMode(HSB, 360, 100, 100, 100);
textAlign(CENTER, CENTER);
R = min(width, height) / int(random(5, 15));
s = sqrt((3 * sq(R)) / 4);
for (let y = -s; y < height + s; y += 2 * s) {
for (let x = -s; x < width + R; x += 3 * R) {
hexagons.push(new Hexagon(x, y, R));
hexagons.push(new Hexagon(x + 1.5 * R, y + s, R));
randomSeed(230617 + frameCount / freq);
if (frameCount % freq == 0) {
global_n += int(random(1, 7));
R = min(width, height) / int(random(5, 15));
s = sqrt((3 * sq(R)) / 4);
for (let y = -s; y < height + s; y += 2 * s) {
for (let x = -s; x < width + R; x += 3 * R) {
hexagons.push(new Hexagon(x, y, R));
hexagons.push(new Hexagon(x + 1.5 * R, y + s, R));
for (let h of hexagons) {
shuffle(palette.concat()),
shuffle(palette.concat()),
shuffle(palette.concat()),
int(random(2, this.colors[0].length)),
int(random(2, this.colors[1].length)),
int(random(2, this.colors[2].length)),
this.dir = random() > 0.5 ? -1 : 1;
rotate((int(random(6)) * 360) / 6 + this.t * 60 * this.dir);
for (let angle = 0; angle < 360; angle += 360 / 3) {
let sclStep = 1 / int(random(2, 8));
for (let scl = 1; scl > 0; scl -= sclStep) {
fill(this.colors[n][m++ % this.limit[n]]);
angle + 180 + this.t * 360,
angle + 300 + this.t * 360,
this.t = this.getTime(global_n % 7);
this.t += (1 / freq) * (frameCount % freq) * 3;
this.t = constrain(abs(this.t - 1.5), 0, 1);
this.t = easeInOutCirc(1 - this.t);
this.draw(this.x, this.y, this.r);
dist(this.x, this.y, width / 2, height / 2) /
sqrt(sq(width) + sq(height));
n = (this.x + this.y * width * 2) / (width * height);
n = dist(mouseX, mouseY, this.x, this.y) / sqrt(sq(width) + sq(height));
return dist(mouseX, mouseY, this.x, this.y);
function easeInOutCirc(x) {
? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2
: (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2;
function easeInOutElastic(x) {
const c5 = (2 * Math.PI) / 4.5;
? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2
: (Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5)) / 2 + 1;
function windowResized() {
resizeCanvas(windowWidth, windowHeight);