This commit is contained in:
Jip Fr 2023-12-14 21:54:05 +01:00
parent b00c89906e
commit 8e0f385024
2 changed files with 23 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

View File

@ -142,30 +142,44 @@ function ParticlesCanvas() {
let imageParticleCount = particleCount; let imageParticleCount = particleCount;
// Holiday overrides // Holiday overrides
let imageOverride; let imageOverride: { image: string; sizeRange?: [number, number] }[] = [];
let sizeRange;
const date = new Date(); const date = new Date();
const month = date.getMonth(); const month = date.getMonth();
const day = date.getDate(); const day = date.getDate();
if (month === 11 && day >= 24 && day <= 26) { if (month === 11 && day >= 12 && day <= 26) {
imageOverride = "/lightbar-images/snowflake.svg"; imageOverride = [
sizeRange = [4, 15] as [number, number]; {
image: "/lightbar-images/snowflake.svg",
sizeRange: [4, 15] as [number, number],
},
{
image: "/lightbar-images/santa.png",
sizeRange: [15, 30] as [number, number],
},
];
} }
// Fish easter egg // Fish easter egg
const shouldShowFishie = Math.floor(Math.random() * 600) === 1; const shouldShowFishie = Math.floor(Math.random() * 600) === 1;
if (shouldShowFishie) { if (shouldShowFishie) {
imageOverride = "/lightbar-images/fishie.png"; imageOverride = [
{
image: "/lightbar-images/fishie.png",
sizeRange: [10, 11] as [number, number],
},
];
imageParticleCount = particleCount / 2; imageParticleCount = particleCount / 2;
sizeRange = [10, 11] as [number, number];
} }
// HOIST THE SAIL (of particles)! // HOIST THE SAIL (of particles)!
for (let i = 0; i < particleCount; i += 1) { for (let i = 0; i < particleCount; i += 1) {
const isImageParticle = imageOverride && i <= imageParticleCount; const isImageParticle = imageOverride && i <= imageParticleCount;
const randomImageIndex = Math.floor(Math.random() * imageOverride.length);
const sizeRange = imageOverride[randomImageIndex]?.sizeRange;
const src = imageOverride[randomImageIndex]?.image;
const particle = new Particle(canvas, { const particle = new Particle(canvas, {
imgSrc: isImageParticle ? imageOverride : undefined, imgSrc: isImageParticle ? src : undefined,
horizontalMotion: imageOverride?.includes("fishie"), horizontalMotion: src?.includes("fishie"),
sizeRange, sizeRange,
}); });
particles.push(particle); particles.push(particle);