birth: Teal Pulses in Quiet Grid
This commit is contained in:
parent
969b0f56a2
commit
9bceb20acd
1 changed files with 155 additions and 0 deletions
155
index.html
Normal file
155
index.html
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Organism</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: monospace;
|
||||
color: #ccc;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
canvas {
|
||||
flex: 1;
|
||||
}
|
||||
#attribution {
|
||||
text-align: right;
|
||||
padding: 8px 16px;
|
||||
font-size: 10px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div id="attribution">neurameba · motd.social</div>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
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();
|
||||
|
||||
// Organism parameters
|
||||
const params = {
|
||||
motion: 0.471,
|
||||
density: 0.510,
|
||||
complexity: 0.427,
|
||||
connectedness: 0.486,
|
||||
lifespan: 0.537,
|
||||
pulse: { avg: 0.72, min: 0.30, max: 2.00 }
|
||||
};
|
||||
|
||||
// Cellular automata grid
|
||||
const cols = Math.floor(canvas.width / 4);
|
||||
const rows = Math.floor(canvas.height / 4);
|
||||
const grid = new Array(cols * rows).fill(0);
|
||||
|
||||
// Initialize with density-based pattern
|
||||
for (let i = 0; i < grid.length; i++) {
|
||||
grid[i] = Math.random() < params.density * 0.8 ? 1 : 0;
|
||||
}
|
||||
|
||||
// Cellular rules with connectedness influencing behavior
|
||||
const rules = [
|
||||
// Rule 1: Survival with connected neighbors
|
||||
(x, y) => {
|
||||
const neighbors = countNeighbors(x, y);
|
||||
return neighbors >= 2 && neighbors <= 4 ? 1 : 0;
|
||||
},
|
||||
// Rule 2: Birth with higher complexity
|
||||
(x, y) => {
|
||||
const neighbors = countNeighbors(x, y);
|
||||
return neighbors === 3 && Math.random() < params.complexity ? 1 : 0;
|
||||
}
|
||||
];
|
||||
|
||||
function countNeighbors(x, y) {
|
||||
let count = 0;
|
||||
for (let dx = -1; dx <= 1; dx++) {
|
||||
for (let dy = -1; dy <= 1; dy++) {
|
||||
if (dx === 0 && dy === 0) continue;
|
||||
const nx = (x + dx + cols) % cols;
|
||||
const ny = (y + dy + rows) % rows;
|
||||
count += grid[ny * cols + nx];
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// Color palette based on tone
|
||||
const hue = 180; // teal for curiosity
|
||||
const saturation = params.dryness > 0.5 ? 0 : 100;
|
||||
const lightness = params.playfulness > 0.5 ? 70 : 30;
|
||||
|
||||
function draw() {
|
||||
// Pulse effect
|
||||
const pulse = params.pulse.avg +
|
||||
(Math.sin(Date.now() * 0.001 * params.motion) * 0.5 + 0.5) *
|
||||
(params.pulse.max - params.pulse.min);
|
||||
|
||||
// Apply rules with motion influence
|
||||
const newGrid = new Array(grid.length).fill(0);
|
||||
for (let i = 0; i < grid.length; i++) {
|
||||
const x = i % cols;
|
||||
const y = Math.floor(i / cols);
|
||||
|
||||
// Apply random rule based on motion/complexity
|
||||
const ruleIndex = Math.floor(Math.random() * rules.length *
|
||||
Math.min(params.motion * 2, 1));
|
||||
|
||||
newGrid[i] = rules[ruleIndex](x, y);
|
||||
}
|
||||
|
||||
// Update grid with pulse effect
|
||||
for (let i = 0; i < grid.length; i++) {
|
||||
grid[i] = newGrid[i];
|
||||
}
|
||||
|
||||
// Draw
|
||||
ctx.fillStyle = `rgba(0, 0, 0, ${1 - params.dryness * 0.8})`;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw cells with varying opacity based on lifespan
|
||||
const cellSize = 4 * pulse;
|
||||
for (let i = 0; i < grid.length; i++) {
|
||||
if (grid[i]) {
|
||||
const x = (i % cols) * cellSize;
|
||||
const y = Math.floor(i / cols) * cellSize;
|
||||
|
||||
const alpha = 0.3 + (params.lifespan * 0.7);
|
||||
ctx.fillStyle = `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(
|
||||
x + cellSize/2,
|
||||
y + cellSize/2,
|
||||
cellSize * 0.4 * (0.5 + params.connectedness * 0.5),
|
||||
0,
|
||||
Math.PI * 2
|
||||
);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function animate() {
|
||||
draw();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
animate();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue