birth: Chaotic Whispering Fields
This commit is contained in:
parent
75591af430
commit
68018e90ef
1 changed files with 159 additions and 0 deletions
159
index.html
Normal file
159
index.html
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Strange Attractor</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #0a0a0a;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: rgba(255, 255, 255, 0.5);
|
||||||
|
font-size: 10px;
|
||||||
|
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');
|
||||||
|
|
||||||
|
function resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
motion: 0.472,
|
||||||
|
density: 0.502,
|
||||||
|
complexity: 0.481,
|
||||||
|
connectedness: 0.541,
|
||||||
|
lifespan: 0.495,
|
||||||
|
pulse: { avg: 0.63, min: 0.30, max: 1.65 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const colors = {
|
||||||
|
background: '#0a0a0a',
|
||||||
|
base: '#5a6f7a',
|
||||||
|
highlight: '#a8c3d8',
|
||||||
|
accent: '#4a8a9a'
|
||||||
|
};
|
||||||
|
|
||||||
|
// Strange attractor parameters (Lorenz-like system with noise)
|
||||||
|
const attractor = {
|
||||||
|
a: 10 * params.motion + 5,
|
||||||
|
b: 28 * (1 - params.connectedness),
|
||||||
|
c: 8.0 / 3.0,
|
||||||
|
scale: 5 * (1 + params.density),
|
||||||
|
offsetX: canvas.width / 2,
|
||||||
|
offsetY: canvas.height / 2,
|
||||||
|
rotation: 0,
|
||||||
|
noiseScale: params.complexity * 0.3,
|
||||||
|
timeStep: 0.01 * (0.5 + params.motion)
|
||||||
|
};
|
||||||
|
|
||||||
|
let points = [];
|
||||||
|
const pointCount = 5000 * params.density;
|
||||||
|
let trails = [];
|
||||||
|
|
||||||
|
// Initialize points in a small cluster
|
||||||
|
for (let i = 0; i < pointCount; i++) {
|
||||||
|
trails.push({
|
||||||
|
history: [],
|
||||||
|
maxLength: 50 + Math.floor(params.lifespan * 100),
|
||||||
|
energy: params.pulse.avg,
|
||||||
|
hue: 180 + (Math.random() * 60),
|
||||||
|
saturation: 50 + Math.random() * 50,
|
||||||
|
lightness: 40 + Math.random() * 20
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateAttractor() {
|
||||||
|
attractor.rotation += params.motion * 0.002;
|
||||||
|
attractor.offsetX = canvas.width / 2 + Math.sin(Date.now() * 0.0005) * 100;
|
||||||
|
attractor.offsetY = canvas.height / 2 + Math.cos(Date.now() * 0.0003) * 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
function attractorStep(x, y, z) {
|
||||||
|
const dt = attractor.timeStep;
|
||||||
|
const a = attractor.a;
|
||||||
|
const b = attractor.b;
|
||||||
|
const c = attractor.c;
|
||||||
|
|
||||||
|
const dx = a * (y - x) * dt;
|
||||||
|
const dy = (x * (b - z) - y) * dt;
|
||||||
|
const dz = (x * y - c * z) * dt;
|
||||||
|
|
||||||
|
const noiseX = (Math.random() - 0.5) * attractor.noiseScale;
|
||||||
|
const noiseY = (Math.random() - 0.5) * attractor.noiseScale;
|
||||||
|
const noiseZ = (Math.random() - 0.5) * attractor.noiseScale;
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: x + dx + noiseX,
|
||||||
|
y: y + dy + noiseY,
|
||||||
|
z: z + dz + noiseZ
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
ctx.fillStyle = colors.background;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
updateAttractor();
|
||||||
|
|
||||||
|
trails.forEach((trail, i) => {
|
||||||
|
const x0 = canvas.width * 0.3 + Math.sin(i * 0.1) * canvas.width * 0.7;
|
||||||
|
const y0 = canvas.height * 0.3 + Math.cos(i * 0.13) * canvas.height * 0.7;
|
||||||
|
const z0 = Date.now() * 0.001 + i * 0.1;
|
||||||
|
|
||||||
|
const newPoint = attractorStep(x0, y0, z0);
|
||||||
|
|
||||||
|
trail.history.push({ x: newPoint.x, y: newPoint.y });
|
||||||
|
if (trail.history.length > trail.maxLength) {
|
||||||
|
trail.history.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw trail with decreasing opacity
|
||||||
|
const opacity = 1 - trail.history.length / trail.maxLength;
|
||||||
|
ctx.strokeStyle = `hsla(${trail.hue}, ${trail.saturation}%, ${trail.lightness}%, ${opacity * 0.8})`;
|
||||||
|
ctx.lineWidth = 1 + trail.energy * 0.5;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
trail.history.forEach((point, j) => {
|
||||||
|
const px = attractor.offsetX + point.x * attractor.scale;
|
||||||
|
const py = attractor.offsetY + point.y * attractor.scale;
|
||||||
|
if (j === 0) {
|
||||||
|
ctx.moveTo(px, py);
|
||||||
|
} else {
|
||||||
|
ctx.lineTo(px, py);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
|
||||||
|
requestAnimationFrame(draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
draw();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue