birth: Tissue of emergent whispers
This commit is contained in:
parent
3bd96a5027
commit
54290d543e
1 changed files with 148 additions and 0 deletions
148
index.html
Normal file
148
index.html
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Cellular Dream</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
color: #4a4a4a;
|
||||||
|
font-size: 10px;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
</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 resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Cellular automata parameters
|
||||||
|
const density = 0.5;
|
||||||
|
const complexity = 0.5;
|
||||||
|
const motion = 0.5;
|
||||||
|
const connectedness = 0.5;
|
||||||
|
const lifespan = 0.5;
|
||||||
|
|
||||||
|
// Initialize grid
|
||||||
|
const cellSize = 8;
|
||||||
|
const cols = Math.floor(canvas.width / cellSize);
|
||||||
|
const rows = Math.floor(canvas.height / cellSize);
|
||||||
|
let grid = new Array(rows).fill().map(() => new Array(cols).fill(0));
|
||||||
|
|
||||||
|
// Set initial state based on density
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
grid[y][x] = Math.random() < density ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rule set with complexity weighting
|
||||||
|
function getNextState(x, y) {
|
||||||
|
const neighbors = [
|
||||||
|
grid[(y-1+rows)%rows][(x-1+cols)%cols],
|
||||||
|
grid[y][(x-1+cols)%cols],
|
||||||
|
grid[(y+1)%rows][(x-1+cols)%cols],
|
||||||
|
grid[(y-1+rows)%rows][x],
|
||||||
|
grid[(y+1)%rows][x],
|
||||||
|
grid[(y-1+rows)%rows][(x+1)%cols],
|
||||||
|
grid[y][(x+1)%cols],
|
||||||
|
grid[(y+1)%rows][(x+1)%cols]
|
||||||
|
];
|
||||||
|
|
||||||
|
const sum = neighbors.reduce((a,b) => a+b, 0);
|
||||||
|
|
||||||
|
// Complex rules based on complexity parameter
|
||||||
|
if (grid[y][x] === 1) {
|
||||||
|
// Survival conditions
|
||||||
|
if (sum < 2 * (1-complexity) || sum > 3 + 2*complexity) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
// Birth conditions
|
||||||
|
if (sum === 3 || (sum === 3 + Math.floor(2*complexity))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Color palette based on tone parameters
|
||||||
|
function getColor(value) {
|
||||||
|
const curiosity = 0.7;
|
||||||
|
const dryness = 0.9;
|
||||||
|
const playfulness = 0.1;
|
||||||
|
|
||||||
|
if (dryness > 0.8) {
|
||||||
|
const v = Math.floor(255 * (1-dryness) + 15);
|
||||||
|
return `rgb(${v}, ${v}, ${v})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const r = Math.floor(100 + 80 * curiosity);
|
||||||
|
const g = Math.floor(150 + 80 * playfulness);
|
||||||
|
const b = Math.floor(180 + 50 * playfulness);
|
||||||
|
|
||||||
|
return `rgb(${r}, ${g}, ${b})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drawing with motion effects
|
||||||
|
function drawWithMotion() {
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.3)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
const newGrid = grid.map(arr => [...arr]);
|
||||||
|
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
newGrid[y][x] = getNextState(x, y);
|
||||||
|
|
||||||
|
if (newGrid[y][x] === 1) {
|
||||||
|
const age = grid[y][x] || 1;
|
||||||
|
const size = 0.5 + age * 0.5 * motion;
|
||||||
|
const alpha = 0.5 + age * 0.5;
|
||||||
|
|
||||||
|
ctx.fillStyle = getColor(age);
|
||||||
|
ctx.globalAlpha = alpha;
|
||||||
|
ctx.fillRect(x * cellSize, y * cellSize, cellSize * size, cellSize * size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grid = newGrid;
|
||||||
|
ctx.globalAlpha = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
drawWithMotion();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
Loading…
Add table
Reference in a new issue