birth: Monochrome Life Veins
This commit is contained in:
parent
29ece02986
commit
cb6ad4fc62
1 changed files with 184 additions and 0 deletions
184
index.html
Normal file
184
index.html
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Motd</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
canvas {
|
||||
flex: 1;
|
||||
}
|
||||
#attribution {
|
||||
color: #333;
|
||||
text-align: center;
|
||||
padding: 8px;
|
||||
font-family: monospace;
|
||||
font-size: 11px;
|
||||
}
|
||||
</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();
|
||||
|
||||
// System parameters
|
||||
const motion = 0.5;
|
||||
const density = 0.5;
|
||||
const complexity = 0.5;
|
||||
const connectedness = 0.5;
|
||||
const lifespan = 0.5;
|
||||
const pulse = 1.08;
|
||||
|
||||
// Cellular automata grid (adaptive to density)
|
||||
const cellSize = Math.max(4, 8 - Math.floor(density * 4));
|
||||
const cols = Math.ceil(canvas.width / cellSize);
|
||||
const rows = Math.ceil(canvas.height / cellSize);
|
||||
|
||||
// State arrays
|
||||
let grid = new Array(rows).fill().map(() =>
|
||||
new Array(cols).fill().map(() =>
|
||||
Math.random() < density ? 1 : 0
|
||||
)
|
||||
);
|
||||
|
||||
let nextGrid = new Array(rows).fill().map(() => new Array(cols).fill(0));
|
||||
|
||||
// Color palette (dryness = monochrome)
|
||||
const baseHue = Math.random() * 360;
|
||||
const hueVariation = 20;
|
||||
|
||||
function getColor(value) {
|
||||
const h = (baseHue + (Math.random() * hueVariation - hueVariation/2)) % 360;
|
||||
const s = 0 + (value * 30);
|
||||
const l = 20 + (value * 30);
|
||||
return `hsl(${h}, ${s}%, ${l}%)`;
|
||||
}
|
||||
|
||||
// Cellular automata rules (Rock-Paper-Scissors variant)
|
||||
function updateGrid() {
|
||||
for (let r = 0; r < rows; r++) {
|
||||
for (let c = 0; c < cols; c++) {
|
||||
const neighbors = [
|
||||
grid[(r-1+rows)%rows][(c-1+cols)%cols],
|
||||
grid[(r-1+rows)%rows][c],
|
||||
grid[(r-1+rows)%rows][(c+1+cols)%cols],
|
||||
grid[r][(c-1+cols)%cols],
|
||||
grid[r][(c+1+cols)%cols],
|
||||
grid[(r+1+rows)%rows][(c-1+cols)%cols],
|
||||
grid[(r+1+rows)%rows][c],
|
||||
grid[(r+1+rows)%rows][(c+1+cols)%cols]
|
||||
];
|
||||
|
||||
const self = grid[r][c];
|
||||
const sum = neighbors.reduce((a, b) => a + b, 0);
|
||||
|
||||
// RPS-style rules with mutation
|
||||
if (self === 1) {
|
||||
if (sum === 2 || Math.random() < 0.1) {
|
||||
nextGrid[r][c] = 2;
|
||||
} else if (sum > 3) {
|
||||
nextGrid[r][c] = 0;
|
||||
} else {
|
||||
nextGrid[r][c] = 1;
|
||||
}
|
||||
} else if (self === 2) {
|
||||
if (sum === 3 || Math.random() < 0.1) {
|
||||
nextGrid[r][c] = 0;
|
||||
} else if (sum < 2) {
|
||||
nextGrid[r][c] = 1;
|
||||
} else {
|
||||
nextGrid[r][c] = 2;
|
||||
}
|
||||
} else { // 0
|
||||
if (sum === 3 || Math.random() < 0.05) {
|
||||
nextGrid[r][c] = 1;
|
||||
} else if (sum > 4) {
|
||||
nextGrid[r][c] = 2;
|
||||
} else {
|
||||
nextGrid[r][c] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Swap grids
|
||||
[grid, nextGrid] = [nextGrid, grid];
|
||||
}
|
||||
|
||||
// Animation variables
|
||||
let time = 0;
|
||||
const speed = 0.8 + (motion * 0.4);
|
||||
const complexityFactor = complexity * 0.7 + 0.3;
|
||||
|
||||
function animate() {
|
||||
// Pulse effect
|
||||
const pulseScale = 1 + Math.sin(time * 0.001) * 0.05 * (pulse - 1);
|
||||
canvas.style.transform = `scale(${pulseScale})`;
|
||||
canvas.style.transition = 'transform 0.1s ease';
|
||||
|
||||
// Clear with slight fade
|
||||
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw cells with some jitter based on complexity
|
||||
const jitter = complexity * 2;
|
||||
for (let r = 0; r < rows; r++) {
|
||||
for (let c = 0; c < cols; c++) {
|
||||
if (grid[r][c] !== 0) {
|
||||
const x = c * cellSize + (Math.random() - 0.5) * jitter;
|
||||
const y = r * cellSize + (Math.random() - 0.5) * jitter;
|
||||
const size = cellSize * (0.7 + grid[r][c] * 0.3);
|
||||
|
||||
ctx.fillStyle = getColor(grid[r][c]);
|
||||
ctx.beginPath();
|
||||
ctx.arc(
|
||||
x + cellSize/2,
|
||||
y + cellSize/2,
|
||||
size/2 * (0.8 + Math.sin(time * 0.002 + r + c) * 0.2),
|
||||
0,
|
||||
Math.PI * 2
|
||||
);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateGrid();
|
||||
time += speed;
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
|
||||
// Handle touch/mouse for interaction (low-complexity feature)
|
||||
canvas.addEventListener('mousemove', (e) => {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const x = Math.floor((e.clientX - rect.left) / cellSize);
|
||||
const y = Math.floor((e.clientY - rect.top) / cellSize);
|
||||
|
||||
if (x >= 0 && x < cols && y >= 0 && y < rows) {
|
||||
grid[y][x] = 1;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue