205 lines
No EOL
6.9 KiB
HTML
205 lines
No EOL
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Entangled Currents</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background-color: #0a0a0a;
|
|
font-family: -apple-system, sans-serif;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
#info {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
color: #666;
|
|
font-size: 11px;
|
|
text-align: right;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="canvas"></canvas>
|
|
<div id="info">neurameba · motd.social</div>
|
|
<script>
|
|
const canvas = document.getElementById('canvas');
|
|
const ctx = canvas.getContext('2d');
|
|
|
|
function resize() {
|
|
canvas.width = window.innerWidth;
|
|
canvas.height = window.innerHeight;
|
|
}
|
|
window.addEventListener('resize', resize);
|
|
resize();
|
|
|
|
// Flow field parameters
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.1, min: 0.9, max: 1.2 },
|
|
tone: { anger: 0, sadness: 0, curiosity: 0.2, dryness: 0.8, playfulness: 0.1, tension: 0 }
|
|
};
|
|
|
|
// Generate field vectors
|
|
const gridSize = 40;
|
|
const cols = Math.ceil(canvas.width / gridSize) + 1;
|
|
const rows = Math.ceil(canvas.height / gridSize) + 1;
|
|
const field = [];
|
|
|
|
// Initialize field with Perlin-like noise
|
|
for (let y = 0; y < rows; y++) {
|
|
field[y] = [];
|
|
for (let x = 0; x < cols; x++) {
|
|
const angle = Math.random() * Math.PI * 2;
|
|
const strength = 0.5 + Math.random() * 0.5;
|
|
field[y][x] = {
|
|
vx: Math.cos(angle) * strength,
|
|
vy: Math.sin(angle) * strength,
|
|
tx: x,
|
|
ty: y
|
|
};
|
|
}
|
|
}
|
|
|
|
// Particle system
|
|
const particles = [];
|
|
const particleCount = 100 + Math.floor(params.density * 200);
|
|
|
|
class Particle {
|
|
constructor() {
|
|
this.reset();
|
|
this.size = 1 + Math.random() * 2;
|
|
this.hue = 0;
|
|
this.life = 0;
|
|
}
|
|
|
|
reset() {
|
|
this.x = Math.random() * canvas.width;
|
|
this.y = Math.random() * canvas.height;
|
|
this.vx = 0;
|
|
this.vy = 0;
|
|
this.trail = [];
|
|
this.maxTrail = 5 + Math.floor(params.complexity * 10);
|
|
this.trailFade = 0.8 - params.dryness * 0.5;
|
|
this.hue = Math.random() < params.tone.curiosity ? 180 : 0;
|
|
}
|
|
|
|
update() {
|
|
// Get field influence
|
|
const gridX = Math.floor(this.x / gridSize);
|
|
const gridY = Math.floor(this.y / gridSize);
|
|
const p = field[gridY][gridX];
|
|
|
|
// Smooth interpolation
|
|
const fx = this.x / gridSize - gridX;
|
|
const fy = this.y / gridSize - gridY;
|
|
|
|
// Blend vectors
|
|
const top = field[gridY][gridX];
|
|
const bottom = gridY + 1 < rows ? field[gridY + 1][gridX] : top;
|
|
const left = field[gridY][gridX + 1] !== undefined ? field[gridY][gridX + 1] : top;
|
|
const right = gridX + 1 < cols ? field[gridY][gridX + 1] : top;
|
|
|
|
const midTop = lerp(top.vx, bottom.vx, fy);
|
|
const midBottom = lerp(left.vx, right.vx, fx);
|
|
const vx = lerp(midTop, midBottom, 0.5);
|
|
|
|
const midTopY = lerp(top.vy, bottom.vy, fy);
|
|
const midBottomY = lerp(left.vy, right.vy, fx);
|
|
const vy = lerp(midTopY, midBottomY, 0.5);
|
|
|
|
// Apply motion with pulse variation
|
|
const pulse = params.pulse.avg + (Math.random() * (params.pulse.max - params.pulse.min) - (params.pulse.max - params.pulse.avg));
|
|
this.vx = lerp(this.vx, vx * params.motion * pulse, 0.05);
|
|
this.vy = lerp(this.vy, vy * params.motion * pulse, 0.05);
|
|
|
|
// Update position
|
|
this.x += this.vx;
|
|
this.y += this.vy;
|
|
|
|
// Boundary checks
|
|
if (this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height) {
|
|
this.reset();
|
|
return;
|
|
}
|
|
|
|
// Add to trail
|
|
this.trail.push({ x: this.x, y: this.y });
|
|
if (this.trail.length > this.maxTrail) {
|
|
this.trail.shift();
|
|
}
|
|
|
|
// Update life
|
|
this.life++;
|
|
const decay = params.lifespan < 0.5 ? 0.02 : 0;
|
|
if (Math.random() < decay) this.reset();
|
|
}
|
|
|
|
draw() {
|
|
ctx.strokeStyle = `hsl(${this.hue}, ${80 + params.tone.curiosity * 20}%, ${50 + params.tone.dryness * 20}%)`;
|
|
ctx.lineWidth = this.size * (0.5 + params.tone.playfulness);
|
|
|
|
if (this.trail.length > 1) {
|
|
ctx.beginPath();
|
|
ctx.moveTo(this.trail[0].x, this.trail[0].y);
|
|
for (let i = 1; i < this.trail.length; i++) {
|
|
const p = this.trail[i];
|
|
const prev = this.trail[i - 1];
|
|
ctx.moveTo(prev.x, prev.y);
|
|
ctx.lineTo(p.x, p.y);
|
|
}
|
|
ctx.stroke();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Initialize particles
|
|
for (let i = 0; i < particleCount; i++) {
|
|
particles.push(new Particle());
|
|
}
|
|
|
|
// Animation loop
|
|
let time = 0;
|
|
function animate() {
|
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Slightly perturb field over time
|
|
if (time % 5 === 0) {
|
|
for (let y = 0; y < rows; y++) {
|
|
for (let x = 0; x < cols; x++) {
|
|
const angle = Math.random() * Math.PI * 2;
|
|
const strength = 0.3 + Math.random() * 0.4;
|
|
field[y][x].vx = Math.cos(angle) * strength;
|
|
field[y][x].vy = Math.sin(angle) * strength;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update and draw particles
|
|
particles.forEach(p => {
|
|
p.update();
|
|
p.draw();
|
|
});
|
|
|
|
time++;
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
|
|
function lerp(a, b, t) {
|
|
return a * (1 - t) + b * t;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |