Skip to content

Commit 110c248

Browse files
committed
feat: enhance starfield animation with dynamic opacity and duration effects
1 parent b5e4b6f commit 110c248

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

src/components/language-card.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,16 @@ export class LanguageCardRenderer {
9898
const starField = Array.from({ length: 60 }, (_, i) => {
9999
const x = ((i * 113) % width).toFixed(0);
100100
const y = ((i * 61) % height).toFixed(0);
101-
const r = (1 + (i % 3)).toFixed(0);
102-
const delay = ((i % 10) * 0.5).toFixed(1);
103-
const opacity = (0.2 + (i % 4) * 0.06).toFixed(2);
104-
return `<circle class="star" style="animation-delay:${delay}s" cx="${x}" cy="${y}" r="${r}" opacity="${opacity}" />`;
101+
const r = (1 + (i % 3)).toFixed(1);
102+
const opacity = (0.2 + (i % 4) * 0.08).toFixed(2);
103+
const duration = (i % 3 === 0 ? 3 : i % 3 === 1 ? 5 : 7);
104+
const begin = (i % 10) * 0.2;
105+
const minOpacity = (parseFloat(opacity) * 0.3).toFixed(2);
106+
107+
return `
108+
<circle cx="${x}" cy="${y}" r="${r}" fill="${theme.textColor}" opacity="${opacity}">
109+
<animate attributeName="opacity" values="${opacity};${minOpacity};${opacity}" dur="${duration}s" begin="${begin}s" repeatCount="indefinite" />
110+
</circle>`;
105111
}).join('');
106112

107113
const bubbleNodes = bubbles.map((bubble, index) => {
@@ -275,11 +281,6 @@ export class LanguageCardRenderer {
275281
50% { transform: translate(12px, -8px); }
276282
}
277283
278-
@keyframes twinkle {
279-
0%, 100% { opacity: 0.2; }
280-
50% { opacity: 0.6; }
281-
}
282-
283284
@keyframes spaceFloat {
284285
0%, 100% { transform: translate(0, 0); }
285286
50% { transform: translate(-6px, -4px); }
@@ -300,11 +301,6 @@ export class LanguageCardRenderer {
300301
transform-origin: ${centerX}px ${centerY}px;
301302
}
302303
303-
.star {
304-
fill: ${theme.textColor};
305-
animation: twinkle 6s ease-in-out infinite;
306-
}
307-
308304
.space-icons {
309305
animation: spaceFloat 12s ease-in-out infinite;
310306
}

0 commit comments

Comments
 (0)