97

Solar Corona & Flare Prominence

Astrophysical simulation of the Sun's dynamic outer atmosphere. Models magnetic dipole coronal loops, convective thermonuclear core granulation, high-energy plasma prominences, and radial solar wind streamer rays.

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

Full Executable Algorithm Code

// 082 - Solar Corona & Flare Prominence (physics)
// 1:1 Original algorithm engine source
function createSolarCoronaFlare() {
  const PROMINENCE_LOOPS = 28;
  const loopPhases = [];

  function initLoops() {
    loopPhases.length = 0;
    for (let i = 0; i < PROMINENCE_LOOPS; i++) {
      loopPhases.push({
        angle: (i / PROMINENCE_LOOPS) * Math.PI * 2 + (Math.random() - 0.5) * 0.2,
        span: 0.15 + Math.random() * 0.35,
        height: 25 + Math.random() * 65,
        speed: 0.4 + Math.random() * 0.8,
        phase: Math.random() * Math.PI * 2,
      });
    }
  }

  return {
    setup() {
      initLoops();
    },
    render(context, timeState, params) {
      const { ctx, width, height } = context;
      const speed = Number(params.speed ?? 1.0);
      const solarActivity = Number(params.solarActivity ?? 1.2);
      const loopDensity = Number(params.loopDensity ?? 1.0);
      const coronaRadiusParam = Number(params.coronaRadius ?? 1.0);
      const flareIntensity = Number(params.flareIntensity ?? 1.3);

      const t = timeState.time * speed;
      if (loopPhases.length === 0) initLoops();

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

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

      // Extended Outer Solar Corona Streamers
      ctx.save();
      ctx.globalCompositeOperation = 'screen';
      const STREAMER_RAYS = 64;
      const maxStreamerLen = Math.min(width, height) * 0.48;

      for (let i = 0; i < STREAMER_RAYS; i++) {
        const theta = (i / STREAMER_RAYS) * Math.PI * 2;
        const rayAngle = theta + Math.sin(theta * 6.0 + t * 1.5) * 0.08 + Math.cos(theta * 14.0 - t * 2.2) * 0.04;
        const pulse = 0.6 + 0.4 * Math.sin(i * 3.1 + t * 2.5 * solarActivity);
        const rayLen = baseR + (maxStreamerLen - baseR) * (0.6 + 0.4 * Math.sin(theta * 3 + t));
        const alpha = Math.min(0.55, 0.28 * pulse * flareIntensity);

        const streamerGrad = ctx.createRadialGradient(cx, cy, baseR * 0.8, cx, cy, rayLen);
        streamerGrad.addColorStop(0, `rgba(255, 235, 160, ${alpha * 1.3})`);
        streamerGrad.addColorStop(0.25, `rgba(255, 140, 40, ${alpha})`);
        streamerGrad.addColorStop(0.65, `rgba(210, 50, 15, ${alpha * 0.35})`);
        streamerGrad.addColorStop(1.0, 'rgba(80, 10, 5, 0)');

        ctx.beginPath();
        ctx.moveTo(cx + Math.cos(rayAngle - 0.045) * baseR, cy + Math.sin(rayAngle - 0.045) * baseR);
        ctx.lineTo(cx + Math.cos(rayAngle) * rayLen, cy + Math.sin(rayAngle) * rayLen);
        ctx.lineTo(cx + Math.cos(rayAngle + 0.045) * baseR, cy + Math.sin(rayAngle + 0.045) * baseR);
        ctx.closePath();
        ctx.fillStyle = streamerGrad;
        ctx.fill();
      }
      ctx.restore();

      // Magnetic Coronal Plasma Loops
      ctx.save();
      ctx.globalCompositeOperation = 'screen';
      const activeLoops = Math.floor(PROMINENCE_LOOPS * loopDensity);
      for (let l = 0; l < activeLoops; l++) {
        const loop = loopPhases[l];
        const a1 = loop.angle - loop.span * 0.5;
        const a2 = loop.angle + loop.span * 0.5;
        const loopHeightDynamic = loop.height * (0.75 + 0.25 * Math.sin(t * loop.speed + loop.phase)) * solarActivity;

        const p1x = cx + Math.cos(a1) * baseR;
        const p1y = cy + Math.sin(a1) * baseR;
        const p2x = cx + Math.cos(a2) * baseR;
        const p2y = cy + Math.sin(a2) * baseR;

        const apexR = baseR + loopHeightDynamic;
        const cpx = cx + Math.cos(loop.angle) * (apexR * 1.25);
        const cpy = cy + Math.sin(loop.angle) * (apexR * 1.25);

        ctx.beginPath();
        ctx.moveTo(p1x, p1y);
        ctx.quadraticCurveTo(cpx, cpy, p2x, p2y);
        ctx.strokeStyle = `hsla(${20 + Math.sin(t + l) * 15}, 95%, 60%, 0.75)`;
        ctx.lineWidth = 1.8;
        ctx.stroke();
      }
      ctx.restore();

      // Photosphere Core
      ctx.save();
      const coreGrad = ctx.createRadialGradient(cx, cy, 0, cx, cy, baseR * 1.3);
      coreGrad.addColorStop(0, '#ffffff');
      coreGrad.addColorStop(0.35, '#fff0a0');
      coreGrad.addColorStop(0.7, '#ff8010');
      coreGrad.addColorStop(1.0, 'rgba(200, 30, 0, 0)');
      ctx.fillStyle = coreGrad;
      ctx.beginPath();
      ctx.arc(cx, cy, baseR * 1.3, 0, Math.PI * 2);
      ctx.fill();
      ctx.restore();
    }
  };
}

const defaultParams = [
  { key: "speed", label: "Solar Dynamic Cadence", type: "range", min: 0.2, max: 2.5, step: 0.1, defaultValue: 1.0 },
  { key: "solarActivity", label: "MHD Prominence Activity", type: "range", min: 0.4, max: 2.2, step: 0.1, defaultValue: 1.2 },
  { key: "loopDensity", label: "Magnetic Arc Loop Count", type: "range", min: 0.3, max: 1.8, step: 0.1, defaultValue: 1.0 },
  { key: "coronaRadius", label: "Photosphere Core Scale", type: "range", min: 0.6, max: 1.5, step: 0.05, defaultValue: 1.0 },
  { key: "flareIntensity", label: "Streamer Glow Luminance", type: "range", min: 0.5, max: 2.5, step: 0.1, defaultValue: 1.3 }
];

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

const instance = window.__art_instances['solar-corona-flare'];
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

high
Analytical Equation
×B=μ0J,ρ(vt+vv)=p+J×B+ρg\nabla \times \mathbf{B} = \mu_0 \mathbf{J}, \quad \rho \left( \frac{\partial \mathbf{v}}{\partial t} + \mathbf{v} \cdot \nabla \mathbf{v} \right) = -\nabla p + \mathbf{J} \times \mathbf{B} + \rho \mathbf{g}
Click to expand
Compact Formula
B_dipole = μ_0 m / (4π r³) · (2 cos θ r_hat + sin θ θ_hat), I_corona(r) ∝ r^(-2.5) · pulse(t)

Mathematical Tags

#astrophysics #solar-flare #corona #plasma #sunrays #magnetic-loops #space-physics #solar-physics
Author: Solar Astrophysical Observatory Target: 60 FPS

Export & Embed: Solar Corona & Flare Prominence

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/solar-corona-flare" width="500" height="500" frameborder="0" loading="lazy"></iframe>
ESC
↑↓ Navigate Select
101 Mathematical Artworks

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! ✨