import { Helios } from '@helios-project/core';
import p5 from 'p5';
const helios = new Helios({ fps: 30, duration: 8 });
const sketch = (p: p5) => {
let particles: { x: number; y: number; speed: number }[] = [];
p.setup = () => {
p.createCanvas(window.innerWidth, window.innerHeight);
p.noLoop();
// Initialize particles
for (let i = 0; i < 50; i++) {
particles.push({
x: p.random(p.width),
y: p.random(p.height),
speed: p.random(0.5, 2)
});
}
};
p.draw = () => {
const time = helios.currentTime.value;
p.background(20, 20, 30);
p.noStroke();
// Draw animated particles
particles.forEach((particle, i) => {
const hue = (i * 10 + time * 50) % 360;
p.colorMode(p.HSB);
p.fill(hue, 70, 90);
const x = (particle.x + time * particle.speed * 50) % p.width;
const y = particle.y + p.sin(time + i) * 50;
const size = 20 + p.sin(time * 2 + i) * 10;
p.ellipse(x, y, size);
});
};
p.windowResized = () => {
p.resizeCanvas(window.innerWidth, window.innerHeight);
};
};
const container = document.getElementById('p5-container');
if (container) {
const mySketch = new p5(sketch, container);
helios.bindToDocumentTimeline();
helios.subscribe(() => {
mySketch.redraw();
});
(window as any).helios = helios;
}