Spaces:
Running
Running
File size: 14,366 Bytes
8644757 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Matrix Code Rain</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inconsolata:wght@400;700&display=swap');
body {
font-family: 'Inconsolata', monospace;
overflow: hidden;
background-color: #000;
margin: 0;
padding: 0;
}
.matrix-column {
position: relative;
display: inline-block;
color: #20C20E;
text-shadow: 0 0 5px #20C20E;
width: 20px;
height: 100vh;
overflow: hidden;
}
.matrix-char {
position: absolute;
opacity: 0;
animation:
fadeIn 0.1s forwards,
fall linear forwards;
}
@keyframes fadeIn {
to { opacity: 1; }
}
@keyframes fall {
to { transform: translateY(100vh); }
}
.glitch {
position: relative;
}
.glitch::before, .glitch::after {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #000;
}
.glitch::before {
left: 2px;
text-shadow: -2px 0 #ff00c1;
clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
animation: glitch-anim-1 2s infinite linear alternate-reverse;
}
.glitch::after {
left: -2px;
text-shadow: -2px 0 #00fff9;
clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%);
animation: glitch-anim-2 2s infinite linear alternate-reverse;
}
@keyframes glitch-anim-1 {
0% { transform: translateX(0); }
20% { transform: translateX(-3px); }
40% { transform: translateX(3px); }
60% { transform: translateX(-3px); }
80% { transform: translateX(3px); }
100% { transform: translateX(0); }
}
@keyframes glitch-anim-2 {
0% { transform: translateX(0); }
20% { transform: translateX(3px); }
40% { transform: translateX(-3px); }
60% { transform: translateX(3px); }
80% { transform: translateX(-3px); }
100% { transform: translateX(0); }
}
.scanline {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(
to bottom,
rgba(32, 194, 14, 0.1) 0%,
rgba(32, 194, 14, 0.1) 50%,
rgba(32, 194, 14, 0) 51%
);
background-size: 100% 8px;
animation: scanline 8s linear infinite;
pointer-events: none;
z-index: 100;
}
@keyframes scanline {
0% { transform: translateY(-100%); }
100% { transform: translateY(100%); }
}
.ripple {
position: absolute;
border-radius: 50%;
background-color: rgba(32, 194, 14, 0.7);
transform: scale(0);
opacity: 1;
pointer-events: none;
animation: ripple 1s linear;
}
@keyframes ripple {
to {
transform: scale(30);
opacity: 0;
}
}
</style>
</head>
<body class="bg-black text-green-500 h-screen w-screen flex flex-col">
<!-- Header with glitch effect -->
<header class="p-4 border-b border-green-500/20 relative overflow-hidden">
<h1 class="glitch text-3xl font-bold text-center" data-text="MATRIX CODE RAIN">MATRIX CODE RAIN</h1>
<div class="absolute top-0 left-0 w-full h-full bg-green-500/5 pointer-events-none"></div>
</header>
<!-- Main matrix display -->
<main class="flex-1 relative overflow-hidden">
<div id="matrix-container" class="h-full w-full flex justify-center items-center"></div>
<div class="scanline"></div>
</main>
<!-- Footer with controls -->
<footer class="p-4 border-t border-green-500/20 flex justify-between items-center">
<div class="flex space-x-4">
<button id="speed-up" class="px-3 py-1 bg-green-900/50 border border-green-500 rounded hover:bg-green-800/70 transition">
<span class="text-xs">SPEED +</span>
</button>
<button id="speed-down" class="px-3 py-1 bg-green-900/50 border border-green-500 rounded hover:bg-green-800/70 transition">
<span class="text-xs">SPEED -</span>
</button>
<button id="density-up" class="px-3 py-1 bg-green-900/50 border border-green-500 rounded hover:bg-green-800/70 transition">
<span class="text-xs">DENSITY +</span>
</button>
<button id="density-down" class="px-3 py-1 bg-green-900/50 border border-green-500 rounded hover:bg-green-800/70 transition">
<span class="text-xs">DENSITY -</span>
</button>
</div>
<div class="text-xs opacity-70">
<span id="fps-counter">FPS: 0</span>
</div>
<button id="toggle-matrix" class="px-3 py-1 bg-green-900/50 border border-green-500 rounded hover:bg-green-800/70 transition">
<span class="text-xs">TOGGLE MATRIX</span>
</button>
</footer>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Configuration
const config = {
columns: 80,
minChars: 5,
maxChars: 25,
speed: 2, // Lower is faster
density: 0.8,
chars: "日ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘヲイクコソチトノフヤヨルレロン0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
running: true
};
// State
let columns = [];
let lastFrameTime = 0;
let fps = 0;
let frameCount = 0;
let lastFpsUpdate = 0;
// DOM elements
const matrixContainer = document.getElementById('matrix-container');
const fpsCounter = document.getElementById('fps-counter');
// Initialize matrix
function initMatrix() {
matrixContainer.innerHTML = '';
columns = [];
// Calculate column width based on container width
const columnWidth = Math.max(20, window.innerWidth / config.columns);
for (let i = 0; i < config.columns; i++) {
const column = document.createElement('div');
column.className = 'matrix-column';
column.style.width = `${columnWidth}px`;
column.style.height = '100vh';
// Random delay for each column
column.dataset.delay = Math.random() * 2000;
column.dataset.lastUpdate = 0;
column.dataset.speed = config.speed + Math.random() * 2 - 1;
matrixContainer.appendChild(column);
columns.push(column);
// Initial characters
const initialChars = Math.floor(Math.random() * (config.maxChars - config.minChars) + config.minChars);
for (let j = 0; j < initialChars; j++) {
addCharToColumn(column, -j * 20);
}
}
}
// Add a character to a column at specific position
function addCharToColumn(column, yPos) {
const char = document.createElement('div');
char.className = 'matrix-char';
char.textContent = getRandomChar();
// Random brightness
const brightness = Math.random();
if (brightness > 0.8) {
char.style.color = '#FFFFFF';
char.style.textShadow = '0 0 8px #FFFFFF';
} else if (brightness > 0.5) {
char.style.color = '#20C20E';
char.style.textShadow = '0 0 5px #20C20E';
} else {
char.style.color = '#0A5C07';
char.style.textShadow = 'none';
}
// Set random animation duration between 2-5 seconds
const duration = 2 + Math.random() * 3;
char.style.animationDuration = `${duration}s`;
// Set initial position
char.style.left = '0';
char.style.top = `${yPos}px`;
column.appendChild(char);
// Remove character after animation completes
setTimeout(() => {
char.remove();
}, duration * 1000);
}
// Generate random matrix character
function getRandomChar() {
return config.chars.charAt(Math.floor(Math.random() * config.chars.length));
}
// Update a single column
function updateColumn(column, now) {
const lastUpdate = parseFloat(column.dataset.lastUpdate);
const speed = parseFloat(column.dataset.speed);
if (now - lastUpdate < speed * 100) return;
// Skip some updates based on density
if (Math.random() > config.density) return;
column.dataset.lastUpdate = now;
// Add new character at top
addCharToColumn(column, -20);
// Randomly reset the column
if (Math.random() < 0.005) {
const chars = column.querySelectorAll('.matrix-char');
chars.forEach(char => {
char.style.opacity = '0';
char.style.transition = 'opacity 0.5s ease';
});
}
}
// Main animation loop
function animate(now) {
if (!lastFrameTime) lastFrameTime = now;
const deltaTime = now - lastFrameTime;
lastFrameTime = now;
frameCount++;
if (now - lastFpsUpdate >= 1000) {
fps = Math.round((frameCount * 1000) / (now - lastFpsUpdate));
fpsCounter.textContent = `FPS: ${fps}`;
lastFpsUpdate = now;
frameCount = 0;
}
if (config.running) {
columns.forEach(column => updateColumn(column, now));
}
requestAnimationFrame(animate);
}
// Event listeners for controls
document.getElementById('speed-up').addEventListener('click', () => {
config.speed = Math.max(0.5, config.speed - 0.5);
});
document.getElementById('speed-down').addEventListener('click', () => {
config.speed = Math.min(5, config.speed + 0.5);
});
document.getElementById('density-up').addEventListener('click', () => {
config.density = Math.min(1, config.density + 0.1);
});
document.getElementById('density-down').addEventListener('click', () => {
config.density = Math.max(0.1, config.density - 0.1);
});
document.getElementById('toggle-matrix').addEventListener('click', () => {
config.running = !config.running;
document.getElementById('toggle-matrix').querySelector('span').textContent =
config.running ? 'TOGGLE MATRIX' : 'RESUME MATRIX';
});
// Handle window resize
window.addEventListener('resize', () => {
initMatrix();
});
// Start everything
initMatrix();
requestAnimationFrame(animate);
// Easter egg - click anywhere to create a ripple effect
document.addEventListener('click', (e) => {
const ripple = document.createElement('div');
ripple.className = 'ripple';
ripple.style.left = `${e.clientX - 10}px`;
ripple.style.top = `${e.clientY - 10}px`;
ripple.style.width = '20px';
ripple.style.height = '20px';
document.body.appendChild(ripple);
setTimeout(() => {
ripple.remove();
}, 1000);
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=MarkTheArtist/matrix-code-rain" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |