birth: Voronoi Fracture Dreams
This commit is contained in:
parent
70375a9130
commit
9edb873095
1 changed files with 205 additions and 0 deletions
205
index.html
Normal file
205
index.html
Normal file
|
|
@ -0,0 +1,205 @@
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Voronoi Fracture</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a1a;
|
||||||
|
color: #e0e0e0;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
text-align: right;
|
||||||
|
padding: 1rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="canvas"></canvas>
|
||||||
|
<div id="attribution">neurameba · motd.social</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
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 from brief
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.07, min: 0.9, max: 1.2 },
|
||||||
|
tone: {
|
||||||
|
anger: 0.0,
|
||||||
|
sadness: 0.0,
|
||||||
|
curiosity: 0.3,
|
||||||
|
dryness: 0.8,
|
||||||
|
playfulness: 0.1,
|
||||||
|
tension: 0.0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Color palette based on parameters
|
||||||
|
function getColor() {
|
||||||
|
const hue = 180 + (Math.random() * 30); // Teal range for curiosity
|
||||||
|
const saturation = 30 + (params.tone.playfulness * 70);
|
||||||
|
const lightness = 50 + (params.tone.dryness * 20 * (Math.random() > 0.5 ? 1 : -1));
|
||||||
|
return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Voronoi cell structure
|
||||||
|
class VoronoiCell {
|
||||||
|
constructor(x, y, index) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.index = index;
|
||||||
|
this.points = [];
|
||||||
|
this.color = getColor();
|
||||||
|
this.energy = Math.random();
|
||||||
|
this.maxPoints = 5 + Math.floor(params.complexity * 10);
|
||||||
|
this.lifespan = params.lifespan * 1000 + Math.random() * 500;
|
||||||
|
this.age = 0;
|
||||||
|
this.connections = new Set();
|
||||||
|
}
|
||||||
|
|
||||||
|
addPoint(px, py) {
|
||||||
|
if (this.points.length < this.maxPoints) {
|
||||||
|
this.points.push({x: px, y: py});
|
||||||
|
this.energy += 0.1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connectTo(cell) {
|
||||||
|
if (Math.random() < params.connectedness * 0.1) {
|
||||||
|
this.connections.add(cell.index);
|
||||||
|
cell.connections.add(this.index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.age++;
|
||||||
|
this.energy = Math.min(1, this.energy * (1 - 0.01));
|
||||||
|
|
||||||
|
// Add new points based on complexity and motion
|
||||||
|
const pointsToAdd = Math.floor(params.complexity * 2);
|
||||||
|
for (let i = 0; i < pointsToAdd; i++) {
|
||||||
|
const angle = Math.random() * Math.PI * 2;
|
||||||
|
const distance = 5 + Math.random() * 20;
|
||||||
|
this.addPoint(
|
||||||
|
this.x + Math.cos(angle) * distance,
|
||||||
|
this.y + Math.sin(angle) * distance
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fade out based on lifespan
|
||||||
|
if (this.age > this.lifespan) {
|
||||||
|
this.energy *= 0.9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw(ctx) {
|
||||||
|
if (this.points.length === 0) return;
|
||||||
|
|
||||||
|
// Draw connections first
|
||||||
|
if (params.connectedness > 0.3) {
|
||||||
|
ctx.strokeStyle = `rgba(255, 255, 255, ${this.energy * 0.5})`;
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
ctx.beginPath();
|
||||||
|
for (const conn of this.connections) {
|
||||||
|
const other = cells[conn];
|
||||||
|
if (other) {
|
||||||
|
ctx.moveTo(this.x, this.y);
|
||||||
|
ctx.lineTo(other.x, other.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw cell points
|
||||||
|
ctx.fillStyle = this.color;
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let i = 0; i < this.points.length; i++) {
|
||||||
|
const p = this.points[i];
|
||||||
|
ctx.moveTo(p.x, p.y);
|
||||||
|
ctx.arc(p.x, p.y, 1 + this.energy * 3, 0, Math.PI * 2);
|
||||||
|
}
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize cells
|
||||||
|
const cells = [];
|
||||||
|
const cellCount = Math.max(10, Math.floor(params.density * 50));
|
||||||
|
for (let i = 0; i < cellCount; i++) {
|
||||||
|
cells.push(new VoronoiCell(
|
||||||
|
Math.random() * canvas.width,
|
||||||
|
Math.random() * canvas.height,
|
||||||
|
i
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect cells
|
||||||
|
for (let i = 0; i < cells.length; i++) {
|
||||||
|
for (let j = i + 1; j < cells.length; j++) {
|
||||||
|
cells[i].connectTo(cells[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation
|
||||||
|
let time = 0;
|
||||||
|
function animate() {
|
||||||
|
// Clear with slight fade
|
||||||
|
ctx.fillStyle = 'rgba(10, 10, 26, 0.1)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Pulse effect
|
||||||
|
const pulse = params.pulse.avg * (1 + Math.sin(time * 0.001) * 0.1);
|
||||||
|
const motionScale = params.motion * pulse;
|
||||||
|
|
||||||
|
// Update and draw all cells
|
||||||
|
for (const cell of cells) {
|
||||||
|
cell.update();
|
||||||
|
|
||||||
|
// Move cell based on motion
|
||||||
|
cell.x += (Math.random() - 0.5) * motionScale * 2;
|
||||||
|
cell.y += (Math.random() - 0.5) * motionScale * 2;
|
||||||
|
cell.x = Math.max(0, Math.min(canvas.width, cell.x));
|
||||||
|
cell.y = Math.max(0, Math.min(canvas.height, cell.y));
|
||||||
|
|
||||||
|
cell.draw(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
time++;
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
Loading…
Add table
Reference in a new issue