Elliptical Arc Sweep

Builds an elliptical arc dynamically with trigonometry and updates the A command.

Motion specs

Duration
1.3s
Easing
cubic-bezier(0.16, 1, 0.3, 1)
Technique
SVG Arc Command A
Library
SVG Path Arc (A rx ry) + rAF
Category
SVG Draw & Morph
License
Free for personal and commercial use
AI prompt
Create a professional web motion called "Elliptical Arc Sweep" (رسم القوس الإهليلجي).
• Target: .arc-path
• Duration: 1.3s
• Easing: cubic-bezier(0.16, 1, 0.3, 1)
• Colors: dark charcoal background #0d0e11, surface #16181e, white text #f3f4f6, and one fiery orange accent #ff5e1a
• Direction: -
• Library / technique: SVG Path Arc (A rx ry) + rAF
• Output format: a fully self-contained HTML5 / CSS3 / vanilla JS file
• Performance: animate only GPU-safe properties (transform, opacity, clip-path, filter), 60fps, use IntersectionObserver to run on enter, and support @media (prefers-reduced-motion: reduce).
Full code (HTML + CSS + JS)
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Elliptical Arc Sweep</title>
  <style>
    body { margin: 0; background: #0d0e11; color: #f3f4f6; font-family: system-ui, sans-serif; }
    :root { --font-mono: ui-monospace, Menlo, Consolas, monospace; }
    #stage { position: relative; width: 100%; height: 220px; box-sizing: border-box; padding: 16px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #090a0d; }
  </style>
</head>
<body>
  <div id="stage"></div>
  <script>
    function play(stage) {
      const fx = { id: 47, mode: "s_arc" };
      const timers = [], rafs = [], anims = [], listeners = [];
      const regTimer = (t) => { timers.push(t); return t; };
      const regRaf = (r) => { rafs.push(r); return r; };
      const regAnim = (a) => { anims.push(a); return a; };
      const regListen = (el, ev, fn) => { el.addEventListener(ev, fn); listeners.push([el, ev, fn]); };
      const accent = '#ff5e1a', white = '#f3f4f6', muted = '#a1a8b3', surface = '#1e2129';
      const svgEl = (tag, attrs = {}) => {
        const el = document.createElementNS('http://www.w3.org/2000/svg', tag);
        Object.entries(attrs).forEach(([k, v]) => el.setAttribute(k, v));
        return el;
      };
      switch (fx.mode) {
    case 's_arc': {
              const svg = svgEl('svg', { viewBox: '0 0 160 120', width: '160', height: '120' });
              svg.appendChild(svgEl('ellipse', { cx: 80, cy: 60, rx: 58, ry: 32, fill: 'none', stroke: '#252934', 'stroke-width': '2' }));
              const arc = svgEl('path', { fill: 'none', stroke: accent, 'stroke-width': '4', 'stroke-linecap': 'round' });
              svg.appendChild(arc);
              stage.appendChild(svg);
              const start = performance.now();
              const tick = (now) => {
                const t = Math.min(1, (now - start) / 1300);
                const deg = 10 + 300 * (1 - Math.pow(1 - t, 3));
                const rad = deg * Math.PI / 180;
                const x1 = 80 + 58, y1 = 60;
                const x2 = 80 + 58 * Math.cos(rad), y2 = 60 + 32 * Math.sin(rad);
                const large = deg > 180 ? 1 : 0;
                arc.setAttribute('d', `M${x1},${y1} A58,32 0 ${large},1 ${x2.toFixed(1)},${y2.toFixed(1)}`);
                if (t < 1) regRaf(requestAnimationFrame(tick));
              };
              regRaf(requestAnimationFrame(tick));
              break;
            }
      }
      return () => {
        timers.forEach(clearTimeout);
        rafs.forEach(cancelAnimationFrame);
        anims.forEach(a => { try { a.cancel(); } catch (_) {} });
        listeners.forEach(([el, ev, fn]) => el.removeEventListener(ev, fn));
      };
    }
    
    const MS = 1900, PAUSE = 1500; // MS = 0: the effect already runs continuously
    const host = document.getElementById('stage');
    const still = matchMedia('(prefers-reduced-motion: reduce)').matches;
    let stop = null, timer = null, shown = false;
    function run() { if (stop) stop(); host.innerHTML = ""; stop = play(host); }
    function loop() { run(); if (!still && MS) timer = setTimeout(loop, MS + PAUSE); }
    new IntersectionObserver(([e]) => {
      if (e.isIntersecting && !shown) { shown = true; loop(); }
      else if (!e.isIntersecting && shown) { shown = false; clearTimeout(timer); if (stop) stop(); }
    }, { threshold: 0.1 }).observe(host);
  </script>
</body>
</html>

Related templates