438

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


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

export function createSmokeLattice(): ArtRenderer {
  const GRID_SIZE = 40;
  const density = new Float32Array(GRID_SIZE * GRID_SIZE);

  return {
    setup() {
      density.fill(0);
    },

    render(context: RenderContext, timeState: TimeState, params: ParameterState) {
      const { ctx, width, height } = context;
      const t = timeState.time * Number(params.speed || 1.0);
      const cellW = width / GRID_SIZE;
      const cellH = height / GRID_SIZE;

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

      // Emitter in center with swirling dynamics
      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);

          // Harmonic injection
          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();
          }
        }
      }
    },
  };
}
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
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! ✨