Files
2025-12-07 02:17:19 +01:00

1142 lines
30 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>xdfnx</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@500;700;800&display=swap"
rel="stylesheet">
<style>
/* ===== Variables & Core ===== */
:root {
/* Dark Theme (Professional Deep Slate) */
--bg-dark: #0b1120;
--card-dark: rgba(30, 41, 59, 0.7);
/* More transparent for blur */
--text-main-dark: #f1f5f9;
--text-muted-dark: #94a3b8;
--accent-dark: #6366f1;
/* Indigo */
--accent-glow-dark: rgba(99, 102, 241, 0.2);
--border-dark: rgba(255, 255, 255, 0.08);
/* Light Theme */
--bg-light: #ffffff;
--card-light: rgba(243, 244, 246, 0.8);
--text-main-light: #111827;
--text-muted-light: #4b5563;
--accent-light: #4f46e5;
--accent-glow-light: rgba(79, 70, 229, 0.1);
--border-light: rgba(0, 0, 0, 0.06);
--font-heading: 'Outfit', sans-serif;
--font-body: 'Inter', sans-serif;
--radius: 12px;
}
* {
box-sizing: border-box;
}
body {
font-family: var(--font-body);
margin: 0;
padding: 0;
background: var(--bg-dark);
color: var(--text-main-dark);
transition: background 0.3s, color 0.3s;
line-height: 1.6;
overflow-x: hidden;
}
body.light-theme {
background: var(--bg-light);
color: var(--text-main-light);
}
.container {
max-width: 1100px;
margin: 0 auto;
padding: 0 1.5rem;
}
/* ===== Decoration ===== */
#bg-canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
body.light-theme .mesh-gradient {
background: radial-gradient(circle, var(--accent-glow-light) 0%, transparent 60%);
}
/* Floating Orbs */
.orb {
position: fixed;
border-radius: 50%;
filter: blur(80px);
z-index: -1;
opacity: 0.6;
animation: float-orb 20s infinite ease-in-out;
}
.orb-1 {
top: 10%;
left: 10%;
width: 300px;
height: 300px;
background: var(--accent-dark);
animation-delay: 0s;
}
.orb-2 {
bottom: 20%;
right: 10%;
width: 400px;
height: 400px;
background: #a855f7;
/* Purple */
animation-delay: -5s;
}
.orb-3 {
top: 40%;
left: 60%;
width: 200px;
height: 200px;
background: #06b6d4;
/* Cyan */
animation-delay: -10s;
}
@keyframes float-orb {
0%,
100% {
transform: translate(0, 0);
}
33% {
transform: translate(30px, -50px);
}
66% {
transform: translate(-20px, 20px);
}
}
/* Custom Cursor */
.cursor-dot,
.cursor-outline {
position: fixed;
top: 0;
left: 0;
transform: translate(-50%, -50%);
border-radius: 50%;
z-index: 9999;
pointer-events: none;
}
.cursor-dot {
width: 8px;
height: 8px;
background-color: var(--accent-dark);
}
.cursor-outline {
width: 40px;
height: 40px;
border: 1px solid var(--accent-dark);
transition: width 0.2s, height 0.2s, background-color 0.2s;
}
body:hover .cursor-outline {
opacity: 1;
}
/* Hover state for cursor */
body.hovering .cursor-outline {
width: 60px;
height: 60px;
background-color: rgba(99, 102, 241, 0.1);
border-color: transparent;
}
/* ===== Header & Stats ===== */
.header {
padding: 8rem 0 4rem;
text-align: center;
}
.status-badge {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 16px;
border-radius: 50px;
background: rgba(99, 102, 241, 0.1);
border: 1px solid rgba(99, 102, 241, 0.3);
color: var(--accent-dark);
font-size: 0.85rem;
font-weight: 600;
margin-bottom: 1.5rem;
}
.status-dot {
width: 8px;
height: 8px;
background: currentColor;
border-radius: 50%;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% {
opacity: 1;
}
50% {
opacity: 0.4;
}
100% {
opacity: 1;
}
}
.headline {
font-family: var(--font-heading);
font-size: clamp(3rem, 6vw, 5rem);
line-height: 1.1;
margin: 0 0 1rem;
background: linear-gradient(135deg, #fff 0%, #94a3b8 50%, #6366f1 100%);
background-size: 200% auto;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: gradient-flow 5s linear infinite;
}
@keyframes gradient-flow {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
body.light-theme .headline {
background: linear-gradient(135deg, #111 0%, #666 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.sub-headline {
font-size: 1.25rem;
color: var(--text-muted-dark);
max-width: 600px;
margin: 0 auto 2.5rem;
}
body.light-theme .sub-headline {
color: var(--text-muted-light);
}
.cta-group {
display: flex;
gap: 1rem;
justify-content: center;
margin-bottom: 4rem;
}
.btn {
padding: 0.8rem 1.5rem;
border-radius: 8px;
font-weight: 600;
text-decoration: none;
transition: 0.2s;
font-size: 1rem;
display: inline-flex;
align-items: center;
gap: 8px;
}
.btn-primary {
background: var(--accent-dark);
color: #fff;
border: 1px solid transparent;
}
.btn-primary:hover {
background: #4f46e5;
transform: translateY(-2px);
}
.btn-secondary {
background: transparent;
border: 1px solid var(--border-dark);
color: var(--text-main-dark);
}
body.light-theme .btn-secondary {
border-color: var(--border-light);
color: var(--text-main-light);
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.05);
}
/* Stats Bar */
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 2rem;
padding: 2rem;
border-radius: var(--radius);
border-radius: var(--radius);
background: var(--card-dark);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid var(--border-dark);
max-width: 800px;
margin: 0 auto;
}
body.light-theme .stats-grid {
background: var(--card-light);
border-color: var(--border-light);
}
.stat-item {
text-align: center;
}
.stat-num {
display: block;
font-family: var(--font-heading);
font-size: 2rem;
font-weight: 700;
color: var(--accent-dark);
}
.stat-label {
font-size: 0.9rem;
color: var(--text-muted-dark);
}
/* ===== Sections ===== */
.section {
padding: 5rem 0;
opacity: 0;
transform: translateY(30px);
transition: 0.6s ease;
}
.section.visible {
opacity: 1;
transform: translateY(0);
}
.section-title {
font-family: var(--font-heading);
font-size: 2rem;
margin-bottom: 3rem;
display: flex;
align-items: center;
gap: 1rem;
}
.section-title::after {
content: '';
flex-grow: 1;
height: 1px;
background: var(--border-dark);
opacity: 0.5;
}
body.light-theme .section-title::after {
background: var(--border-light);
}
/* ===== Experience Timeline (Serious Stuff) ===== */
.timeline {
position: relative;
border-left: 2px solid var(--border-dark);
margin-left: 1rem;
padding-left: 2rem;
}
body.light-theme .timeline {
border-color: var(--border-light);
}
.timeline-item {
position: relative;
margin-bottom: 3rem;
}
.timeline-item::before {
content: '';
position: absolute;
left: -2.45rem;
top: 5px;
width: 14px;
height: 14px;
border-radius: 50%;
background: var(--bg-dark);
border: 2px solid var(--accent-dark);
}
body.light-theme .timeline-item::before {
background: var(--bg-light);
border-color: var(--accent-light);
}
.role {
font-size: 1.25rem;
font-weight: 700;
color: var(--text-main-dark);
margin: 0 0 0.5rem;
}
body.light-theme .role {
color: var(--text-main-light);
}
.company {
color: var(--accent-dark);
font-weight: 600;
font-size: 0.95rem;
margin-bottom: 0.5rem;
display: block;
}
.period {
font-size: 0.85rem;
color: var(--text-muted-dark);
margin-bottom: 1rem;
display: block;
font-family: monospace;
}
.description {
color: var(--text-muted-dark);
margin: 0;
max-width: 700px;
}
/* ===== Tech Stack (Expanded) ===== */
.stack-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 2rem;
}
.stack-card {
background: var(--card-dark);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid var(--border-dark);
padding: 1.5rem;
border-radius: var(--radius);
}
body.light-theme .stack-card {
background: var(--card-light);
border-color: var(--border-light);
}
.stack-title {
font-size: 1.1rem;
margin: 0 0 1.5rem;
display: flex;
align-items: center;
gap: 10px;
color: var(--text-main-dark);
}
body.light-theme .stack-title {
color: var(--text-main-light);
}
.stack-title i {
color: var(--accent-dark);
}
.icons-container img {
height: 45px;
margin-right: 12px;
margin-bottom: 12px;
transition: transform 0.2s;
}
.icons-container img:hover {
transform: translateY(-5px);
}
/* ===== Projects ===== */
.project-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 2rem;
}
.project-card {
background: var(--card-dark);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid var(--border-dark);
border-radius: var(--radius);
padding: 2rem;
transition: 0.3s;
display: flex;
flex-direction: column;
}
body.light-theme .project-card {
background: var(--card-light);
border-color: var(--border-light);
}
.project-card:hover {
transform: translateY(-5px);
border-color: var(--accent-dark);
}
.project-head {
display: flex;
justify-content: space-between;
align-items: start;
margin-bottom: 1rem;
}
.project-head h3 {
margin: 0;
font-size: 1.4rem;
font-family: var(--font-heading);
}
.project-head a {
color: var(--text-muted-dark);
font-size: 1.2rem;
transition: 0.2s;
}
.project-head a:hover {
color: var(--accent-dark);
}
.tech-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: auto;
padding-top: 1.5rem;
}
.tech-pill {
font-size: 0.75rem;
padding: 4px 10px;
border-radius: 4px;
background: rgba(255, 255, 255, 0.05);
color: var(--text-muted-dark);
font-weight: 500;
}
body.light-theme .tech-pill {
background: rgba(0, 0, 0, 0.05);
color: var(--text-muted-light);
}
/* ===== Team Section ===== */
.team-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
margin-top: 2rem;
}
.team-card {
background: var(--card-dark);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid var(--border-dark);
border-radius: var(--radius);
padding: 2.5rem 1.5rem;
text-align: center;
transition: transform 0.3s, box-shadow 0.3s;
position: relative;
overflow: hidden;
}
body.light-theme .team-card {
background: var(--card-light);
border-color: var(--border-light);
}
.team-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4px;
background: linear-gradient(90deg, var(--accent-dark), #a855f7);
transform: scaleX(0);
transition: transform 0.3s ease;
transform-origin: left;
}
.team-card:hover::before {
transform: scaleX(1);
}
.team-card:hover {
transform: translateY(-10px);
box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.3);
}
.team-avatar {
width: 90px;
height: 90px;
border-radius: 50%;
background: linear-gradient(135deg, var(--accent-dark), #a855f7);
margin: 0 auto 1.5rem;
display: flex;
align-items: center;
justify-content: center;
font-size: 2.5rem;
color: white;
font-weight: 700;
box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}
.team-name {
font-family: var(--font-heading);
font-size: 1.4rem;
margin-bottom: 0.5rem;
color: var(--text-main-dark);
font-weight: 700;
}
body.light-theme .team-name {
color: var(--text-main-light);
}
.team-link {
color: var(--accent-dark);
text-decoration: none;
font-size: 0.95rem;
transition: color 0.2s;
font-weight: 500;
}
.team-link:hover {
color: #a855f7;
text-decoration: underline;
}
/* ===== Footer ===== */
.footer {
text-align: center;
padding: 4rem 0;
color: var(--text-muted-dark);
font-size: 0.9rem;
border-top: 1px solid var(--border-dark);
margin-top: 4rem;
}
body.light-theme .footer {
color: var(--text-muted-light);
border-color: var(--border-light);
}
/* Theme Toggle */
.theme-toggle {
position: fixed;
top: 1.5rem;
right: 1.5rem;
width: 44px;
height: 44px;
border-radius: 50%;
background: var(--card-dark);
border: 1px solid var(--border-dark);
color: var(--text-main-dark);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: 0.3s;
z-index: 100;
}
body.light-theme .theme-toggle {
background: #fff;
border-color: #ddd;
color: #333;
}
.theme-toggle:hover {
transform: scale(1.1);
}
/* Responsive */
@media (max-width: 768px) {
.headline {
font-size: 2.8rem;
}
.stats-grid {
grid-template-columns: 1fr;
gap: 1rem;
}
.section {
padding: 3rem 0;
}
}
</style>
</head>
<body class="dark-theme">
<div class="mesh-gradient"></div>
<div class="orb orb-1"></div>
<div class="orb orb-2"></div>
<div class="orb orb-3"></div>
<div class="cursor-dot"></div>
<div class="cursor-outline"></div>
<button class="theme-toggle" id="theme-toggle" aria-label="Toggle Theme">
<i class="fas fa-sun"></i>
</button>
<div class="container">
<header class="header">
<div class="status-badge">
<div class="status-dot"></div> Open for Complex Projects
</div>
<h1 class="headline">xdfnx</h1>
<p class="sub-headline">
Senior Full Stack Engineer with a focus on system performance.
I build scalable web applications and optimize core infrastructure using <strong>Rust</strong> &
<strong>C++</strong>.
</p>
<div class="cta-group">
<a href="#contact" class="btn btn-primary"><i class="fas fa-paper-plane"></i> Contact Me</a>
<a href="#projects" class="btn btn-secondary"><i class="fas fa-code"></i> View Work</a>
</div>
<div class="stats-grid">
<div class="stat-item">
<span class="stat-num">6+</span>
<span class="stat-label">Years Experience</span>
</div>
<div class="stat-item">
<span class="stat-num">20+</span>
<span class="stat-label">Production Deploys</span>
</div>
<div class="stat-item">
<span class="stat-num">100%</span>
<span class="stat-label">Performance Focused</span>
</div>
</div>
</header>
<section id="experience" class="section">
<h2 class="section-title">Professional Experience</h2>
<div class="timeline">
<div class="timeline-item">
<h3 class="role">Senior Full Stack Engineer</h3>
<span class="company">TechFlow Systems</span>
<span class="period">2025 - Present</span>
<p class="description">
Leading the backend migration to microservices. Implemented a high-throughput event processing pipeline
using <strong>Python</strong> and <strong>Rust</strong>, reducing latency by 40%. Oversaw the React frontend
architecture for the main dashboard.
</p>
</div>
<div class="timeline-item">
<h3 class="role">Software Engineer</h3>
<span class="company">Creative Solutions Ltd.</span>
<span class="period">2020 - 2023</span>
<p class="description">
Developed full-stack web applications using Node.js and TypeScript. Integrated native <strong>C++</strong>
modules for image processing tasks, speeding up user workflows by 3x.
</p>
</div>
</div>
</section>
<section id="skills" class="section">
<h2 class="section-title">Technical Arsenal</h2>
<div class="stack-grid">
<div class="stack-card">
<div class="stack-title"><i class="fas fa-laptop-code"></i> Modern Frontend</div>
<div class="icons-container">
<img src="https://skillicons.dev/icons?i=react,nextjs,ts,js,tailwind" alt="Frontend">
</div>
<p style="font-size: 0.9rem; color: var(--text-muted-dark); margin-top: 10px;">
Building responsive, type-safe interfaces with a focus on UX and accessibility.
</p>
</div>
<div class="stack-card">
<div class="stack-title"><i class="fas fa-server"></i> Backend & Infra</div>
<div class="icons-container">
<img src="https://skillicons.dev/icons?i=nodejs,python,postgres,redis,docker" alt="Backend">
</div>
<p style="font-size: 0.9rem; color: var(--text-muted-dark); margin-top: 10px;">
Scalable architectures using Node & Python. Dockerized deployments and cloud infrastructure.
</p>
</div>
<div class="stack-card">
<div class="stack-title"><i class="fas fa-microchip"></i> Systems & Low Level</div>
<div class="icons-container">
<img src="https://skillicons.dev/icons?i=rust,cpp,c,linux,git" alt="Systems">
</div>
<p style="font-size: 0.9rem; color: var(--text-muted-dark); margin-top: 10px;">
When JS isn't fast enough. Writing memory-safe, high-performance modules for critical paths.
</p>
</div>
</div>
</section>
<section id="projects" class="section">
<h2 class="section-title">Selected Work</h2>
<div class="project-grid">
<div class="project-card">
<div class="project-head">
<h3>Fintech Analytics Engine</h3>
</div>
<p style="color: var(--text-muted-dark)">
A real-time dashboard for financial data visualization. The backend aggregates streams from multiple sources
using a custom <strong>Rust</strong> service for zero-cost abstraction performance.
</p>
<div class="tech-list">
<span class="tech-pill">Next.js</span>
<span class="tech-pill">Rust</span>
<span class="tech-pill">WebSockets</span>
</div>
</div>
<div class="project-card">
<div class="project-head">
<h3>AI Data Pipeline</h3>
</div>
<p style="color: var(--text-muted-dark)">
Automated ETL pipeline processing terabytes of data. Written in <strong>Python</strong> for flexibility with
C++ bindings for heavy computational steps.
</p>
<div class="tech-list">
<span class="tech-pill">Python</span>
<span class="tech-pill">C++</span>
<span class="tech-pill">Docker</span>
</div>
</div>
<div class="project-card">
<div class="project-head">
<h3>Distributed Task Queue</h3>
</div>
<p style="color: var(--text-muted-dark)">
Fault-tolerant job scheduler inspired by Celery but optimized for low-memory environments.
</p>
<div class="tech-list">
<span class="tech-pill">Node.js</span>
<span class="tech-pill">Redis</span>
<span class="tech-pill">System Design</span>
</div>
</div>
</div>
</section>
<section id="team" class="section">
<h2 class="section-title">The Team</h2>
<div class="team-grid">
<!-- chernuha -->
<div class="team-card">
<div class="team-avatar">C</div>
<h3 class="team-name">chernuha</h3>
<a href="https://chernuha.space" target="_blank" class="team-link">chernuha.space</a>
</div>
<!-- MrForust -->
<div class="team-card">
<div class="team-avatar">M</div>
<h3 class="team-name">MrForust</h3>
<a href="https://forust.xyz" target="_blank" class="team-link">forust.xyz</a>
</div>
<!-- hudan -->
<div class="team-card">
<div class="team-avatar">H</div>
<h3 class="team-name">hudan</h3>
<a href="https://hudan.xyz" target="_blank" class="team-link">hudan.xyz</a>
</div>
</div>
</section>
<footer class="footer" id="contact">
<h2 style="color: var(--text-main-dark); margin-bottom: 1rem;">Ready to scale?</h2>
<p style="margin-bottom: 2rem;">Let's discuss how I can help your team build faster and better.</p>
<a href="mailto:contact@xdfnx.dev" class="btn btn-primary">contact@xdfnx.cfd</a>
<p style="margin-top: 2rem; opacity: 0.5;">&copy; <span id="current-year">2025</span> xdfnx. Engineering
Excellence.
</p>
</footer>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const toggle = document.getElementById('theme-toggle');
const body = document.body;
const icon = toggle.querySelector('i');
// Restore Theme
const savedTheme = localStorage.getItem('theme') || 'dark';
body.className = savedTheme + '-theme';
updateIcon(savedTheme);
toggle.addEventListener('click', () => {
const current = body.classList.contains('dark-theme') ? 'dark' : 'light';
const next = current === 'dark' ? 'light' : 'dark';
body.className = next + '-theme';
localStorage.setItem('theme', next);
updateIcon(next);
initParticles(); // Refresh particle colors
});
function updateIcon(theme) {
if (theme === 'dark') {
icon.className = 'fas fa-sun';
} else {
icon.className = 'fas fa-moon';
}
}
// Scroll Animations
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, { threshold: 0.1 });
document.querySelectorAll('.section').forEach(sec => observer.observe(sec));
// Dynamic Year
document.getElementById('current-year').textContent = new Date().getFullYear();
// Simple Tilt Effect for Cards
const cards = document.querySelectorAll('.project-card, .stack-card, .team-card');
cards.forEach(card => {
card.addEventListener('mousemove', (e) => {
const rect = card.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const rotateX = ((y - centerY) / centerY) * -5;
const rotateY = ((x - centerX) / centerX) * 5;
card.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale3d(1.02, 1.02, 1.02)`;
});
card.addEventListener('mouseleave', () => {
card.style.transform = 'perspective(1000px) rotateX(0) rotateY(0) scale3d(1, 1, 1)';
});
});
// Custom Cursor Logic
const cursorDot = document.querySelector('.cursor-dot');
const cursorOutline = document.querySelector('.cursor-outline');
window.addEventListener('mousemove', (e) => {
const posX = e.clientX;
const posY = e.clientY;
cursorDot.style.left = `${posX}px`;
cursorDot.style.top = `${posY}px`;
// Add some lag to the outline for a smooth feel
cursorOutline.animate({
left: `${posX}px`,
top: `${posY}px`
}, { duration: 500, fill: "forwards" });
});
// Hover effect for cursor
const interactiveElements = document.querySelectorAll('a, button, .card, .project-card, .stack-card, .team-card');
interactiveElements.forEach(el => {
el.addEventListener('mouseenter', () => document.body.classList.add('hovering'));
el.addEventListener('mouseleave', () => document.body.classList.remove('hovering'));
});
// ===== Dynamic Background (Particles) =====
const canvas = document.getElementById('bg-canvas');
const ctx = canvas.getContext('2d');
let particlesArray;
// Set Canvas Size
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Handle Resize
window.addEventListener('resize', () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
initParticles();
});
// Mouse Interaction
const mouse = {
x: null,
y: null,
radius: 150
}
window.addEventListener('mousemove', (event) => {
mouse.x = event.x;
mouse.y = event.y;
});
// Particle Class
class Particle {
constructor(x, y, directionX, directionY, size, color) {
this.x = x;
this.y = y;
this.directionX = directionX;
this.directionY = directionY;
this.size = size;
this.color = color;
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2, false);
ctx.fillStyle = this.color;
ctx.fill();
}
update() {
// Boundary Check
if (this.x > canvas.width || this.x < 0) {
this.directionX = -this.directionX;
}
if (this.y > canvas.height || this.y < 0) {
this.directionY = -this.directionY;
}
// Mouse Collision (Repel)
let dx = mouse.x - this.x;
let dy = mouse.y - this.y;
let distance = Math.sqrt(dx * dx + dy * dy);
if (distance < mouse.radius + this.size) {
if (mouse.x < this.x && this.x < canvas.width - this.size * 10) {
this.x += 10;
}
if (mouse.x > this.x && this.x > this.size * 10) {
this.x -= 10;
}
if (mouse.y < this.y && this.y < canvas.height - this.size * 10) {
this.y += 10;
}
if (mouse.y > this.y && this.y > this.size * 10) {
this.y -= 10;
}
}
// Move
this.x += this.directionX;
this.y += this.directionY;
this.draw();
}
}
function initParticles() {
particlesArray = [];
let numberOfParticles = (canvas.height * canvas.width) / 9000;
let color = document.body.classList.contains('light-theme') ? '#4f46e5' : '#6366f1';
for (let i = 0; i < numberOfParticles; i++) {
let size = (Math.random() * 3) + 1;
let x = (Math.random() * ((innerWidth - size * 2) - (size * 2)) + size * 2);
let y = (Math.random() * ((innerHeight - size * 2) - (size * 2)) + size * 2);
let directionX = (Math.random() * 2) - 1; // -1 to 1
let directionY = (Math.random() * 2) - 1;
particlesArray.push(new Particle(x, y, directionX, directionY, size, color));
}
}
function animateParticles() {
requestAnimationFrame(animateParticles);
ctx.clearRect(0, 0, innerWidth, innerHeight);
for (let i = 0; i < particlesArray.length; i++) {
particlesArray[i].update();
}
connectParticles();
}
function connectParticles() {
let opacityValue = 1;
let connectorColor = document.body.classList.contains('light-theme') ? '79, 70, 229' : '99, 102, 241';
for (let a = 0; a < particlesArray.length; a++) {
for (let b = a; b < particlesArray.length; b++) {
let distance = ((particlesArray[a].x - particlesArray[b].x) * (particlesArray[a].x - particlesArray[b].x))
+ ((particlesArray[a].y - particlesArray[b].y) * (particlesArray[a].y - particlesArray[b].y));
if (distance < (canvas.width / 7) * (canvas.height / 7)) {
opacityValue = 1 - (distance / 20000);
ctx.strokeStyle = 'rgba(' + connectorColor + ',' + opacityValue + ')';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(particlesArray[a].x, particlesArray[a].y);
ctx.lineTo(particlesArray[b].x, particlesArray[b].y);
ctx.stroke();
}
}
}
}
initParticles();
animateParticles();
});
</script>
</body>
</html>