birth: Pulsing Monochrome Tesserae
This commit is contained in:
parent
dbecc89c8b
commit
097ad53ccc
1 changed files with 182 additions and 0 deletions
182
index.html
Normal file
182
index.html
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Tessellated Currents</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background-color: #0a0a0a;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
.attribution {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
font-size: 10px;
|
||||
z-index: 100;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div class="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 adjusted from abstract inputs
|
||||
const params = {
|
||||
density: 0.5,
|
||||
motion: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: 1.05,
|
||||
dryness: 0.8,
|
||||
playfulness: 0.1
|
||||
};
|
||||
|
||||
// Tessellation grid setup
|
||||
const gridSize = 20 + Math.floor(params.density * 30);
|
||||
const cellSize = Math.max(5, Math.min(30, 200 / gridSize));
|
||||
const cols = Math.ceil(canvas.width / cellSize);
|
||||
const rows = Math.ceil(canvas.height / cellSize);
|
||||
|
||||
// Create grid cells
|
||||
const grid = Array(rows).fill().map(() =>
|
||||
Array(cols).fill().map(() => ({
|
||||
value: 0,
|
||||
target: 0,
|
||||
phase: Math.random() * Math.PI * 2,
|
||||
speed: 0.01 + Math.random() * 0.02
|
||||
}))
|
||||
);
|
||||
|
||||
// Initialize with some structure
|
||||
for (let y = 0; y < rows; y++) {
|
||||
for (let x = 0; x < cols; x++) {
|
||||
if (Math.random() > params.connectedness) continue;
|
||||
|
||||
// Create some organic connections
|
||||
const neighbors = [];
|
||||
for (let dy = -1; dy <= 1; dy++) {
|
||||
for (let dx = -1; dx <= 1; dx++) {
|
||||
if (dx === 0 && dy === 0) continue;
|
||||
neighbors.push({x: x + dx, y: y + dy});
|
||||
}
|
||||
}
|
||||
|
||||
// Connect to some neighbors
|
||||
const connections = Math.floor(params.complexity * 3);
|
||||
for (let i = 0; i < connections; i++) {
|
||||
if (neighbors.length === 0) break;
|
||||
const idx = Math.floor(Math.random() * neighbors.length);
|
||||
const {x: nx, y: ny} = neighbors.splice(idx, 1)[0];
|
||||
|
||||
if (nx >= 0 && nx < cols && ny >= 0 && ny < rows) {
|
||||
const distance = Math.sqrt((x - nx) ** 2 + (y - ny) ** 2);
|
||||
grid[y][x].target += 0.3 / distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animation
|
||||
let time = 0;
|
||||
let pulsePhase = 0;
|
||||
const pulseSpeed = 0.02;
|
||||
const pulseHeight = 0.05 + params.pulse * 0.05;
|
||||
|
||||
function animate() {
|
||||
// Clear with semi-transparent for trails
|
||||
ctx.fillStyle = `rgba(20, 20, 30, ${0.1 + params.dryness * 0.2})`;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Update pulse
|
||||
pulsePhase += pulseSpeed;
|
||||
const pulse = 1.0 + Math.sin(pulsePhase) * pulseHeight;
|
||||
|
||||
// Update grid
|
||||
for (let y = 0; y < rows; y++) {
|
||||
for (let x = 0; x < cols; x++) {
|
||||
const cell = grid[y][x];
|
||||
cell.phase += cell.speed * params.motion * pulse;
|
||||
|
||||
// Organic growth toward targets
|
||||
if (Math.abs(cell.value - cell.target) < 0.001) {
|
||||
cell.target = Math.random() * 0.5 * params.complexity;
|
||||
} else {
|
||||
cell.value += (cell.target - cell.value) * 0.005 * pulse;
|
||||
}
|
||||
|
||||
// Draw cells with dry/monochrome palette
|
||||
const size = cellSize * (0.8 + cell.value * 0.3);
|
||||
const xPos = x * cellSize + cellSize/2;
|
||||
const yPos = y * cellSize + cellSize/2;
|
||||
|
||||
// Slight rotation effect
|
||||
ctx.save();
|
||||
ctx.translate(xPos, yPos);
|
||||
ctx.rotate(cell.phase * 0.1);
|
||||
|
||||
const alpha = cell.value * 0.8 * (1 - params.dryness * 0.5);
|
||||
ctx.fillStyle = `rgba(200, 200, 200, ${alpha})`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(0, 0, size, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
// Add subtle connections
|
||||
if (params.connectedness > 0.3) {
|
||||
ctx.strokeStyle = `rgba(100, 100, 120, ${cell.value * 0.5})`;
|
||||
ctx.lineWidth = cell.value * 2 * params.connectedness;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.lineTo(
|
||||
Math.sin(cell.phase) * cellSize * 0.8,
|
||||
Math.cos(cell.phase * 0.7) * cellSize * 0.6
|
||||
);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// Occasionally add new organic growth
|
||||
if (Math.random() < 0.05 * params.lifespan) {
|
||||
const x = Math.floor(Math.random() * cols);
|
||||
const y = Math.floor(Math.random() * rows);
|
||||
grid[y][x].target = 0.3 + Math.random() * 0.4;
|
||||
}
|
||||
|
||||
time++;
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue