I'll create an impressive, interactive visual experience using HTML, CSS, and JavaScript with animated particles, gradients, and dynamic effects.
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mesmerizing Visual Generator</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
color: #fff;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
min-height: 100vh;
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 20px;
}
.container {
max-width: 1200px;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
z-index: 10;
}
header {
margin-bottom: 30px;
text-align: center;
}
h1 {
font-size: 3.5rem;
margin-bottom: 10px;
background: linear-gradient(to right, #ff7e5f, #feb47b, #86a8e7, #91eae4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 0 20px rgba(134, 168, 231, 0.3);
animation: pulse 4s infinite;
}
.subtitle {
font-size: 1.2rem;
opacity: 0.8;
max-width: 700px;
margin: 0 auto;
line-height: 1.6;
}
.visual-canvas {
position: relative;
width: 90%;
max-width: 800px;
height: 450px;
background: rgba(25, 25, 50, 0.3);
border-radius: 20px;
margin: 30px 0;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
overflow: hidden;
backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 15px;
justify-content: center;
margin: 20px 0;
padding: 20px;
background: rgba(20, 20, 40, 0.5);
border-radius: 15px;
width: 90%;
max-width: 800px;
}
.control-group {
display: flex;
flex-direction: column;
align-items: center;
}
label {
margin-bottom: 8px;
font-size: 0.9rem;
opacity: 0.9;
}
input[type="range"] {
width: 150px;
cursor: pointer;
}
.btn {
background: linear-gradient(45deg, #ff7e5f, #feb47b);
color: white;
border: none;
padding: 12px 25px;
border-radius: 50px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
font-size: 1rem;
box-shadow: 0 5px 15px rgba(255, 126, 95, 0.4);
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 8px 20px rgba(255, 126, 95, 0.6);
}
.btn:active {
transform: translateY(1px);
}
.particle {
position: absolute;
border-radius: 50%;
pointer-events: none;
}
.footer {
margin-top: 30px;
opacity: 0.7;
font-size: 0.9rem;
display: flex;
gap: 15px;
align-items: center;
}
.shape {
position: absolute;
border-radius: 50%;
opacity: 0.3;
filter: blur(40px);
z-index: -1;
}
.shape:nth-child(1) {
width: 300px;
height: 300px;
background: #ff7e5f;
top: 10%;
left: 5%;
animation: float 25s infinite linear;
}
.shape:nth-child(2) {
width: 400px;
height: 400px;
background: #86a8e7;
bottom: 10%;
right: 5%;
animation: float 30s infinite linear reverse;
}
.shape:nth-child(3) {
width: 200px;
height: 200px;
background: #91eae4;
top: 40%;
right: 20%;
animation: float 20s infinite linear;
}
@keyframes float {
0% {
transform: translate(0, 0) rotate(0deg);
}
25% {
transform: translate(20px, 30px) rotate(90deg);
}
50% {
transform: translate(0, 60px) rotate(180deg);
}
75% {
transform: translate(-20px, 30px) rotate(270deg);
}
100% {
transform: translate(0, 0) rotate(360deg);
}
}
@keyframes pulse {
0% {
text-shadow: 0 0 20px rgba(134, 168, 231, 0.3);
}
50% {
text-shadow: 0 0 30px rgba(134, 168, 231, 0.7), 0 0 60px rgba(134, 168, 231, 0.5);
}
100% {
text-shadow: 0 0 20px rgba(134, 168, 231, 0.3);
}
}
@media (max-width: 768px) {
h1 {
font-size: 2.5rem;
}
.visual-canvas {
height: 350px;
}
.controls {
flex-direction: column;
align-items: center;
}
}
</style>
</head>
<body>
<div class="shape"></div>
<div class="shape"></div>
<div class="shape"></div>
<div class="container">
<header>
<h1><i class="fas fa-magic"></i> Mesmerizing Visual Generator</h1>
<p class="subtitle">Experience dynamic particle animations with interactive controls. Adjust parameters to create your own unique visual masterpiece.</p>
</header>
<div class="visual-canvas" id="canvas">
<!-- Particles will be generated here -->
</div>
<div class="controls">
<div class="control-group">
<label for="particleCount"><i class="fas fa-shapes"></i> Particle Count</label>
<input type="range" id="particleCount" min="20" max="300" value="100">
</div>
<div class="control-group">
<label for="particleSize"><i class="fas fa-expand"></i> Particle Size</label>
<input type="range" id="particleSize" min="1" max="20" value="4">
</div>
<div class="control-group">
<label for="speed"><i class="fas fa-tachometer-alt"></i> Speed</label>
<input type="range" id="speed" min="1" max="10" value="5">
</div>
<div class="control-group">
<label for="colorMode"><i class="fas fa-palette"></i> Color Mode</label>
<select id="colorMode">
<option value="rainbow">Rainbow</option>
<option value="fire">Fire</option>
<option value="ocean">Ocean</option>
<option value="monochrome">Monochrome</option>
</select>
</div>
<button id="resetBtn" class="btn"><i class="fas fa-sync-alt"></i> Reset</button>
</div>
<div class="footer">
<p>Created with HTML, CSS & JavaScript</p>
<i class="fas fa-heart"></i>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
let particles = [];
let animationId;
// Get control elements
const particleCountSlider = document.getElementById('particleCount');
const particleSizeSlider = document.getElementById('particleSize');
const speedSlider = document.getElementById('speed');
const colorModeSelect = document.getElementById('colorMode');
const resetBtn = document.getElementById('resetBtn');
// Set canvas size
function setCanvasSize() {
canvas.width = canvas.clientWidth;
canvas.height = canvas.clientHeight;
}
setCanvasSize();
window.addEventListener('resize', setCanvasSize);
// Particle class
class Particle {
constructor() {
this.reset();
this.size = Math.random() * parseInt(particleSizeSlider.value) + 2;
}
reset() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.vx = (Math.random() - 0.5) * parseInt(speedSlider.value);
this.vy = (Math.random() - 0.5) * parseInt(speedSlider.value);
this.size = Math.random() * parseInt(particleSizeSlider.value) + 2;
this.color = this.getColor();
this.life = Math.random() * 300 + 100;
this.maxLife = this.life;
}
getColor() {
const colorMode = colorModeSelect.value;
switch(colorMode) {
case 'rainbow':
const hue = (Math.sin(Date.now() * 0.001 + this.x * 0.01) * 0.5 + 0.5) * 360;
return `hsl(${hue}, 100%, 70%)`;
case 'fire':
const r = Math.floor(Math.random() * 155 + 100);
const g = Math.floor(Math.random() * 60);
const b = Math.floor(Math.random() * 20);
return `rgb(${r}, ${g}, ${b})`;
case 'ocean':
const r2 = Math.floor(Math.random() * 50);
const g2 = Math.floor(Math.random() * 100 + 100);
const b2 = Math.floor(Math.random() * 155 + 100);
return `rgb(${r2}, ${g2}, ${b2})`;
case 'monochrome':
const brightness = Math.floor(Math.random() * 155 + 100);
return `rgb(${brightness}, ${brightness}, ${brightness})`;
default:
return '#ffffff';
}
}
update() {
this.x += this.vx;
this.y += this.vy;
this.life--;
// Bounce off edges
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
// Apply some randomness
this.vx += (Math.random() - 0.5) * 0.2;
this.vy += (Math.random() - 0.5) * 0.2;
// Limit speed
const speedLimit = parseInt(speedSlider.value) * 2;
const currentSpeed = Math.sqrt(this.vx * this.vx + this.vy * this.vy);
if (currentSpeed > speedLimit) {
this.vx = (this.vx / currentSpeed) * speedLimit;
this.vy = (this.vy / currentSpeed) * speedLimit;
}
// Fade out as life decreases
this.opacity = this.life / this.maxLife;
// Reset if life is over
if (this.life <= 0) {
this.reset();
}
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = this.color;
ctx.globalAlpha = this.opacity;
ctx.fill();
ctx.closePath();
}
}
// Initialize particles
function initParticles() {
particles = [];
const count = parseInt(particleCountSlider.value);
for (let i = 0; i < count; i++) {
particles.push(new Particle());
}
}
// Animation loop
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw particles
particles.forEach(particle => {
particle.update();
particle.draw();
});
// Draw connections between particles
drawConnections();
animationId = requestAnimationFrame(animate);
}
// Draw connections between nearby particles
function drawConnections() {
const maxDistance = 150;
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 < maxDistance) {
const opacity = 1 - distance / maxDistance;
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
// Blend particle colors for connection
const gradient = ctx.createLinearGradient(
particles[i].x, particles[i].y,
particles[j].x, particles[j].y
);
gradient.addColorStop(0, particles[i].color);
gradient.addColorStop(1, particles[j].color);
ctx.strokeStyle = gradient;
ctx.globalAlpha = opacity * 0.4;
ctx.lineWidth = 0.5;
ctx.stroke();
}
}
}
ctx.globalAlpha = 1;
}
// Event listeners for controls
particleCountSlider.addEventListener('input', () => {
const currentCount = particles.length;
const newCount = parseInt(particleCountSlider.value);
if (newCount > currentCount) {
// Add new particles
for (let i = 0; i < newCount - currentCount; i++) {
particles.push(new Particle());
}
} else if (newCount < currentCount) {
// Remove particles
particles.splice(newCount, currentCount - newCount);
}
});
particleSizeSlider.addEventListener('input', () => {
particles.forEach(p => {
p.size = Math.random() * parseInt(particleSizeSlider.value) + 2;
});
});
speedSlider.addEventListener('input', () => {
particles.forEach(p => {
p.vx = (Math.random() - 0.5) * parseInt(speedSlider.value);
p.vy = (Math.random() - 0.5) * parseInt(speedSlider.value);
});
});
colorModeSelect.addEventListener('change', () => {
particles.forEach(p => {
p.color = p.getColor();
});
});
resetBtn.addEventListener('click', () => {
// Reset sliders to default values
particleCountSlider.value = 100;
particleSizeSlider.value = 4;
speedSlider.value = 5;
colorModeSelect.value = 'rainbow';
// Reinitialize particles
initParticles();
});
// Mouse interaction
canvas.addEventListener('mousemove', (e) => {
const rect = canvas.getBoundingClientRect();
const mouseX = e.clientX - rect.left;
const mouseY = e.clientY - rect.top;
particles.forEach(p => {
const dx = p.x - mouseX;
const dy = p.y - mouseY;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 100) {
const force = (100 - distance) * 0.02;
p.vx += (dx / distance) * force;
p.vy += (dy / distance) * force;
}
});
});
// Initialize and start animation
initParticles();
animate();
});
</script>
</body>
</html>
To interact with the visualization, simply move your mouse over the canvas to influence particle movement. Use the sliders to adjust different parameters and see the changes in real-time. Click the reset button to restore default settings.
The particles will automatically create beautiful connections with each other, forming an ever-changing network of light and color.