birth: silent fractures in motion
This commit is contained in:
parent
ff70e08343
commit
a139933f7f
1 changed files with 175 additions and 0 deletions
175
index.html
Normal file
175
index.html
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>voronameba</title>
|
||||
<style>
|
||||
body { margin: 0; overflow: hidden; background: #000; }
|
||||
canvas { display: block; }
|
||||
#attribution { position: absolute; bottom: 10px; right: 10px; color: #333; font-family: monospace; font-size: 10px; }
|
||||
</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
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.12, min: 0.9, max: 1.3 }
|
||||
};
|
||||
|
||||
// Palette (dryness=monochrome, curiosity=teals)
|
||||
const palette = [
|
||||
'#f0f0f0', // light teal-like
|
||||
'#d0d0d0',
|
||||
'#a0a0a0',
|
||||
'#707070',
|
||||
'#404040'
|
||||
];
|
||||
|
||||
// Voronoi state
|
||||
const sites = [];
|
||||
const cells = [];
|
||||
let time = 0;
|
||||
let pulse = params.pulse.avg;
|
||||
|
||||
// Initialize sites
|
||||
function initSites() {
|
||||
const count = Math.floor(params.density * 200) + 50;
|
||||
sites.length = 0;
|
||||
for (let i = 0; i < count; i++) {
|
||||
sites.push({
|
||||
x: Math.random() * canvas.width,
|
||||
y: Math.random() * canvas.height,
|
||||
vx: (Math.random() - 0.5) * params.motion * 2,
|
||||
vy: (Math.random() - 0.5) * params.motion * 2,
|
||||
life: 1
|
||||
});
|
||||
}
|
||||
calculateVoronoi();
|
||||
}
|
||||
|
||||
// Basic Voronoi calculation (simplified)
|
||||
function calculateVoronoi() {
|
||||
cells.length = 0;
|
||||
for (const site of sites) {
|
||||
const cell = {
|
||||
site: site,
|
||||
points: [],
|
||||
edges: []
|
||||
};
|
||||
|
||||
// Find neighboring sites (simplified)
|
||||
const neighbors = [];
|
||||
for (const other of sites) {
|
||||
if (other !== site) {
|
||||
const dx = other.x - site.x;
|
||||
const dy = other.y - site.y;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
if (dist < 100) {
|
||||
neighbors.push(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create cell boundary points (simplified)
|
||||
for (const neighbor of neighbors) {
|
||||
const dx = neighbor.x - site.x;
|
||||
const dy = neighbor.y - site.y;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
const steps = Math.floor(dist * 0.2);
|
||||
for (let i = 0; i <= steps; i++) {
|
||||
const t = i / steps;
|
||||
cell.points.push({
|
||||
x: site.x + dx * t,
|
||||
y: site.y + dy * t
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cells.push(cell);
|
||||
}
|
||||
}
|
||||
|
||||
// Update function
|
||||
function update() {
|
||||
// Pulse effect
|
||||
pulse = params.pulse.min + (Math.sin(time * 0.001) + 1) * 0.5 *
|
||||
(params.pulse.max - params.pulse.min);
|
||||
|
||||
// Update sites
|
||||
for (const site of sites) {
|
||||
site.x += site.vx * params.motion * 0.1;
|
||||
site.y += site.vy * params.motion * 0.1;
|
||||
|
||||
// Wrap around
|
||||
if (site.x < 0) site.x = canvas.width;
|
||||
if (site.x > canvas.width) site.x = 0;
|
||||
if (site.y < 0) site.y = canvas.height;
|
||||
if (site.y > canvas.height) site.y = 0;
|
||||
}
|
||||
|
||||
// Recalculate Voronoi
|
||||
calculateVoronoi();
|
||||
time++;
|
||||
|
||||
// Fade effect
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
}
|
||||
|
||||
// Draw function
|
||||
function draw() {
|
||||
// Draw cells
|
||||
for (const cell of cells) {
|
||||
// Only draw if we have points
|
||||
if (cell.points.length > 2) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(cell.points[0].x, cell.points[0].y);
|
||||
for (let i = 1; i < cell.points.length; i++) {
|
||||
ctx.lineTo(cell.points[i].x, cell.points[i].y);
|
||||
}
|
||||
ctx.closePath();
|
||||
|
||||
// Color based on density/complexity
|
||||
const idx = Math.floor((cell.points.length / 200) * palette.length);
|
||||
ctx.fillStyle = palette[idx % palette.length];
|
||||
ctx.fill();
|
||||
|
||||
// Outline
|
||||
ctx.strokeStyle = '#111';
|
||||
ctx.lineWidth = 0.5;
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
update();
|
||||
draw();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Start
|
||||
initSites();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue