birth: Tidal Pools of Static
This commit is contained in:
parent
f2371f6608
commit
1d046ede77
1 changed files with 186 additions and 0 deletions
186
index.html
Normal file
186
index.html
Normal file
|
|
@ -0,0 +1,186 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Tidal Pools</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 10px;
|
||||||
|
font-size: 10px;
|
||||||
|
opacity: 0.6;
|
||||||
|
text-shadow: 0 0 5px rgba(255,255,255,0.3);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="canvas"></canvas>
|
||||||
|
<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();
|
||||||
|
|
||||||
|
// Voronoi system parameters
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
pulse: 1.2, // Average pulse value
|
||||||
|
pulseVariation: 0.15,
|
||||||
|
hue: 0, // Dryness tones (monochrome)
|
||||||
|
saturation: 0,
|
||||||
|
brightness: 0.7,
|
||||||
|
trailLength: 20,
|
||||||
|
maxRadius: 20,
|
||||||
|
minRadius: 5,
|
||||||
|
connectionThreshold: 0.4
|
||||||
|
};
|
||||||
|
|
||||||
|
// Voronoi point system
|
||||||
|
class VoronoiSystem {
|
||||||
|
constructor(width, height, pointCount) {
|
||||||
|
this.points = [];
|
||||||
|
this.edges = [];
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.pointCount = pointCount;
|
||||||
|
this.age = 0;
|
||||||
|
this.initPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
initPoints() {
|
||||||
|
for (let i = 0; i < this.pointCount; i++) {
|
||||||
|
this.points.push({
|
||||||
|
x: Math.random() * this.width,
|
||||||
|
y: Math.random() * this.height,
|
||||||
|
vx: (Math.random() - 0.5) * 2 * params.motion,
|
||||||
|
vy: (Math.random() - 0.5) * 2 * params.motion,
|
||||||
|
radius: params.minRadius + Math.random() * (params.maxRadius - params.minRadius),
|
||||||
|
hue: params.hue,
|
||||||
|
saturation: params.saturation,
|
||||||
|
brightness: params.brightness * (0.7 + Math.random() * 0.3),
|
||||||
|
lifetime: Math.random() * 100 + 50,
|
||||||
|
age: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.age++;
|
||||||
|
this.points.forEach(point => {
|
||||||
|
point.age++;
|
||||||
|
point.x += point.vx;
|
||||||
|
point.y += point.vy;
|
||||||
|
|
||||||
|
// Bounce off edges
|
||||||
|
if (point.x < 0 || point.x > this.width) point.vx *= -1;
|
||||||
|
if (point.y < 0 || point.y > this.height) point.vy *= -1;
|
||||||
|
|
||||||
|
// Age-based decay
|
||||||
|
const ageRatio = point.age / point.lifetime;
|
||||||
|
point.radius = params.minRadius + (params.maxRadius - params.minRadius) * (1 - ageRatio);
|
||||||
|
point.brightness = params.brightness * (0.5 + 0.5 * (1 - ageRatio));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update connections based on near points
|
||||||
|
this.updateConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConnections() {
|
||||||
|
this.edges = [];
|
||||||
|
for (let i = 0; i < this.points.length; i++) {
|
||||||
|
for (let j = i + 1; j < this.points.length; j++) {
|
||||||
|
const p1 = this.points[i];
|
||||||
|
const p2 = this.points[j];
|
||||||
|
const dx = p1.x - p2.x;
|
||||||
|
const dy = p1.y - p2.y;
|
||||||
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (distance < 200 * params.connectedness) {
|
||||||
|
this.edges.push({
|
||||||
|
p1: i,
|
||||||
|
p2: j,
|
||||||
|
distance: distance,
|
||||||
|
strength: 1 - (distance / 200) * params.connectedness
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
// Clear with fade effect
|
||||||
|
ctx.fillStyle = `rgba(0, 0, 0, 0.05)`;
|
||||||
|
ctx.fillRect(0, 0, this.width, this.height);
|
||||||
|
|
||||||
|
// Draw edges (connections)
|
||||||
|
ctx.strokeStyle = `rgba(200, 200, 200, ${0.3 * params.connectedness})`;
|
||||||
|
ctx.lineWidth = 1 * params.connectedness;
|
||||||
|
this.edges.forEach(edge => {
|
||||||
|
const p1 = this.points[edge.p1];
|
||||||
|
const p2 = this.points[edge.p2];
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(p1.x, p1.y);
|
||||||
|
ctx.lineTo(p2.x, p2.y);
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Draw points with trail
|
||||||
|
this.points.forEach(point => {
|
||||||
|
// Trail effect
|
||||||
|
const gradient = ctx.createRadialGradient(
|
||||||
|
point.x, point.y, 0,
|
||||||
|
point.x, point.y, point.radius * 2
|
||||||
|
);
|
||||||
|
gradient.addColorStop(0, `hsla(${point.hue}, ${point.saturation}%, ${point.brightness * 100}%, 0.8)`);
|
||||||
|
gradient.addColorStop(1, `hsla(${point.hue}, ${point.saturation}%, ${point.brightness * 100}%, 0)`);
|
||||||
|
|
||||||
|
ctx.fillStyle = gradient;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(point.x, point.y, point.radius * 2, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create system with adjusted density
|
||||||
|
const system = new VoronoiSystem(canvas.width, canvas.height,
|
||||||
|
Math.max(20, Math.floor(50 * params.density)));
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
system.update();
|
||||||
|
system.draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
|
||||||
|
// Resize handler
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
system.width = canvas.width;
|
||||||
|
system.height = canvas.height;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<div id="info">neurameba · motd.social</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue