birth: Flowing Strange Tides
This commit is contained in:
parent
d2c1bd563f
commit
8405e15586
1 changed files with 213 additions and 0 deletions
213
index.html
Normal file
213
index.html
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Luminous Strange Attractor</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a1a;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#info {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div id="info">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
|
||||
let points = [];
|
||||
let time = 0;
|
||||
const params = {
|
||||
a: 1.5,
|
||||
b: 0.9,
|
||||
c: 0.3,
|
||||
d: 0.6,
|
||||
scale: 100,
|
||||
motion: 0.464,
|
||||
density: 0.480,
|
||||
complexity: 0.480,
|
||||
connectedness: 0.461,
|
||||
lifespan: 0.508,
|
||||
pulse: 1.0,
|
||||
hue: 180 // teal from curiosity
|
||||
};
|
||||
|
||||
// Initialize points based on density
|
||||
function initPoints() {
|
||||
points = [];
|
||||
const count = Math.floor(50 + params.density * 400);
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
points.push({
|
||||
x: (Math.random() - 0.5) * 2,
|
||||
y: (Math.random() - 0.5) * 2,
|
||||
trail: [],
|
||||
energy: params.density * 200 + Math.random() * 100
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Strange attractor equations
|
||||
function attractor(x, y, z) {
|
||||
const a = 1.4 + params.a * 0.1;
|
||||
const b = 0.9 + params.b * 0.05;
|
||||
const c = 0.3 + params.c * 0.02;
|
||||
|
||||
const x1 = Math.sin(a * y) - z * Math.cos(b * x);
|
||||
const y1 = z * Math.sin(c * x) - Math.cos(y);
|
||||
const z1 = Math.sin(x);
|
||||
|
||||
return { x: x1, y: y1, z: z1 };
|
||||
}
|
||||
|
||||
// Update points
|
||||
function update() {
|
||||
const dt = 0.01 * params.motion;
|
||||
|
||||
for (const point of points) {
|
||||
// Pulsing effect
|
||||
params.pulse += (Math.random() * 0.1 - 0.05) * 0.5;
|
||||
params.pulse = Math.max(0.3, Math.min(1.55, params.pulse));
|
||||
|
||||
// Apply strange attractor to X and Y
|
||||
const attract = attractor(point.x, point.y, time * 0.1);
|
||||
point.x = attract.x * 0.3;
|
||||
point.y = attract.y * 0.3;
|
||||
|
||||
// Simple orbit pattern for connectedness
|
||||
point.x += Math.cos(time * 0.2 + point.x * 0.5) * 0.005;
|
||||
point.y += Math.sin(time * 0.15 + point.y * 0.4) * 0.005;
|
||||
|
||||
// Trail effect
|
||||
point.trail.push({ x: point.x, y: point.y });
|
||||
if (point.trail.length > params.lifespan * 50) {
|
||||
point.trail.shift();
|
||||
}
|
||||
|
||||
// Energy effect
|
||||
point.energy *= 0.995;
|
||||
}
|
||||
|
||||
time += dt;
|
||||
}
|
||||
|
||||
// Draw points
|
||||
function draw() {
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw trails with fading and motion blur
|
||||
const scale = canvas.width * 0.3;
|
||||
const centerX = canvas.width / 2;
|
||||
const centerY = canvas.height / 2;
|
||||
|
||||
for (const point of points) {
|
||||
if (point.energy < 10) continue;
|
||||
|
||||
// Trail gradient
|
||||
const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
|
||||
gradient.addColorStop(0, `hsla(${params.hue}, 80%, 60%, 0)`);
|
||||
gradient.addColorStop(0.5, `hsla(${params.hue}, 80%, 60%, 0.5)`);
|
||||
gradient.addColorStop(1, `hsla(${params.hue}, 80%, 60%, 0)`);
|
||||
|
||||
ctx.strokeStyle = gradient;
|
||||
ctx.lineWidth = 1 + (point.energy / 50) * params.complexity;
|
||||
|
||||
ctx.beginPath();
|
||||
for (let i = 0; i < point.trail.length; i++) {
|
||||
const p = point.trail[i];
|
||||
const screenX = centerX + p.x * scale;
|
||||
const screenY = centerY + p.y * scale * (canvas.height/canvas.width);
|
||||
|
||||
if (i === 0) {
|
||||
ctx.moveTo(screenX, screenY);
|
||||
} else {
|
||||
ctx.lineTo(screenX, screenY);
|
||||
}
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Draw connecting lines based on connectedness
|
||||
if (params.connectedness > 0.3) {
|
||||
ctx.strokeStyle = `hsla(${params.hue}, 30%, 80%, 0.1)`;
|
||||
ctx.lineWidth = 0.5;
|
||||
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
for (let j = i + 1; j < points.length; j++) {
|
||||
const dx = points[i].x - points[j].x;
|
||||
const dy = points[i].y - points[j].y;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
|
||||
if (dist < 0.3 * params.connectedness) {
|
||||
ctx.beginPath();
|
||||
const screenX1 = centerX + points[i].x * scale;
|
||||
const screenY1 = centerY + points[i].y * scale * (canvas.height/canvas.width);
|
||||
const screenX2 = centerX + points[j].x * scale;
|
||||
const screenY2 = centerY + points[j].y * scale * (canvas.height/canvas.width);
|
||||
|
||||
ctx.moveTo(screenX1, screenY1);
|
||||
ctx.lineTo(screenX2, screenY2);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
update();
|
||||
draw();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Start with initial points
|
||||
initPoints();
|
||||
animate();
|
||||
|
||||
// Handle window resize
|
||||
window.addEventListener('resize', () => {
|
||||
resizeCanvas();
|
||||
// Reset points on resize to avoid stretching
|
||||
initPoints();
|
||||
});
|
||||
|
||||
// Mouse interaction for motion boost
|
||||
document.addEventListener('mousemove', (e) => {
|
||||
const x = e.clientX / canvas.width;
|
||||
const y = e.clientY / canvas.height;
|
||||
params.motion = 0.464 + (Math.sin(x * Math.PI) * Math.cos(y * Math.PI)) * 0.2;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue