# Morphing Gradient Blob

> A soft gradient blob that wobbles on springs and leans toward your cursor wherever it moves.

- Kind: Element
- Page: https://ownlyplans.com/bhaskar/morphing-gradient-blob/
- Licence: MIT (do anything, keep the notice)

## Code

`index.html`

```html
<!--
  MIT License
  Copyright (c) 2026 Suraj Maurya
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  documentation files (the "Software"), to deal in the Software without restriction, including without limitation
  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  The above copyright notice and this permission notice shall be included in all copies or substantial portions
  of the Software.
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  DEALINGS IN THE SOFTWARE.
-->
<div class="mb-stage">
  <svg class="mb" viewBox="0 0 400 400" aria-hidden="true" data-points="8" data-radius="120" data-variance="28" data-speed="0.7" data-stiffness="45" data-damping="9" data-strength="0.35" data-smooth="0.08" data-c1="#7C3AED" data-c2="#06B6D4"></svg>
  <div class="mb-copy"><h2>Shape that breathes</h2><p>Move your cursor around.</p></div>
</div>
```

`styles.css`

```css
.mb-stage{position:relative;width:100%;min-height:calc(100vh - 40px);display:grid;place-items:center;overflow:hidden;border-radius:16px;background:#0a0a0c;font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif}
.mb{position:absolute;left:50%;top:50%;width:min(400px,90vw,calc(100vh - 40px));height:auto;aspect-ratio:1;overflow:visible;transform:translate(-50%,-50%);pointer-events:none;user-select:none}
.mb-copy{position:relative;z-index:1;text-align:center;pointer-events:none}
.mb-copy h2{margin:0;color:#fff;font-size:clamp(26px,5vw,44px);font-weight:700;letter-spacing:-.03em;text-shadow:0 2px 24px rgba(0,0,0,.35)}
.mb-copy p{margin:8px 0 0;color:rgba(255,255,255,.75);font-size:14px}
```

`script.js`

```js
(function(){
  var NS='http://www.w3.org/2000/svg',TAU=Math.PI*2,uid=0,reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;
  function path(c){var n=c.length,d='M '+c[0].x.toFixed(2)+','+c[0].y.toFixed(2)+' ';for(var i=0;i<n;i++){var p0=c[(i-1+n)%n],p1=c[i],p2=c[(i+1)%n],p3=c[(i+2)%n];d+='C '+(p1.x+(p2.x-p0.x)/6).toFixed(2)+','+(p1.y+(p2.y-p0.y)/6).toFixed(2)+' '+(p2.x-(p3.x-p1.x)/6).toFixed(2)+','+(p2.y-(p3.y-p1.y)/6).toFixed(2)+' '+p2.x.toFixed(2)+','+p2.y.toFixed(2)+' ';}return d+'Z';}
  document.querySelectorAll('svg.mb').forEach(function(svg){
    var d=svg.dataset,W=400,H=400,N=+d.points||8,R=+d.radius||120,V=+d.variance||28,SP=+d.speed||.7,K=+d.stiffness||45,DA=+d.damping||9,CS=+d.strength||.35,SM=+d.smooth||.08,id='mbg'+(uid++);
    svg.innerHTML='<defs><linearGradient id="'+id+'" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="'+(d.c1||'#7C3AED')+'"/><stop offset="100%" stop-color="'+(d.c2||'#06B6D4')+'"/></linearGradient></defs>';
    var p=document.createElementNS(NS,'path');p.setAttribute('fill','url(#'+id+')');p.style.filter='blur(10px)';svg.appendChild(p);
    var st=[];for(var i=0;i<N;i++)st.push({r:R,v:0,t:R});
    function coords(ox,oy){return st.map(function(s,i){var a=i/N*TAU;return{x:W/2+Math.cos(a)*s.r+ox,y:H/2+Math.sin(a)*s.r+oy};});}
    p.setAttribute('d',path(coords(0,0)));
    if(reduce)return;
    var cur={x:W/2,y:H/2},pos={x:W/2,y:H/2};
    addEventListener('pointermove',function(e){var r=svg.getBoundingClientRect();if(!r.width)return;cur.x=(e.clientX-r.left)*W/r.width;cur.y=(e.clientY-r.top)*H/r.height;});
    document.documentElement.addEventListener('pointerleave',function(){cur.x=W/2;cur.y=H/2;});
    function retarget(){st.forEach(function(s){s.t=R+(Math.random()*2-1)*V;});}
    retarget();setInterval(retarget,1800/Math.max(SP,.01));
    var last=performance.now();
    requestAnimationFrame(function f(now){var dt=Math.min((now-last)/1000,.05);last=now;pos.x+=(cur.x-pos.x)*SM;pos.y+=(cur.y-pos.y)*SM;
      st.forEach(function(s){s.v+=((s.t-s.r)*K-s.v*DA)*dt;s.r+=s.v*dt;});
      p.setAttribute('d',path(coords((pos.x-W/2)*CS,(pos.y-H/2)*CS)));requestAnimationFrame(f);});
  });
})();
```

## About

An organic, living shape for hero sections. A blurred violet-to-cyan blob is drawn through eight control points joined with smooth curves, and every couple of seconds each point picks a new radius and springs toward it, so the outline breathes and wobbles. The whole blob drifts gently toward your pointer and glides back when you move away. Point count, size, variance, speed, spring stiffness and damping, cursor pull and colours are all adjustable, and it rests as a calm circle for reduced motion.

---
Also available as JSON: https://ownlyplans.com/bhaskar/morphing-gradient-blob/?format=json
MCP server: https://ownlyplans.com/mcp
