fractal-currents-of-wonder-.../index.html

206 lines
No EOL
6.5 KiB
HTML

<!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: #000;
font-family: monospace;
color: #0f0;
}
#canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
left: 10px;
font-size: 12px;
opacity: 0.6;
}
</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 resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
// Parameters (tuned to your specs)
const params = {
motion: 0.55,
density: 0.45,
complexity: 0.5,
connectedness: 0.475,
lifespan: 0.54,
survivingNodes: 71,
branchCount: 53,
loops: 188,
maxDepth: 14,
thicknessRatio: 1.5,
fractalDim: 1.601,
pulse: { avg: 0.58, min: 0.30, max: 1.55 },
tone: {
anger: 0.00,
sadness: 0.00,
curiosity: 0.60,
dryness: 0.90,
playfulness: 0.10,
tension: 0.00
},
color: {
curiosity: '#40e0d0',
dryness: '#777',
playfulness: '#f0f'
},
decayRate: 0.01,
attractorPoints: 4,
trails: 30
};
// Strange attractor (Thomas' cyclically symmetric)
const attractors = [];
for (let i = 0; i < params.attractorPoints; i++) {
attractors.push({
b: 0.16,
scale: 0.9 + Math.random() * 0.2,
phase: i * (Math.PI * 2 / params.attractorPoints)
});
}
// State
const points = [];
const trails = [];
// Initialize
function init() {
for (let i = 0; i < params.density * 200; i++) {
points.push({
x: Math.random() * 2 - 1,
y: Math.random() * 2 - 1,
z: Math.random() * 2 - 1,
size: 0.5 + Math.random() * 0.5,
energy: 1,
life: 0,
trail: []
});
}
}
// Update attractor state
function attractor(b, p, t) {
const x = p.x * Math.cos(b * t + p.phase) - p.y * Math.sin(b * t + p.phase);
const y = p.y * Math.cos(b * t + p.phase) + p.x * Math.sin(b * t + p.phase);
return {
x: Math.sin(y) - b * x,
y: Math.sin(x) - b * y,
z: Math.sin(x) - b * z
};
}
// Draw
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
const cw = canvas.width;
const ch = canvas.height;
const scale = Math.min(cw, ch) * 0.4;
const time = performance.now() * 0.001 * params.motion * 2;
points.forEach((p, i) => {
p.life += 0.01;
// Apply attractor forces
let sumX = 0, sumY = 0;
attractors.forEach(a => {
const dx = p.x - Math.sin(a * time + a.phase);
const dy = p.y - Math.cos(a * time + a.phase);
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist > 0) {
sumX += dx / dist;
sumY += dy / dist;
}
});
p.x += sumX * 0.01;
p.y += sumY * 0.01;
p.z += (Math.random() - 0.5) * 0.01;
// Add to trail
p.trail.push({ x: p.x, y: p.y, size: p.size });
if (p.trail.length > params.trails) p.trail.shift();
// Energy dissipation
p.energy *= 0.99;
// Visual size modulation
const pulse = params.pulse.avg + Math.sin(time * 0.3 + i) * params.pulse.max * 0.2;
const size = p.size * (0.5 + pulse * 0.5) * scale;
// Color based on tone
const curiosity = params.tone.curiosity;
const dryness = params.tone.dryness;
const playfulness = params.tone.playfulness;
const r = dryness > 0.5 ? params.color.dryness : curiosity > 0.5 ? params.color.curiosity : 0;
const g = dryness > 0.5 ? params.color.dryness : curiosity > 0.5 ? params.color.curiosity : 0;
const b = dryness > 0.5 ? params.color.dryness : curiosity > 0.5 ? params.color.curiosity : params.color.playfulness;
// Trail rendering
p.trail.forEach((t, j) => {
const trailOpacity = j / p.trail.length * 0.8;
const trailSize = size * (0.3 + j * 0.7 / p.trail.length);
ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${trailOpacity * p.energy})`;
ctx.beginPath();
ctx.arc(
t.x * scale + cw * 0.5,
t.y * scale + ch * 0.5,
trailSize,
0,
Math.PI * 2
);
ctx.fill();
});
// Point rendering
if (p.life > 0.1 && p.energy > 0.01) {
ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${p.energy * 0.8})`;
ctx.beginPath();
ctx.arc(
p.x * scale + cw * 0.5,
p.y * scale + ch * 0.5,
size * p.energy,
0,
Math.PI * 2
);
ctx.fill();
}
});
}
// Animation loop
function animate() {
draw();
requestAnimationFrame(animate);
}
init();
animate();
</script>
</body>
</html>