* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
overflow: hidden;
background: #03045e;
}
canvas {
display: block;
width: 100%;
height: 100vh;
}
.content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
color: #ffffff;
z-index: 10;
pointer-events: none;
}
.content h1 {
font-size: 4rem;
font-weight: 700;
margin-bottom: 20px;
text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
animation: fadeInDown 1s ease-out;
}
.content p {
font-size: 1.5rem;
opacity: 0.9;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
animation: fadeInUp 1s ease-out 0.3s backwards;
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 0.9;
transform: translateY(0);
}
}
.controls {
position: absolute;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 15px;
z-index: 10;
}
.btn {
padding: 12px 24px;
background: rgba(255, 255, 255, 0.15);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
border-radius: 30px;
cursor: pointer;
font-size: 0.95rem;
font-weight: 600;
backdrop-filter: blur(10px);
transition: all 0.3s;
pointer-events: auto;
}
.btn:hover {
background: rgba(255, 255, 255, 0.25);
border-color: rgba(255, 255, 255, 0.5);
transform: translateY(-2px);
}
.btn:active {
transform: translateY(0);
}
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
let width = canvas.width = window.innerWidth;
let height = canvas.height = window.innerHeight;
let particles = [];
let particleCount = 100;
let connectionDistance = 150;
let mouseX = width / 2;
let mouseY = height / 2;
let animationRunning = true;
let currentPattern = 0;
// Color palette based on #03045e
const colors = {
primary: '#03045e',
light1: '#0077b6',
light2: '#00b4d8',
light3: '#90e0ef',
accent: '#caf0f8'
};
class Particle {
constructor() {
this.reset();
this.y = Math.random() * height;
this.vx = (Math.random() - 0.5) * 2;
this.vy = (Math.random() - 0.5) * 2;
}
reset() {
this.x = Math.random() * width;
this.y = Math.random() * height;
this.vx = (Math.random() - 0.5) * 2;
this.vy = (Math.random() - 0.5) * 2;
this.radius = Math.random() * 3 + 1;
this.opacity = Math.random() * 0.5 + 0.3;
}
update() {
this.x += this.vx;
this.y += this.vy;
// Bounce off edges
if (this.x < 0 || this.x > width) this.vx *= -1;
if (this.y < 0 || this.y > height) this.vy *= -1;
// Mouse interaction
const dx = mouseX - this.x;
const dy = mouseY - this.y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 100) {
const force = (100 - distance) / 100;
this.vx -= (dx / distance) * force * 0.5;
this.vy -= (dy / distance) * force * 0.5;
}
// Limit velocity
const speed = Math.sqrt(this.vx * this.vx + this.vy * this.vy);
if (speed > 3) {
this.vx = (this.vx / speed) * 3;
this.vy = (this.vy / speed) * 3;
}
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
ctx.fillStyle = `rgba(202, 240, 248, ${this.opacity})`;
ctx.fill();
}
}
function init() {
particles = [];
for (let i = 0; i < particleCount; i++) {
particles.push(new Particle());
}
}
function drawConnections() {
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x;
const dy = particles[i].y - particles[j].y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < connectionDistance) {
const opacity = (1 - distance / connectionDistance) * 0.5;
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
// Gradient line
const gradient = ctx.createLinearGradient(
particles[i].x, particles[i].y,
particles[j].x, particles[j].y
);
gradient.addColorStop(0, `rgba(0, 180, 216, ${opacity})`);
gradient.addColorStop(1, `rgba(202, 240, 248, ${opacity})`);
ctx.strokeStyle = gradient;
ctx.lineWidth = 1;
ctx.stroke();
}
}
}
}
function drawPolygons() {
// Create triangular polygons from connected particles
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
for (let k = j + 1; k < particles.length; k++) {
const d1 = distance(particles[i], particles[j]);
const d2 = distance(particles[j], particles[k]);
const d3 = distance(particles[k], particles[i]);
if (d1 < connectionDistance && d2 < connectionDistance && d3 < connectionDistance) {
const avgDistance = (d1 + d2 + d3) / 3;
const opacity = (1 - avgDistance / connectionDistance) * 0.15;
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
ctx.lineTo(particles[k].x, particles[k].y);
ctx.closePath();
ctx.fillStyle = `rgba(0, 180, 216, ${opacity})`;
ctx.fill();
ctx.strokeStyle = `rgba(202, 240, 248, ${opacity * 2})`;
ctx.lineWidth = 0.5;
ctx.stroke();
}
}
}
}
}
function distance(p1, p2) {
const dx = p1.x - p2.x;
const dy = p1.y - p2.y;
return Math.sqrt(dx * dx + dy * dy);
}
function animate() {
if (!animationRunning) return;
ctx.fillStyle = colors.primary;
ctx.fillRect(0, 0, width, height);
particles.forEach(particle => {
particle.update();
particle.draw();
});
if (currentPattern === 0) {
drawConnections();
} else {
drawPolygons();
}
requestAnimationFrame(animate);
}
function changePattern() {
currentPattern = currentPattern === 0 ? 1 : 0;
}
function toggleAnimation() {
animationRunning = !animationRunning;
if (animationRunning) {
animate();
}
}
// Mouse tracking
canvas.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
});
// Touch support
canvas.addEventListener('touchmove', (e) => {
e.preventDefault();
mouseX = e.touches[0].clientX;
mouseY = e.touches[0].clientY;
});
// Resize handling
window.addEventListener('resize', () => {
width = canvas.width = window.innerWidth;
height = canvas.height = window.innerHeight;
init();
});
// Initialize and start
init();
animate();
No comments yet. Be the first!