228

Smoke Lattice Drift

Grid-based discretized fluid simulation capturing continuous harmonic injection, vortex dissipation, and buoyant plume dispersion.

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

Full Executable Algorithm Code

// 007 - Smoke Lattice Drift (fluid)
// 1:1 Original algorithm engine source
function createSmokeLattice() {
  const GRID_SIZE = 40;
  const density = new Float32Array(GRID_SIZE * GRID_SIZE);
  return {
    setup() {
      density.fill(0);
    },
    render(context, timeState, params) {
      const { ctx, width, height } = context;
      const t = timeState.time * Number(params.speed || 1);
      const cellW = width / GRID_SIZE;
      const cellH = height / GRID_SIZE;
      ctx.fillStyle = "#08090d";
      ctx.fillRect(0, 0, width, height);
      const cx = GRID_SIZE / 2;
      const cy = GRID_SIZE / 2;
      for (let y = 1; y < GRID_SIZE - 1; y++) {
        for (let x = 1; x < GRID_SIZE - 1; x++) {
          const idx = y * GRID_SIZE + x;
          const dx = x - cx;
          const dy = y - cy;
          const dist = Math.sqrt(dx * dx + dy * dy);
          const injection = Math.sin(dist * 0.4 - t * 3) * Math.cos(Math.atan2(dy, dx) * 4 + t * 2) * Math.exp(-dist * 0.1);
          density[idx] = Math.max(0, Math.min(1, density[idx] * 0.94 + injection * 0.15));
          if (density[idx] > 0.02) {
            const px = x * cellW;
            const py = y * cellH;
            const alpha = density[idx];
            const hue = (240 + alpha * 100 + t * 20) % 360;
            ctx.fillStyle = hsla(hue, 80, 60, alpha * 0.8);
            ctx.beginPath();
            ctx.arc(px + cellW * 0.5, py + cellH * 0.5, cellW * 0.7 * alpha, 0, Math.PI * 2);
            ctx.fill();
          }
        }
      }
    }
  };
}

// Default parameters from content metadata
const defaultParams = [
  {
    "key": "speed",
    "label": "Emission Speed",
    "type": "range",
    "min": 0.3,
    "max": 3,
    "step": 0.1,
    "defaultValue": 1,
    "description": "Turbulence oscillation rate"
  }
];

if (!window.__art_instances) window.__art_instances = {};
if (!window.__art_instances['smoke-lattice']) {
  const inst = typeof createSmokeLattice === 'function' ? createSmokeLattice() : null;
  if (inst && inst.setup) {
    inst.setup({ ctx, width, height, dpr: 1, aspectRatio: width / height }, defaultParams);
  }
  window.__art_instances['smoke-lattice'] = inst;
}

const instance = window.__art_instances['smoke-lattice'];
if (instance && instance.render) {
  instance.render(
    { ctx, width, height, dpr: 1, aspectRatio: width / height },
    { time, deltaTime: dt, frameCount: Math.floor(time * 60), fps: 60 },
    defaultParams
  );
}
Edit in Interactive Playground Zero Dependencies • Standalone Canvas 2D
ƒ

Mathematical Formulation

medium
Analytical Equation
ρt+uρ=κ2ρ+S(x,t)\frac{\partial \rho}{\partial t} + \mathbf{u} \cdot \nabla \rho = \kappa \nabla^2 \rho + S(\mathbf{x}, t)
Click to expand
Compact Formula
ρ_{x,y}^{t+1} = ρ_{x,y}^t * 0.94 + sin(r*0.4 - 3t)*cos(4θ + 2t)*exp(-0.1r)*0.15

Mathematical Tags

#smoke #lattice #eulerian #fluid #diffusion #advection
Author: Math Art Core Target: 60 FPS

Export & Embed: Smoke Lattice Drift

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/smoke-lattice" width="500" height="500" frameborder="0" loading="lazy"></iframe>
ESC
↑↓ Navigate Select
110 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! ✨