Вот полный код в одном файле index.html, который создает эффект, похожий на матрицу с использованием 15 эмодзи:
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Матрица Эмодзи</title>
<style>
body {
margin: 0;
overflow: hidden;
background: black;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#matrix-canvas {
background: black;
}
</style>
</head>
<body>
<canvas id="matrix-canvas"></canvas>
<script>
const canvas = document.getElementById('matrix-canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const emojis = ['🌟', '🚀', '💻', '🌈', '🔥', '🌊', '🌍', '💡', '🌙', '🌞', '🌸', '🍀', '🦄', '🌋', '🌠'];
const fontSize = 16;
const columns = canvas.width / fontSize;
const drops = new Array(columns).fill(1);
function drawMatrix() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'green';
ctx.font = `${fontSize}px monospace`;
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
const radius = 200;
for (let i = 0; i < drops.length; i++) {
const text = emojis[Math.floor(Math.random() * emojis.length)];
const x = i * fontSize;
const y = drops[i] * fontSize;
// Проверка попадания в круг
const dx = x - centerX;
const dy = y - centerY;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= radius) {
ctx.fillText(text, x, y);
}
if (y > canvas.height && Math.random() > 0.95) {
drops[i] = 0;
}
drops[i]++;
}
}
setInterval(drawMatrix, 50);
</script>
</body>
</html>
Этот код создает:
- Эффект падающих эмодзи, как в матрице
- Ограничение эффекта только круглой областью по центру
- Используются 15 разных эмодзи
- Анимация обновляется каждые 50 миллисекунд
- Полностью адаптивный под размер экрана
Просто сохраните код в файле index.html и откройте его в браузере.