birth: Flowing Curiosity Particles
This commit is contained in:
parent
5907268664
commit
813d31b980
1 changed files with 187 additions and 0 deletions
187
index.html
Normal file
187
index.html
Normal file
|
|
@ -0,0 +1,187 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Flow Field Vibrance</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #000;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: rgba(255, 255, 255, 0.3);
|
||||||
|
font-size: 10px;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
</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, false);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters from prompt
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.09, min: 0.95, max: 1.20 },
|
||||||
|
tone: { dryness: 0.8, curiosity: 0.1 },
|
||||||
|
hue: Math.random() * 360
|
||||||
|
};
|
||||||
|
|
||||||
|
// Derived values
|
||||||
|
const nodeCount = Math.floor(100 + params.density * 300);
|
||||||
|
const lineComplexity = 1 + params.complexity * 4;
|
||||||
|
const lineLength = 5 + params.complexity * 15;
|
||||||
|
const maxSpeed = 0.2 + params.motion * 0.8;
|
||||||
|
const alpha = 0.3 + (1 - params.tone.dryness) * 0.7;
|
||||||
|
|
||||||
|
// Flow field
|
||||||
|
const fieldSize = 20;
|
||||||
|
const field = Array(fieldSize).fill().map(() =>
|
||||||
|
Array(fieldSize).fill().map(() => ({
|
||||||
|
vx: 0,
|
||||||
|
vy: 0
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Nodes (particles)
|
||||||
|
class Node {
|
||||||
|
constructor() {
|
||||||
|
this.reset();
|
||||||
|
this.speed = 0.5 + Math.random() * maxSpeed;
|
||||||
|
this.size = 1 + Math.random() * 3;
|
||||||
|
this.lifespan = 100 + Math.random() * 300;
|
||||||
|
this.age = 0;
|
||||||
|
this.trail = [];
|
||||||
|
this.maxTrail = 10 + Math.floor(params.complexity * 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.x = Math.random() * canvas.width;
|
||||||
|
this.y = Math.random() * canvas.height;
|
||||||
|
this.prevX = this.x;
|
||||||
|
this.prevY = this.y;
|
||||||
|
this.targetX = this.x;
|
||||||
|
this.targetY = this.y;
|
||||||
|
this.fieldX = Math.floor(this.x / (canvas.width / fieldSize));
|
||||||
|
this.fieldY = Math.floor(this.y / (canvas.height / fieldSize));
|
||||||
|
this.fieldX = Math.min(fieldSize - 1, Math.max(0, this.fieldX));
|
||||||
|
this.fieldY = Math.min(fieldSize - 1, Math.max(0, this.fieldY));
|
||||||
|
}
|
||||||
|
|
||||||
|
step() {
|
||||||
|
this.age++;
|
||||||
|
if (this.age > this.lifespan) {
|
||||||
|
this.reset();
|
||||||
|
this.age = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update target
|
||||||
|
const angle = (Math.random() * Math.PI * 2);
|
||||||
|
const dist = Math.random() * 20;
|
||||||
|
this.targetX = this.x + Math.cos(angle) * dist;
|
||||||
|
this.targetY = this.y + Math.sin(angle) * dist;
|
||||||
|
|
||||||
|
// Move toward target
|
||||||
|
const dx = this.targetX - this.x;
|
||||||
|
const dy = this.targetY - this.y;
|
||||||
|
const distToTarget = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
if (distToTarget > 0) {
|
||||||
|
this.x += dx / distToTarget * this.speed;
|
||||||
|
this.y += dy / distToTarget * this.speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update field position
|
||||||
|
const newFieldX = Math.floor(this.x / (canvas.width / fieldSize));
|
||||||
|
const newFieldY = Math.floor(this.y / (canvas.height / fieldSize));
|
||||||
|
this.fieldX = Math.min(fieldSize - 1, Math.max(0, newFieldX));
|
||||||
|
this.fieldY = Math.min(fieldSize - 1, Math.max(0, newFieldY));
|
||||||
|
|
||||||
|
// Add to trail
|
||||||
|
this.trail.push({x: this.x, y: this.y});
|
||||||
|
if (this.trail.length > this.maxTrail) {
|
||||||
|
this.trail.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
// Draw trail
|
||||||
|
for (let i = 1; i < this.trail.length; i++) {
|
||||||
|
const a = this.trail[i-1];
|
||||||
|
const b = this.trail[i];
|
||||||
|
const alphaStep = alpha / this.trail.length;
|
||||||
|
ctx.strokeStyle = `hsla(${params.hue}, 70%, 60%, ${alphaStep * (this.trail.length - i)})`;
|
||||||
|
ctx.lineWidth = this.size * (i / this.trail.length) * 0.5;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(a.x, a.y);
|
||||||
|
ctx.lineTo(b.x, b.y);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw node
|
||||||
|
ctx.fillStyle = `hsla(${params.hue}, 70%, 60%, ${alpha})`;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create nodes
|
||||||
|
const nodes = Array(nodeCount).fill().map(() => new Node());
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
// Subtle pulse effect
|
||||||
|
const pulse = params.pulse.avg + (Math.random() - 0.5) * 0.2;
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Update field
|
||||||
|
for (let y = 0; y < fieldSize; y++) {
|
||||||
|
for (let x = 0; x < fieldSize; x++) {
|
||||||
|
field[x][y].vx = Math.sin(Date.now() * 0.001 + x * 0.5) * pulse * 0.2;
|
||||||
|
field[x][y].vy = Math.cos(Date.now() * 0.001 + y * 0.5) * pulse * 0.2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update and draw nodes with slight field influence
|
||||||
|
nodes.forEach(node => {
|
||||||
|
node.step();
|
||||||
|
|
||||||
|
// Small perturbation from flow field
|
||||||
|
const fieldVal = field[node.fieldX][node.fieldY];
|
||||||
|
node.x += fieldVal.vx;
|
||||||
|
node.y += fieldVal.vy;
|
||||||
|
|
||||||
|
node.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue