|
24 | 24 | box-sizing: border-box;
|
25 | 25 | }
|
26 | 26 |
|
| 27 | + /* Add particle canvas styling */ |
| 28 | + #particle-canvas { |
| 29 | + position: fixed; |
| 30 | + top: 0; |
| 31 | + left: 0; |
| 32 | + width: 100%; |
| 33 | + height: 100%; |
| 34 | + pointer-events: none; |
| 35 | + z-index: 0; |
| 36 | + } |
| 37 | + |
| 38 | + /* Ensure content stays above particles */ |
| 39 | + nav, header, section, footer { |
| 40 | + position: relative; |
| 41 | + z-index: 1; |
| 42 | + } |
27 | 43 | body {
|
28 | 44 | font-family: 'Inter', sans-serif;
|
29 | 45 | line-height: 1.6;
|
|
469 | 485 | </style>
|
470 | 486 | </head>
|
471 | 487 | <body>
|
| 488 | + <canvas id="particle-canvas"></canvas> |
472 | 489 | <nav>
|
473 | 490 | <div class="nav-content">
|
474 | 491 | <a href="#" class="logo">
|
@@ -742,6 +759,87 @@ <h3>Connect</h3>
|
742 | 759 | });
|
743 | 760 | });
|
744 | 761 | </script>
|
| 762 | + <script> |
| 763 | + // Add particle animation |
| 764 | + const canvas = document.getElementById('particle-canvas'); |
| 765 | + const ctx = canvas.getContext('2d'); |
| 766 | + |
| 767 | + // Set canvas size |
| 768 | + function resizeCanvas() { |
| 769 | + canvas.width = window.innerWidth; |
| 770 | + canvas.height = window.innerHeight; |
| 771 | + } |
| 772 | + resizeCanvas(); |
| 773 | + window.addEventListener('resize', resizeCanvas); |
| 774 | + |
| 775 | + // Particle class |
| 776 | + class Particle { |
| 777 | + constructor() { |
| 778 | + this.x = Math.random() * canvas.width; |
| 779 | + this.y = Math.random() * canvas.height; |
| 780 | + this.size = Math.random() * 2 + 1; |
| 781 | + this.speedX = Math.random() * 1 - 0.5; |
| 782 | + this.speedY = Math.random() * 1 - 0.5; |
| 783 | + this.opacity = Math.random() * 0.5 + 0.1; |
| 784 | + } |
| 785 | + |
| 786 | + update() { |
| 787 | + this.x += this.speedX; |
| 788 | + this.y += this.speedY; |
| 789 | + |
| 790 | + if (this.x > canvas.width) this.x = 0; |
| 791 | + if (this.x < 0) this.x = canvas.width; |
| 792 | + if (this.y > canvas.height) this.y = 0; |
| 793 | + if (this.y < 0) this.y = canvas.height; |
| 794 | + } |
| 795 | + |
| 796 | + draw() { |
| 797 | + ctx.fillStyle = `rgba(255, 255, 255, ${this.opacity})`; |
| 798 | + ctx.beginPath(); |
| 799 | + ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2); |
| 800 | + ctx.fill(); |
| 801 | + } |
| 802 | + } |
| 803 | + |
| 804 | + // Create particle array |
| 805 | + const particles = []; |
| 806 | + const particleCount = 220; |
| 807 | + |
| 808 | + for (let i = 0; i < particleCount; i++) { |
| 809 | + particles.push(new Particle()); |
| 810 | + } |
| 811 | + |
| 812 | + // Animation loop |
| 813 | + function animate() { |
| 814 | + ctx.clearRect(0, 0, canvas.width, canvas.height); |
| 815 | + |
| 816 | + particles.forEach(particle => { |
| 817 | + particle.update(); |
| 818 | + particle.draw(); |
| 819 | + }); |
| 820 | + |
| 821 | + // Draw connections between nearby particles |
| 822 | + particles.forEach((particle1, index) => { |
| 823 | + for (let j = index + 1; j < particles.length; j++) { |
| 824 | + const particle2 = particles[j]; |
| 825 | + const dx = particle1.x - particle2.x; |
| 826 | + const dy = particle1.y - particle2.y; |
| 827 | + const distance = Math.sqrt(dx * dx + dy * dy); |
| 828 | + |
| 829 | + if (distance < 100) { |
| 830 | + ctx.strokeStyle = `rgba(255, 255, 255, ${0.1 * (1 - distance/100)})`; |
| 831 | + ctx.beginPath(); |
| 832 | + ctx.moveTo(particle1.x, particle1.y); |
| 833 | + ctx.lineTo(particle2.x, particle2.y); |
| 834 | + ctx.stroke(); |
| 835 | + } |
| 836 | + } |
| 837 | + }); |
| 838 | + |
| 839 | + requestAnimationFrame(animate); |
| 840 | + } |
| 841 | + |
| 842 | + animate(); |
| 843 | + </script> |
745 | 844 | </body>
|
746 | 845 | </html>
|
747 |
| - |
|
0 commit comments