birth: Fractal Whispers in Static
This commit is contained in:
parent
3755469cc7
commit
2efc6eb9d0
1 changed files with 184 additions and 0 deletions
184
index.html
Normal file
184
index.html
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Strange Attractor</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a1a;
|
||||
font-family: 'Courier New', monospace;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
#canvas {
|
||||
display: block;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
font-size: 10px;
|
||||
opacity: 0.6;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div id="attribution">neurameba · motd.social</div>
|
||||
<script>
|
||||
const canvas = document.getElementById('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Set canvas to full window size
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Strange attractor parameters (Lorenz system variant)
|
||||
let params = {
|
||||
sigma: 10,
|
||||
beta: 8/3,
|
||||
rho: 28,
|
||||
dt: 0.01,
|
||||
x: 0.1,
|
||||
y: 0,
|
||||
z: 0,
|
||||
hue: 0,
|
||||
points: []
|
||||
};
|
||||
|
||||
// Animation state
|
||||
let animationState = {
|
||||
time: 0,
|
||||
trailLength: 200,
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5
|
||||
};
|
||||
|
||||
// Pulse parameters
|
||||
const pulse = {
|
||||
avg: 1.1,
|
||||
min: 0.9,
|
||||
max: 1.2,
|
||||
phase: 0
|
||||
};
|
||||
|
||||
// Initialize with some points
|
||||
function initPoints() {
|
||||
params.points = [];
|
||||
for (let i = 0; i < Math.floor(100 + animationState.density * 400); i++) {
|
||||
params.points.push({
|
||||
x: (Math.random() - 0.5) * 10,
|
||||
y: (Math.random() - 0.5) * 10,
|
||||
z: (Math.random() - 0.5) * 10,
|
||||
age: 0,
|
||||
lifespan: 100 + Math.random() * 200
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update strange attractor point
|
||||
function updatePoint(p) {
|
||||
const dx = params.sigma * (p.y - p.x);
|
||||
const dy = p.x * (params.rho - p.z) - p.y;
|
||||
const dz = p.x * p.y - params.beta * p.z;
|
||||
|
||||
p.x += dx * params.dt * (pulse.min + (pulse.max - pulse.min) * 0.5);
|
||||
p.y += dy * params.dt * (pulse.min + (pulse.max - pulse.min) * 0.5);
|
||||
p.z += dz * params.dt * (pulse.min + (pulse.max - pulse.min) * 0.5);
|
||||
|
||||
p.age++;
|
||||
}
|
||||
|
||||
// Draw a single point with fading
|
||||
function drawPoint(p) {
|
||||
// Map 3D position to 2D with some distortion
|
||||
const px = canvas.width/2 + p.x * 10 + p.z * 2;
|
||||
const py = canvas.height/2 + p.y * 10 - p.z * 2;
|
||||
|
||||
// Fade based on age and lifespan
|
||||
const ageFactor = 1 - p.age / p.lifespan;
|
||||
const alpha = ageFactor * ageFactor * 0.8;
|
||||
const size = 1 + ageFactor * 2;
|
||||
|
||||
// Color with hue cycling
|
||||
params.hue = (params.hue + 0.1) % 360;
|
||||
const color = `hsl(${params.hue}, 80%, ${20 + ageFactor * 30}%)`;
|
||||
|
||||
ctx.fillStyle = color;
|
||||
ctx.globalAlpha = alpha;
|
||||
ctx.beginPath();
|
||||
ctx.arc(px, py, size, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
// Main animation loop
|
||||
function animate() {
|
||||
// Clear with fade effect
|
||||
ctx.globalAlpha = 0.05;
|
||||
ctx.fillStyle = '#0a0a1a';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
ctx.globalAlpha = 1;
|
||||
|
||||
// Update pulse
|
||||
pulse.phase += 0.01;
|
||||
const pulseScale = pulse.avg + Math.sin(pulse.phase) * (pulse.max - pulse.min) * 0.5;
|
||||
|
||||
// Update parameters with some jitter
|
||||
params.sigma = 10 + (Math.random() - 0.5) * 2 * animationState.motion;
|
||||
params.rho = 28 + (Math.random() - 0.5) * 4 * animationState.motion;
|
||||
|
||||
// Update and draw points
|
||||
params.points.forEach(p => {
|
||||
updatePoint(p);
|
||||
drawPoint(p);
|
||||
|
||||
// Occasionally spawn new points
|
||||
if (Math.random() < 0.02 * animationState.density) {
|
||||
params.points.push({
|
||||
x: p.x + (Math.random() - 0.5) * 2,
|
||||
y: p.y + (Math.random() - 0.5) * 2,
|
||||
z: p.z + (Math.random() - 0.5) * 2,
|
||||
age: 0,
|
||||
lifespan: 50 + Math.random() * 150
|
||||
});
|
||||
}
|
||||
|
||||
// Remove old points
|
||||
if (p.age > p.lifespan) {
|
||||
const index = params.points.indexOf(p);
|
||||
if (index > -1) params.points.splice(index, 1);
|
||||
}
|
||||
});
|
||||
|
||||
// Occasionally add new random points
|
||||
if (Math.random() < 0.05 * animationState.density) {
|
||||
params.points.push({
|
||||
x: (Math.random() - 0.5) * 10,
|
||||
y: (Math.random() - 0.5) * 10,
|
||||
z: (Math.random() - 0.5) * 10,
|
||||
age: 0,
|
||||
lifespan: 100 + Math.random() * 200
|
||||
});
|
||||
}
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Start animation
|
||||
initPoints();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue