Skip to content

Commit 11dc008

Browse files
committed
dynamic background
1 parent 391079a commit 11dc008

File tree

1 file changed

+159
-1
lines changed

1 file changed

+159
-1
lines changed

index.html

Lines changed: 159 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,78 @@
3131

3232
body {
3333
font-family: 'Lato', sans-serif;
34-
background: linear-gradient(180deg, #020617 0%, #0f172a 50%, #1e293b 100%);
34+
background: #020617;
3535
color: var(--text-primary);
3636
overflow-x: hidden;
37+
position: relative;
38+
}
39+
40+
/* Animated Background */
41+
.animated-bg {
42+
position: fixed;
43+
top: 0;
44+
left: 0;
45+
width: 100%;
46+
height: 100%;
47+
z-index: -1;
48+
overflow: hidden;
49+
}
50+
51+
.gradient-orb {
52+
position: absolute;
53+
border-radius: 50%;
54+
filter: blur(80px);
55+
opacity: 0.5;
56+
animation: float 20s ease-in-out infinite;
57+
}
58+
59+
.gradient-orb:nth-child(1) {
60+
width: 500px;
61+
height: 500px;
62+
background: radial-gradient(circle, rgba(56, 189, 248, 0.4) 0%, transparent 70%);
63+
top: -200px;
64+
left: -200px;
65+
animation-delay: 0s;
66+
}
67+
68+
.gradient-orb:nth-child(2) {
69+
width: 600px;
70+
height: 600px;
71+
background: radial-gradient(circle, rgba(34, 211, 238, 0.3) 0%, transparent 70%);
72+
bottom: -300px;
73+
right: -200px;
74+
animation-delay: 5s;
75+
}
76+
77+
.gradient-orb:nth-child(3) {
78+
width: 400px;
79+
height: 400px;
80+
background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
81+
top: 50%;
82+
left: 50%;
83+
transform: translate(-50%, -50%);
84+
animation-delay: 10s;
85+
}
86+
87+
@keyframes float {
88+
0%, 100% {
89+
transform: translate(0, 0) scale(1);
90+
}
91+
33% {
92+
transform: translate(30px, -30px) scale(1.1);
93+
}
94+
66% {
95+
transform: translate(-20px, 20px) scale(0.9);
96+
}
97+
}
98+
99+
#particles-canvas {
100+
position: absolute;
101+
top: 0;
102+
left: 0;
103+
width: 100%;
104+
height: 100%;
105+
opacity: 0.6;
37106
}
38107

39108
/* Navbar */
@@ -413,6 +482,13 @@
413482
</style>
414483
</head>
415484
<body>
485+
<!-- Animated Background -->
486+
<div class="animated-bg">
487+
<canvas id="particles-canvas"></canvas>
488+
<div class="gradient-orb"></div>
489+
<div class="gradient-orb"></div>
490+
<div class="gradient-orb"></div>
491+
</div>
416492
<!-- Navigation -->
417493
<div class="navbar-black w-nav">
418494
<div class="container-47">
@@ -699,6 +775,88 @@ <h2 class="h2-section-text" data-i18n="updates.title">Latest Updates</h2>
699775
}
700776

701777
requestAnimationFrame(raf);
778+
779+
// Particle Animation Background
780+
const canvas = document.getElementById('particles-canvas');
781+
const ctx = canvas.getContext('2d');
782+
783+
function resizeCanvas() {
784+
canvas.width = window.innerWidth;
785+
canvas.height = window.innerHeight;
786+
}
787+
resizeCanvas();
788+
window.addEventListener('resize', resizeCanvas);
789+
790+
class Particle {
791+
constructor() {
792+
this.reset();
793+
this.y = Math.random() * canvas.height;
794+
}
795+
796+
reset() {
797+
this.x = Math.random() * canvas.width;
798+
this.y = Math.random() * canvas.height;
799+
this.size = Math.random() * 2 + 0.5;
800+
this.speedX = (Math.random() - 0.5) * 0.5;
801+
this.speedY = (Math.random() - 0.5) * 0.5;
802+
this.opacity = Math.random() * 0.5 + 0.2;
803+
}
804+
805+
update() {
806+
this.x += this.speedX;
807+
this.y += this.speedY;
808+
809+
if (this.x < 0 || this.x > canvas.width) this.speedX *= -1;
810+
if (this.y < 0 || this.y > canvas.height) this.speedY *= -1;
811+
}
812+
813+
draw() {
814+
ctx.fillStyle = `rgba(56, 189, 248, ${this.opacity})`;
815+
ctx.beginPath();
816+
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
817+
ctx.fill();
818+
}
819+
}
820+
821+
const particles = [];
822+
const particleCount = 80;
823+
824+
for (let i = 0; i < particleCount; i++) {
825+
particles.push(new Particle());
826+
}
827+
828+
function connectParticles() {
829+
for (let i = 0; i < particles.length; i++) {
830+
for (let j = i + 1; j < particles.length; j++) {
831+
const dx = particles[i].x - particles[j].x;
832+
const dy = particles[i].y - particles[j].y;
833+
const distance = Math.sqrt(dx * dx + dy * dy);
834+
835+
if (distance < 150) {
836+
ctx.strokeStyle = `rgba(56, 189, 248, ${0.2 * (1 - distance / 150)})`;
837+
ctx.lineWidth = 0.5;
838+
ctx.beginPath();
839+
ctx.moveTo(particles[i].x, particles[i].y);
840+
ctx.lineTo(particles[j].x, particles[j].y);
841+
ctx.stroke();
842+
}
843+
}
844+
}
845+
}
846+
847+
function animateParticles() {
848+
ctx.clearRect(0, 0, canvas.width, canvas.height);
849+
850+
particles.forEach(particle => {
851+
particle.update();
852+
particle.draw();
853+
});
854+
855+
connectParticles();
856+
requestAnimationFrame(animateParticles);
857+
}
858+
859+
animateParticles();
702860
</script>
703861
</body>
704862
</html>

0 commit comments

Comments
 (0)