438

Coral Polyp Growth

Anthozoan coral colony morphology simulated through differential boundary growth equations and undulating feather tentacle radial symmetry.

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 createCoralPolypGrowth(): ArtRenderer {
  const POLYP_COUNT = 8;
  const TENTACLES_PER_POLYP = 12;

  return {
    setup() {},

    render(context: RenderContext, timeState: TimeState, params: ParameterState) {
      const { ctx, width, height } = context;
      const speed = Number(params.flowSpeed || 0.8);
      const bloomScale = Number(params.bloomScale || 1.1);
      const t = timeState.time * speed;

      ctx.fillStyle = '#06080e';
      ctx.fillRect(0, 0, width, height);

      const cx = width * 0.5;
      const cy = height * 0.52;
      const baseR = Math.min(width, height) * 0.28;

      // 1. Central Coral Colony Ridge
      ctx.beginPath();
      const ridgeSteps = 120;
      for (let i = 0; i <= ridgeSteps; i++) {
        const phi = (i / ridgeSteps) * Math.PI * 2;
        const bump = Math.sin(phi * 6 + t * 0.5) * 12 + Math.cos(phi * 12 - t) * 6;
        const r = (baseR * 0.6 + bump) * bloomScale;
        const px = cx + Math.cos(phi) * r;
        const py = cy + Math.sin(phi) * r;
        if (i === 0) ctx.moveTo(px, py);
        else ctx.lineTo(px, py);
      }
      ctx.closePath();
      ctx.fillStyle = hsla(330, 85, 45, 0.4);
      ctx.fill();
      ctx.strokeStyle = hsla(340, 95, 70, 0.8);
      ctx.lineWidth = 2.2;
      ctx.stroke();

      // 2. Blooming Polyps around the ring
      for (let p = 0; p < POLYP_COUNT; p++) {
        const polypAngle = (p / POLYP_COUNT) * Math.PI * 2 + t * 0.1;
        const polypDist = baseR * (0.8 + 0.15 * Math.sin(t * 1.5 + p));
        const px = cx + Math.cos(polypAngle) * polypDist;
        const py = cy + Math.sin(polypAngle) * polypDist;

        // Polyp Mouth Disk
        ctx.beginPath();
        ctx.arc(px, py, 6 * bloomScale, 0, Math.PI * 2);
        ctx.fillStyle = hsla(50, 95, 75, 0.95);
        ctx.fill();

        // Radially radiating feather tentacles
        for (let k = 0; k < TENTACLES_PER_POLYP; k++) {
          const tentAngle = (k / TENTACLES_PER_POLYP) * Math.PI * 2;
          const tentLen = (28 + Math.sin(t * 3 + p + k) * 8) * bloomScale;

          ctx.beginPath();
          ctx.moveTo(px, py);

          // Undulating wave along polyp tentacle
          const wavePhase = t * 4 + k * 0.5 + p;
          const ctrlX = px + Math.cos(tentAngle) * (tentLen * 0.5) + Math.sin(wavePhase) * 6;
          const ctrlY = py + Math.sin(tentAngle) * (tentLen * 0.5) + Math.cos(wavePhase) * 6;
          const endX = px + Math.cos(tentAngle) * tentLen;
          const endY = py + Math.sin(tentAngle) * tentLen;

          ctx.quadraticCurveTo(ctrlX, ctrlY, endX, endY);

          const tentHue = (320 + p * 15 + k * 4) % 360;
          ctx.strokeStyle = hsla(tentHue, 95, 72, 0.85);
          ctx.lineWidth = 1.4;
          ctx.stroke();
        }
      }
    },
  };
}
Edit in Interactive Playground Zero Dependencies • Standalone Canvas 2D
ƒ

Mathematical Formulation

medium
Analytical Equation
p(θ,t)=[R0+∑m=1KAmsin⁡(mθ+ωmt)][cos⁡θsin⁡θ]\mathbf{p}(\theta, t) = \left[ R_0 + \sum_{m=1}^{K} A_m \sin(m \theta + \omega_m t) \right] \begin{bmatrix} \cos\theta \\ \sin\theta \end{bmatrix}
Click to expand
Compact Formula
r_ridge = R0 + 12 sin(6θ + 0.5t) + 6 cos(12θ - t), tentacle = quadCurve(mouth, ctrlWave, tip)

Mathematical Tags

#coral #polyps #differential-growth #botany #marine #nature
Author: Math Art Core Target: 60 FPS

Export & Embed: Coral Polyp Growth

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/coral-polyp-growth" 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! ✨