438

Brownian Constellation

Continuous random walk nodes interconnected by proximity-based Euclidean distance thresholds, forming dynamic topological webs.

Playground
60 FPS • Canvas 2D
Click + Drag to interact with field
</>

Full Executable Algorithm Code


import type { ArtRenderer, ParameterState, RenderContext, TimeState } from '../../types/engine';
import { hsla } from '../common/color';

export function createBrownianConstellation(): ArtRenderer {
  const MAX_NODES = 160;
  const px = new Float32Array(MAX_NODES);
  const py = new Float32Array(MAX_NODES);
  const vx = new Float32Array(MAX_NODES);
  const vy = new Float32Array(MAX_NODES);

  return {
    setup(context: RenderContext) {
      for (let i = 0; i < MAX_NODES; i++) {
        px[i] = Math.random() * context.width;
        py[i] = Math.random() * context.height;
        vx[i] = (Math.random() - 0.5) * 1.5;
        vy[i] = (Math.random() - 0.5) * 1.5;
      }
    },

    render(context: RenderContext, timeState: TimeState, params: ParameterState) {
      const { ctx, width, height } = context;
      const count = Math.min(MAX_NODES, Number(params.nodeCount || 100));
      const maxDistance = Number(params.connectionRadius || 80);
      const maxDistSq = maxDistance * maxDistance;
      const t = timeState.time;

      ctx.fillStyle = '#08090d';
      ctx.fillRect(0, 0, width, height);

      // Update positions
      for (let i = 0; i < count; i++) {
        px[i] += vx[i];
        py[i] += vy[i];

        if (px[i] < 0 || px[i] > width) vx[i] *= -1;
        if (py[i] < 0 || py[i] > height) vy[i] *= -1;
      }

      // Draw connections
      for (let i = 0; i < count; i++) {
        for (let j = i + 1; j < count; j++) {
          const dx = px[j] - px[i];
          const dy = py[j] - py[i];
          const dSq = dx * dx + dy * dy;

          if (dSq < maxDistSq) {
            const alpha = 1 - dSq / maxDistSq;
            const hue = (190 + alpha * 80 + t * 15) % 360;

            ctx.strokeStyle = hsla(hue, 85, 60, alpha * 0.5);
            ctx.lineWidth = alpha * 1.4;
            ctx.beginPath();
            ctx.moveTo(px[i], py[i]);
            ctx.lineTo(px[j], py[j]);
            ctx.stroke();
          }
        }

        // Draw node dots
        ctx.fillStyle = hsla(200, 90, 70, 0.9);
        ctx.beginPath();
        ctx.arc(px[i], py[i], 2.2, 0, Math.PI * 2);
        ctx.fill();
      }
    },
  };
}
Edit in Interactive Playground Zero Dependencies • Standalone Canvas 2D
ƒ

Mathematical Formulation

medium
Analytical Equation
E={(i,j)∣∥pi−pj∥≤rconn},αij=1−∥pi−pj∥2rconn2E = \{ (i, j) \mid \|\mathbf{p}_i - \mathbf{p}_j\| \le r_{\text{conn}} \}, \quad \alpha_{ij} = 1 - \frac{\|\mathbf{p}_i - \mathbf{p}_j\|^2}{r_{\text{conn}}^2}
Click to expand
Compact Formula
d = dist(p_i, p_j), if (d < R) drawLine(p_i, p_j, alpha = 1 - d/R)

Mathematical Tags

#graph #constellation #brownian #network #euclidean #particles
Author: Math Art Core Target: 60 FPS

Export & Embed: Brownian Constellation

4K PNG Snapshot

High-resolution single frame render

WebM Video (5s Loop)

60 FPS browser-captured stream

Standalone JS Script

Complete executable Canvas 2D algorithm

HTML Iframe Embed

<iframe src="https://art.fazleyrabbi.xyz/embed/brownian-constellation" width="500" height="500" frameborder="0" loading="lazy"></iframe>
ESC
↑↓ Navigate ↵ Select
113 Mathematical Artworks
Made by Fazley Rabbi
☕

Support the Project

Keep mathematical creative coding alive & open source

Or via Direct Payoneer ($0 Fee)
Payoneer Customer ID: $0 Fee Direct
24076084

💡 Payoneer app: Go to Pay → Pay to recipient → Enter ID 24076084.

Thank you for supporting generative mathematical animations! ✨