237 lines
No EOL
8.4 KiB
HTML
237 lines
No EOL
8.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Neurameba Tessellation</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background-color: #000;
|
|
color: #fff;
|
|
font-family: monospace;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
#attribution {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
left: 10px;
|
|
font-size: 10px;
|
|
opacity: 0.5;
|
|
}
|
|
</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();
|
|
|
|
// Parameters
|
|
const params = {
|
|
motion: 0.496,
|
|
density: 0.523,
|
|
complexity: 0.558,
|
|
connectedness: 0.582,
|
|
lifespan: 0.512,
|
|
survivingNodes: 91,
|
|
branchCount: 88,
|
|
loops: 1609,
|
|
maxDepth: 30,
|
|
thicknessRatio: 1.50,
|
|
fractalDimension: 0.558,
|
|
finalEnergy: 525.2,
|
|
pulse: { avg: 0.45, min: 0.30, max: 2.00 },
|
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.70, dryness: 0.90, playfulness: 0.10, tension: 0.00 }
|
|
};
|
|
|
|
// State
|
|
const state = {
|
|
cells: [],
|
|
time: 0,
|
|
lastTime: 0,
|
|
cellSize: 20 * (1 - params.density) + 5,
|
|
gridWidth: Math.ceil(window.innerWidth / (20 * (1 - params.density) + 5)),
|
|
gridHeight: Math.ceil(window.innerHeight / (20 * (1 - params.density) + 5))
|
|
};
|
|
|
|
// Initialize cells
|
|
function initCells() {
|
|
state.cells = [];
|
|
for (let y = 0; y < state.gridHeight; y++) {
|
|
for (let x = 0; x < state.gridWidth; x++) {
|
|
state.cells.push({
|
|
x: x * state.cellSize,
|
|
y: y * state.cellSize,
|
|
size: state.cellSize * 0.8,
|
|
baseSize: state.cellSize * 0.8,
|
|
angle: 0,
|
|
targetAngle: 0,
|
|
growth: 0,
|
|
targetGrowth: Math.random() * 0.3 + 0.2,
|
|
color: `hsl(180, 30%, ${50 + Math.random() * 20}%)`,
|
|
connections: [],
|
|
energy: params.finalEnergy * Math.random(),
|
|
pulse: params.pulse.avg + (Math.random() * 2 - 1) * 0.2
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
// Create connections
|
|
function createConnections() {
|
|
state.cells.forEach(cell => {
|
|
// Connect to nearby cells
|
|
const nearbyCells = state.cells.filter(c =>
|
|
c !== cell &&
|
|
Math.abs(c.x - cell.x) < state.cellSize * 2 &&
|
|
Math.abs(c.y - cell.y) < state.cellSize * 2
|
|
);
|
|
|
|
// Create connections based on density and connectedness
|
|
const connectionCount = Math.floor(params.connectedness * 3 * params.density);
|
|
for (let i = 0; i < connectionCount && nearbyCells.length > 0; i++) {
|
|
const target = nearbyCells[Math.floor(Math.random() * nearbyCells.length)];
|
|
if (!cell.connections.includes(target)) {
|
|
cell.connections.push(target);
|
|
// Add reverse connection with lower probability
|
|
if (Math.random() < 0.3) {
|
|
target.connections.push(cell);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Update cells
|
|
function updateCells(deltaTime) {
|
|
state.time += deltaTime * 0.001 * params.motion * params.pulse.avg;
|
|
|
|
state.cells.forEach(cell => {
|
|
// Update growth
|
|
cell.growth = cell.growth * 0.9 + cell.targetGrowth * 0.1;
|
|
cell.size = cell.baseSize * (0.7 + cell.growth * 0.3);
|
|
|
|
// Update angle
|
|
cell.angle = cell.angle * 0.9 + cell.targetAngle * 0.1;
|
|
cell.targetAngle += (Math.random() - 0.5) * params.motion * params.pulse.avg;
|
|
|
|
// Pulse effect
|
|
cell.size *= 1 + (Math.sin(state.time * cell.pulse) * 0.05 * params.pulse.avg);
|
|
|
|
// Update energy
|
|
cell.energy += params.finalEnergy * 0.001 * params.motion;
|
|
|
|
// Connect to other cells based on energy
|
|
if (cell.energy > params.finalEnergy * 0.5) {
|
|
const nearbyCells = state.cells.filter(c =>
|
|
c !== cell &&
|
|
Math.abs(c.x - cell.x) < state.cellSize * 4 &&
|
|
Math.abs(c.y - cell.y) < state.cellSize * 4
|
|
);
|
|
if (nearbyCells.length > 0 && Math.random() < 0.01) {
|
|
const target = nearbyCells[Math.floor(Math.random() * nearbyCells.length)];
|
|
if (!cell.connections.includes(target)) {
|
|
cell.connections.push(target);
|
|
if (Math.random() < 0.3) {
|
|
target.connections.push(cell);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Draw cells
|
|
function drawCells() {
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Draw connections first (darker)
|
|
ctx.strokeStyle = `rgba(255, 255, 255, ${0.1 * params.tone.dryness})`;
|
|
ctx.lineWidth = state.cellSize * 0.2 * params.thicknessRatio * (0.5 + params.connectedness * 0.5);
|
|
|
|
state.cells.forEach(cell => {
|
|
cell.connections.forEach(target => {
|
|
if (cell === target) return;
|
|
const alpha = 0.2 + params.connectedness * 0.8;
|
|
ctx.globalAlpha = alpha;
|
|
ctx.beginPath();
|
|
ctx.moveTo(cell.x + cell.size/2, cell.y + cell.size/2);
|
|
ctx.lineTo(target.x + target.size/2, target.y + target.size/2);
|
|
ctx.stroke();
|
|
});
|
|
});
|
|
|
|
// Draw cells
|
|
ctx.globalAlpha = 1;
|
|
state.cells.forEach(cell => {
|
|
// Draw cell
|
|
ctx.fillStyle = cell.color;
|
|
ctx.beginPath();
|
|
ctx.arc(
|
|
cell.x + cell.size/2,
|
|
cell.y + cell.size/2,
|
|
cell.size/2,
|
|
0,
|
|
Math.PI * 2
|
|
);
|
|
ctx.fill();
|
|
|
|
// Draw inner circle
|
|
ctx.fillStyle = `hsl(180, 40%, ${60 + Math.sin(state.time * 0.5) * 10}%)`;
|
|
ctx.beginPath();
|
|
ctx.arc(
|
|
cell.x + cell.size/2,
|
|
cell.y + cell.size/2,
|
|
cell.size/4,
|
|
0,
|
|
Math.PI * 2
|
|
);
|
|
ctx.fill();
|
|
|
|
// Draw pulse ring
|
|
ctx.strokeStyle = `hsla(180, 100%, 80%, ${0.5 * params.tone.curiosity})`;
|
|
ctx.lineWidth = 2;
|
|
ctx.beginPath();
|
|
ctx.arc(
|
|
cell.x + cell.size/2,
|
|
cell.y + cell.size/2,
|
|
cell.size/2 + Math.sin(state.time * cell.pulse) * 3,
|
|
0,
|
|
Math.PI * 2
|
|
);
|
|
ctx.stroke();
|
|
});
|
|
}
|
|
|
|
// Animation loop
|
|
function animate(timestamp) {
|
|
if (!state.lastTime) state.lastTime = timestamp;
|
|
const deltaTime = timestamp - state.lastTime;
|
|
state.lastTime = timestamp;
|
|
|
|
updateCells(deltaTime);
|
|
drawCells();
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
// Start animation
|
|
initCells();
|
|
createConnections();
|
|
requestAnimationFrame(animate);
|
|
</script>
|
|
</body>
|
|
</html> |