From e207ec15f1624baf74198ce6ce52eda67f98ccc0 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 15 Dec 2024 12:55:54 +0000 Subject: [PATCH] Add blinking effect to nodes Implement a random blinking effect for the nodes in the NetworkAnimation component to enhance visual dynamics. [skip gpt_engineer] --- .../game/animations/NetworkAnimation.tsx | 54 ++++++++----------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/src/components/game/animations/NetworkAnimation.tsx b/src/components/game/animations/NetworkAnimation.tsx index 7e9c75c..145dfee 100644 --- a/src/components/game/animations/NetworkAnimation.tsx +++ b/src/components/game/animations/NetworkAnimation.tsx @@ -7,18 +7,20 @@ interface Node { y: number; size: number; delay: number; + isGreen: boolean; // New property to determine node color } export const NetworkAnimation = ({ className = '' }: { className?: string }) => { const containerRef = useRef(null); - // Generate nodes with different sizes and positions + // Generate nodes with different sizes, positions, and colors const nodes: Node[] = Array.from({ length: 15 }, (_, i) => ({ id: i, x: 20 + Math.random() * 60, y: 20 + Math.random() * 60, - size: 3 + Math.random() * 3, // Larger nodes (3-6px) - delay: i * 0.1 + size: 3 + Math.random() * 3, + delay: i * 0.1, + isGreen: Math.random() > 0.7 // 30% chance of being green })); // Create pairs of nodes for connections @@ -27,7 +29,7 @@ export const NetworkAnimation = ({ className = '' }: { className?: string }) => id: `${node.id}-${otherNode.id}`, from: node, to: otherNode, - opacity: Math.random() * 0.5 + 0.2 // Higher opacity (0.2-0.7) + opacity: Math.random() * 0.5 + 0.2 })) ); @@ -37,7 +39,6 @@ export const NetworkAnimation = ({ className = '' }: { className?: string }) => className={`relative w-full h-40 overflow-hidden bg-black/20 rounded-lg ${className}`} > - {/* Render connections between nodes */} {connections.map(({ id, from, to, opacity }) => ( y1={`${from.y}%`} x2={`${to.x}%`} y2={`${to.y}%`} - stroke="rgba(255, 215, 0, 0.4)" // Brighter connections - strokeWidth="1" // Thicker lines + stroke={`rgba(${from.isGreen && to.isGreen ? '0, 255, 0' : '255, 215, 0'}, 0.4)`} + strokeWidth="1" initial={{ opacity: 0, pathLength: 0 }} animate={{ opacity: [0, opacity, opacity/2], pathLength: [0, 1, 1], - strokeWidth: [1, 2, 1] // Pulsing line thickness + strokeWidth: [1, 2, 1] }} transition={{ duration: 2, @@ -64,7 +65,6 @@ export const NetworkAnimation = ({ className = '' }: { className?: string }) => ))} - {/* Render nodes */} {nodes.map((node) => ( animate={{ scale: [0, 1.2, 1], opacity: [0, 1, 0.8], - x: [ - -15, - 15, - -10, - 10, - 0 - ], - y: [ - -10, - 10, - -15, - 15, - 0 - ] + x: [-15, 15, -10, 10, 0], + y: [-10, 10, -15, 15, 0] }} transition={{ duration: 6, @@ -104,13 +92,13 @@ export const NetworkAnimation = ({ className = '' }: { className?: string }) => > {/* Core node */} {/* Outer glow */} {Array.from({ length: 4 }).map((_, i) => (