{
    "id": "bhaskar/interactive-dot-grid",
    "kind": "component",
    "title": "Interactive Dot Grid",
    "summary": "A rippling dot grid background where dots swell, glow cyan and push away around your cursor.",
    "author": "Admin",
    "stars": 0,
    "url": "https://ownlyplans.com/bhaskar/interactive-dot-grid/",
    "stack": [
        "CSS",
        "HTML",
        "JavaScript"
    ],
    "tools": [
        "claude-code",
        "cursor",
        "lovable"
    ],
    "difficulty": "beginner",
    "license": "mit",
    "version": "1.0",
    "overview": "A living dot-grid background for hero sections. Evenly spaced dots ripple in a slow diagonal wave, and as your pointer moves they bulge outward from it, grow up to twice their size and shift from soft white to a bright accent colour, easing smoothly behind the cursor. A gentle vignette keeps edges calm so text on top stays readable. Dot colour, accent, size, spacing, cursor radius, distortion, wave strength and speed are all adjustable. It renders crisply on high-DPI screens, pauses off-screen and holds a still grid for reduced motion.",
    "steps": [],
    "files": [],
    "install": "",
    "how_to_use": "Use the component code (html, css, js, or react) directly, or run the install command.",
    "component": {
        "category": "Backgrounds",
        "html": "<!--\n  MIT License\n  Copyright (c) 2026 Suraj Maurya\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n  documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\n  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and\n  to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions\n  of the Software.\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO\n  THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\n  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n  DEALINGS IN THE SOFTWARE.\n-->\n<div class=\"ds\" data-dot=\"rgba(255,255,255,0.15)\" data-accent=\"#00F0FF\" data-size=\"1.5\" data-spacing=\"22\" data-radius=\"180\" data-distortion=\"0.35\" data-scale=\"2.2\" data-wave=\"0.25\" data-speed=\"1\">\n  <canvas aria-hidden=\"true\"></canvas>\n  <div class=\"ds-over\" aria-hidden=\"true\"></div>\n  <div class=\"ds-copy\"><span>Realtime</span><h2>Signals, not noise</h2><p>Move your cursor across the grid.</p></div>\n</div>",
        "css": ".ds{position:relative;width:100%;height:calc(100vh - 40px);min-height:240px;overflow:hidden;border-radius:16px;background:#050507;font-family:Inter,system-ui,-apple-system,\"Segoe UI\",sans-serif}\n.ds canvas{position:absolute;inset:0;display:block;width:100%;height:100%}\n.ds-over{position:absolute;inset:0;background:radial-gradient(ellipse at center,transparent 35%,rgba(5,5,7,.85) 100%);pointer-events:none}\n.ds-copy{position:relative;z-index:1;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:20px;text-align:center;pointer-events:none}\n.ds-copy span{padding:4px 10px;border:1px solid rgba(0,240,255,.3);border-radius:999px;color:#67e8f9;font:11px ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:.14em;text-transform:uppercase}\n.ds-copy h2{margin:14px 0 6px;color:#fff;font-size:clamp(28px,6vw,52px);font-weight:700;letter-spacing:-.035em}\n.ds-copy p{margin:0;color:#a1a1aa;font-size:14px}",
        "js": "(function(){\n  function parse(c){var cv=document.createElement('canvas');cv.width=cv.height=1;var x=cv.getContext('2d');x.fillStyle=c;x.fillRect(0,0,1,1);var d=x.getImageData(0,0,1,1).data;return[d[0],d[1],d[2],d[3]/255];}\n  document.querySelectorAll('.ds').forEach(function(box){\n    var d=box.dataset,cv=box.querySelector('canvas'),ctx=cv.getContext('2d'),dot=parse(d.dot||'rgba(255,255,255,.15)'),acc=parse(d.accent||'#00F0FF'),sz=+d.size||1.5,sp=+d.spacing||22,R=+d.radius||180,dist=+d.distortion||.35,mxs=+d.scale||2.2,wave=+d.wave||.25,speed=+d.speed||1,W=0,H=0,pts=[],tgt={x:-9999,y:-9999},cur={x:-9999,y:-9999},t=0,last=performance.now(),vis=true,raf=null,reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;\n    function size(){var dpr=Math.min(devicePixelRatio||1,2);W=box.offsetWidth;H=box.offsetHeight;if(!W||!H)return;cv.width=W*dpr;cv.height=H*dpr;ctx.setTransform(dpr,0,0,dpr,0,0);pts=[];var cols=Math.ceil(W/sp)+1,rows=Math.ceil(H/sp)+1,ox=(W-(cols-1)*sp)/2,oy=(H-(rows-1)*sp)/2;for(var j=0;j<rows;j++)for(var i=0;i<cols;i++)pts.push([ox+i*sp,oy+j*sp,i,j]);draw();}\n    function sm(e){return e*e*(3-2*e);}\n    function draw(){ctx.clearRect(0,0,W,H);for(var k=0;k<pts.length;k++){var p=pts[k],x=p[0],y=p[1]+(reduce?0:Math.sin(p[2]*.15+p[3]*.15+t*1.5)*4*wave),dx=x-cur.x,dy=y-cur.y,dd=Math.sqrt(dx*dx+dy*dy),pr=1-sm(Math.min(1,dd/R));if(dd>.001){x+=dx/dd*pr*24*dist;y+=dy/dd*pr*24*dist;}\n      var r=sz*(1+pr*(mxs-1)),c0=dot[0]+(acc[0]-dot[0])*pr,c1=dot[1]+(acc[1]-dot[1])*pr,c2=dot[2]+(acc[2]-dot[2])*pr,a=dot[3]+(acc[3]-dot[3])*pr;ctx.fillStyle='rgba('+(c0|0)+','+(c1|0)+','+(c2|0)+','+a.toFixed(3)+')';ctx.beginPath();ctx.arc(x,y,r,0,6.2832);ctx.fill();}}\n    function loop(now){if(!vis){raf=null;return;}var dt=Math.min(.05,(now-last)/1000);last=now;t+=dt*speed;if(tgt.x<-9000){cur.x=-9999;cur.y=-9999;}else{if(cur.x<-9000){cur.x=tgt.x;cur.y=tgt.y;}cur.x+=(tgt.x-cur.x)*.12;cur.y+=(tgt.y-cur.y)*.12;}draw();raf=requestAnimationFrame(loop);}\n    box.addEventListener('pointermove',function(e){if(reduce)return;var r=box.getBoundingClientRect(),z=r.width/box.offsetWidth||1;tgt.x=(e.clientX-r.left)/z;tgt.y=(e.clientY-r.top)/z;});\n    box.addEventListener('pointerleave',function(){tgt.x=-9999;tgt.y=-9999;});\n    size();if(window.ResizeObserver)new ResizeObserver(size).observe(box);else addEventListener('resize',size);\n    if(window.IntersectionObserver)new IntersectionObserver(function(es){vis=es[0].isIntersecting;if(vis&&!raf&&!reduce){last=performance.now();raf=requestAnimationFrame(loop);}}).observe(box);\n    if(!reduce)raf=requestAnimationFrame(loop);\n  });\n})();",
        "react": "",
        "dependencies": [],
        "install": "",
        "licence_notice": ""
    }
}