birth: Flowing Static Currents
This commit is contained in:
parent
d1dfd6ea54
commit
c51d3798ba
1 changed files with 191 additions and 0 deletions
191
index.html
Normal file
191
index.html
Normal file
|
|
@ -0,0 +1,191 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Flow Field Currents</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: #555;
|
||||||
|
font-size: 10px;
|
||||||
|
text-shadow: 0 0 2px #000;
|
||||||
|
}
|
||||||
|
</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');
|
||||||
|
|
||||||
|
// Set canvas to full window size
|
||||||
|
function resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters derived from the abstract specifications
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.03, min: 0.8, max: 1.2 },
|
||||||
|
tone: { dryness: 0.9, curiosity: 0.1 },
|
||||||
|
time: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flow field configuration
|
||||||
|
const fieldResolution = 20;
|
||||||
|
const fieldWidth = Math.floor(canvas.width / fieldResolution);
|
||||||
|
const fieldHeight = Math.floor(canvas.height / fieldResolution);
|
||||||
|
const flowField = createFlowField(fieldWidth, fieldHeight, params);
|
||||||
|
|
||||||
|
// Particle system
|
||||||
|
const particleCount = Math.floor(params.density * 300) + 50;
|
||||||
|
const particles = [];
|
||||||
|
for (let i = 0; i < particleCount; i++) {
|
||||||
|
particles.push(createParticle(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw function
|
||||||
|
function draw() {
|
||||||
|
// Dark background
|
||||||
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.95)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Draw flow field (subtle background lines)
|
||||||
|
ctx.strokeStyle = 'rgba(255, 255, 255, 0.05)';
|
||||||
|
ctx.lineWidth = 0.5;
|
||||||
|
drawFlowField(flowField);
|
||||||
|
|
||||||
|
// Update and draw particles
|
||||||
|
ctx.lineWidth = params.complexity * 2 + 0.5;
|
||||||
|
ctx.strokeStyle = 'rgba(200, 200, 200, 0.8)';
|
||||||
|
particles.forEach(p => updateParticle(p, params, flowField));
|
||||||
|
|
||||||
|
params.time += 0.01 * params.motion;
|
||||||
|
requestAnimationFrame(draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize and start
|
||||||
|
draw();
|
||||||
|
|
||||||
|
// Helper functions
|
||||||
|
function createFlowField(width, height, params) {
|
||||||
|
const field = [];
|
||||||
|
const scale = 0.005 + params.complexity * 0.01;
|
||||||
|
|
||||||
|
for (let y = 0; y < height; y++) {
|
||||||
|
field[y] = [];
|
||||||
|
for (let x = 0; x < width; x++) {
|
||||||
|
// Create vector field with time-oscillating patterns
|
||||||
|
const u = Math.sin(y * scale * 1.5 + params.time * 0.3) * Math.cos(x * scale + params.time * 0.2);
|
||||||
|
const v = Math.cos(x * scale * 1.8 + params.time * 0.4) * Math.sin(y * scale + params.time * 0.1);
|
||||||
|
const len = Math.sqrt(u*u + v*v);
|
||||||
|
field[y][x] = { x: u/len, y: v/len }; // Normalized
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawFlowField(field) {
|
||||||
|
const cols = field[0].length;
|
||||||
|
const rows = field.length;
|
||||||
|
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
const v = field[y][x];
|
||||||
|
const px = x * fieldResolution;
|
||||||
|
const py = y * fieldResolution;
|
||||||
|
|
||||||
|
// Draw small line in direction of field
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(px, py);
|
||||||
|
ctx.lineTo(px + v.x * fieldResolution * 0.8, py + v.y * fieldResolution * 0.8);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createParticle(params) {
|
||||||
|
const angle = Math.random() * Math.PI * 2;
|
||||||
|
const speed = params.motion * 2 + 0.5;
|
||||||
|
return {
|
||||||
|
x: Math.random() * canvas.width,
|
||||||
|
y: Math.random() * canvas.height,
|
||||||
|
vx: Math.cos(angle) * speed,
|
||||||
|
vy: Math.sin(angle) * speed,
|
||||||
|
trail: [],
|
||||||
|
maxTrail: 50 + Math.floor(params.connectedness * 200),
|
||||||
|
alpha: 0.7,
|
||||||
|
size: (0.5 + Math.random()) * params.complexity + 0.5
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateParticle(p, params, field) {
|
||||||
|
// Respect field direction with some perturbation
|
||||||
|
const gridX = Math.floor(p.x / fieldResolution);
|
||||||
|
const gridY = Math.floor(p.y / fieldResolution);
|
||||||
|
const fieldX = Math.max(0, Math.min(field[0].length - 1, gridX));
|
||||||
|
const fieldY = Math.max(0, Math.min(field.length - 1, gridY));
|
||||||
|
const fieldVec = field[fieldY][fieldX];
|
||||||
|
|
||||||
|
// Follow field with noise
|
||||||
|
p.vx = p.vx * 0.9 + fieldVec.x * 2 * params.motion;
|
||||||
|
p.vy = p.vy * 0.9 + fieldVec.y * 2 * params.motion;
|
||||||
|
|
||||||
|
// Add some perturbation
|
||||||
|
p.vx += (Math.random() - 0.5) * params.motion * 0.5;
|
||||||
|
p.vy += (Math.random() - 0.5) * params.motion * 0.5;
|
||||||
|
|
||||||
|
// Update position
|
||||||
|
p.x += p.vx;
|
||||||
|
p.y += p.vy;
|
||||||
|
|
||||||
|
// Boundary conditions
|
||||||
|
if (p.x < 0 || p.x > canvas.width || p.y < 0 || p.y > canvas.height) {
|
||||||
|
p.x = Math.random() * canvas.width;
|
||||||
|
p.y = Math.random() * canvas.height;
|
||||||
|
p.vx = 0;
|
||||||
|
p.vy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update trail
|
||||||
|
p.trail.push({x: p.x, y: p.y});
|
||||||
|
if (p.trail.length > p.maxTrail) {
|
||||||
|
p.trail.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw trail
|
||||||
|
if (params.dryness > 0.7) {
|
||||||
|
ctx.strokeStyle = `rgba(200, 200, 255, ${0.4 * p.alpha})`;
|
||||||
|
} else {
|
||||||
|
ctx.strokeStyle = `rgba(200, 200, 255, ${0.7 * p.alpha})`;
|
||||||
|
}
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(p.trail[0].x, p.trail[0].y);
|
||||||
|
for (let i = 1; i < p.trail.length; i++) {
|
||||||
|
ctx.lineTo(p.trail[i].x, p.trail[i].y);
|
||||||
|
}
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue