# Elastic spring mesh

> A net of springs that dents and ripples as the pointer passes, then settles back, changing color where it stretches, on canvas.

- Category: [Backgrounds](https://library.aimran.es/components/patterns)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/pt-uvq16-elastic-mesh
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A physics toy as a background. Every node of the grid is tied to its rest position and to its four neighbours by springs, so a push travels outwards as a ripple before the mesh calms down. The pointer presses into the net and drags it a little with its speed, and when nobody is around small random pokes keep it alive.

The first color is the relaxed mesh, the second the stretched lines and the third the glowing nodes under the most tension. Density sets the cell size and speed the number of physics steps per frame. Good for developer tools, science content and playful landing pages.

## Code

### HTML

```html
<div class="pt-uvq16-elastic-mesh"><canvas></canvas></div>
```

### CSS

```css
.pt-uvq16-elastic-mesh {
  --c1: #7c8799;
  --c2: #ff5a1f;
  --c3: #ffd166;
  --k: 1;
  /* velocidad */
  --d: 1;
  /* densidad / escala */
  --o: 1;
  /* opacidad */
  --bg: #05060a;
  --fg: #ffffff;
  --blend: screen;
  min-height: 100vh;
}

.pt-uvq16-elastic-mesh {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-uvq16-elastic-mesh>* {
  opacity: var(--o);
}

.pt-uvq16-elastic-mesh canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
```

### JavaScript

```js
(function (el) {
const cv=el.querySelector("canvas"),x=cv.getContext("2d");let W=0,H=0,raf=0,LF=null,pend=null,vis=true,dead=false,RF=0;
const RM=matchMedia("(prefers-reduced-motion: reduce)").matches;
const fit=()=>{const r=Math.min(window.devicePixelRatio||1,2),w=el.clientWidth,h=el.clientHeight;if(w===W&&h===H&&cv.width===Math.round(w*r))return;W=w;H=h;cv.width=Math.round(w*r);cv.height=Math.round(h*r);x.setTransform(r,0,0,r,0,0);if(RM&&LF){RF=0;LF()}};
const ro=new ResizeObserver(fit);ro.observe(el);fit();
const io=new IntersectionObserver(e=>{vis=e[e.length-1].isIntersecting;if(vis&&pend&&!dead){const f=pend;pend=null;raf=window.requestAnimationFrame(f)}});io.observe(el);
const requestAnimationFrame=f=>{LF=f;if(dead)return 0;if(RM){if(++RF<90)f();return 0}if(!vis){pend=f;return 0}return window.requestAnimationFrame(f)};
const V=()=>{const s=getComputedStyle(el),g=n=>s.getPropertyValue(n).trim();return{c1:g("--c1"),c2:g("--c2"),c3:g("--c3"),bg:g("--bg")||"#05060a",k:+g("--k")||1,d:+g("--d")||1}};
const pc=document.createElement("canvas").getContext("2d"),CC={};
const rgb=c=>{if(CC[c])return CC[c];pc.fillStyle="#000";pc.fillStyle=c;const s=pc.fillStyle;return CC[c]=s[0]==="#"?[1,3,5].map(i=>parseInt(s.slice(i,i+2),16)):s.slice(s.indexOf("(")+1).split(",").slice(0,3).map(parseFloat)};
const mix=(a,b,p)=>[a[0]+(b[0]-a[0])*p,a[1]+(b[1]-a[1])*p,a[2]+(b[2]-a[2])*p];
const css=(a,o)=>o===undefined?"rgb("+(a[0]|0)+","+(a[1]|0)+","+(a[2]|0)+")":"rgba("+(a[0]|0)+","+(a[1]|0)+","+(a[2]|0)+","+o+")";
const lum=a=>(a[0]*.299+a[1]*.587+a[2]*.114)/255;const m={x:-1e4,y:-1e4,vx:0,vy:0,on:false};const mv=e=>{const r=el.getBoundingClientRect();if(!r.width)return;const nx=(e.clientX-r.left)*W/r.width,ny=(e.clientY-r.top)*H/r.height;if(m.on){m.vx=nx-m.x;m.vy=ny-m.y}m.x=nx;m.y=ny;m.on=true};const lv=()=>{m.on=false;m.x=m.y=-1e4;m.vx=m.vy=0};el.addEventListener("pointermove",mv);el.addEventListener("pointerdown",mv);el.addEventListener("pointerleave",lv);el.addEventListener("pointercancel",lv);
let G=null,nx=0,ny=0,sp=0,idle=200,gt=0;
const loop=()=>{const v=V(),s=Math.max(14,Math.round(26/v.d)),wx=Math.ceil(W/s)+3,wy=Math.ceil(H/s)+3;if(!G||s!==sp||wx!==nx||wy!==ny){sp=s;nx=wx;ny=wy;G=new Float32Array(nx*ny*4)}
const ox=(W-(nx-1)*s)/2,oy=(H-(ny-1)*s)/2,steps=Math.max(1,Math.min(6,Math.round(2*v.k)));
if(m.on)idle=0;else idle++;gt+=.006*v.k;const gh=idle>90,gx=W*(.5+.36*Math.sin(gt*1.3)),gy=H*(.5+.34*Math.sin(gt*.9+1)),fx=m.on?m.x:gx,fy=m.on?m.y:gy,fw=m.on?1:Math.min(1,(idle-90)/60);if(!m.on&&Math.random()<.035*v.k){const k=((1+Math.random()*(ny-2)|0)*nx+(1+Math.random()*(nx-2)|0))*4,a=Math.random()*6.2832;G[k+2]+=Math.cos(a)*20;G[k+3]+=Math.sin(a)*20}
for(let st=0;st<steps;st++){for(let j=1;j<ny-1;j++)for(let i=1;i<nx-1;i++){const k=(j*nx+i)*4,L=k-4,R=k+4,U=k-nx*4,Dn=k+nx*4;let ax=-.02*G[k]+.2*(G[L]+G[R]+G[U]+G[Dn]-4*G[k]),ay=-.02*G[k+1]+.2*(G[L+1]+G[R+1]+G[U+1]+G[Dn+1]-4*G[k+1]);
if(m.on||gh){const dx=ox+i*s+G[k]-fx,dy=oy+j*s+G[k+1]-fy,d2=dx*dx+dy*dy;if(d2<9000){const d=Math.sqrt(d2)+1,f=(1-d2/9000)*fw;ax+=dx/d*f*1.4+m.vx*f*.05;ay+=dy/d*f*1.4+m.vy*f*.05}}
G[k+2]=(G[k+2]+ax)*.965;G[k+3]=(G[k+3]+ay)*.965}
for(let k=0;k<G.length;k+=4){G[k]+=G[k+2];G[k+1]+=G[k+3]}}
m.vx*=.8;m.vy*=.8;
const bg=rgb(v.bg),A=rgb(v.c1),B=rgb(v.c2),gr=x.createRadialGradient(W/2,H/2,0,W/2,H/2,Math.max(W,H)*.7);gr.addColorStop(0,css(mix(bg,A,.1)));gr.addColorStop(1,css(bg));x.fillStyle=gr;x.fillRect(0,0,W,H);
const P=[new Path2D(),new Path2D(),new Path2D(),new Path2D()],N=new Path2D();
for(let j=0;j<ny;j++)for(let i=0;i<nx;i++){const k=(j*nx+i)*4,x0=ox+i*s+G[k],y0=oy+j*s+G[k+1],e=Math.hypot(G[k],G[k+1]),b=Math.min(3,e/3.5|0);
if(i<nx-1){const q=k+4;P[b].moveTo(x0,y0);P[b].lineTo(ox+(i+1)*s+G[q],oy+j*s+G[q+1])}
if(j<ny-1){const q=k+nx*4;P[b].moveTo(x0,y0);P[b].lineTo(ox+i*s+G[q],oy+(j+1)*s+G[q+1])}
if(e>5){const r=1.2+Math.min(3,e/8);N.moveTo(x0+r,y0);N.arc(x0,y0,r,0,6.2832)}}
x.lineCap="round";for(let b=0;b<4;b++){x.strokeStyle=css(mix(A,B,b/3),b?.95:.6);x.lineWidth=1+b*.5;x.stroke(P[b])}x.fillStyle=v.c3;x.fill(N);
raf=requestAnimationFrame(loop)};loop();
return()=>{dead=true;cancelAnimationFrame(raf);ro.disconnect();io.disconnect();el.removeEventListener("pointermove",mv);el.removeEventListener("pointerdown",mv);el.removeEventListener("pointerleave",lv);el.removeEventListener("pointercancel",lv)};
})(document.querySelector(".pt-uvq16-elastic-mesh"));
```

### React

```tsx
// @ts-nocheck
import { useEffect, useRef } from "react";

const css = `
.pt-uvq16-elastic-mesh {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-uvq16-elastic-mesh>* {
  opacity: var(--o);
}

.pt-uvq16-elastic-mesh canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

`;

export default function PatternUvq16ElasticMesh() {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
const cv=el.querySelector("canvas"),x=cv.getContext("2d");let W=0,H=0,raf=0,LF=null,pend=null,vis=true,dead=false,RF=0;
const RM=matchMedia("(prefers-reduced-motion: reduce)").matches;
const fit=()=>{const r=Math.min(window.devicePixelRatio||1,2),w=el.clientWidth,h=el.clientHeight;if(w===W&&h===H&&cv.width===Math.round(w*r))return;W=w;H=h;cv.width=Math.round(w*r);cv.height=Math.round(h*r);x.setTransform(r,0,0,r,0,0);if(RM&&LF){RF=0;LF()}};
const ro=new ResizeObserver(fit);ro.observe(el);fit();
const io=new IntersectionObserver(e=>{vis=e[e.length-1].isIntersecting;if(vis&&pend&&!dead){const f=pend;pend=null;raf=window.requestAnimationFrame(f)}});io.observe(el);
const requestAnimationFrame=f=>{LF=f;if(dead)return 0;if(RM){if(++RF<90)f();return 0}if(!vis){pend=f;return 0}return window.requestAnimationFrame(f)};
const V=()=>{const s=getComputedStyle(el),g=n=>s.getPropertyValue(n).trim();return{c1:g("--c1"),c2:g("--c2"),c3:g("--c3"),bg:g("--bg")||"#05060a",k:+g("--k")||1,d:+g("--d")||1}};
const pc=document.createElement("canvas").getContext("2d"),CC={};
const rgb=c=>{if(CC[c])return CC[c];pc.fillStyle="#000";pc.fillStyle=c;const s=pc.fillStyle;return CC[c]=s[0]==="#"?[1,3,5].map(i=>parseInt(s.slice(i,i+2),16)):s.slice(s.indexOf("(")+1).split(",").slice(0,3).map(parseFloat)};
const mix=(a,b,p)=>[a[0]+(b[0]-a[0])*p,a[1]+(b[1]-a[1])*p,a[2]+(b[2]-a[2])*p];
const css=(a,o)=>o===undefined?"rgb("+(a[0]|0)+","+(a[1]|0)+","+(a[2]|0)+")":"rgba("+(a[0]|0)+","+(a[1]|0)+","+(a[2]|0)+","+o+")";
const lum=a=>(a[0]*.299+a[1]*.587+a[2]*.114)/255;const m={x:-1e4,y:-1e4,vx:0,vy:0,on:false};const mv=e=>{const r=el.getBoundingClientRect();if(!r.width)return;const nx=(e.clientX-r.left)*W/r.width,ny=(e.clientY-r.top)*H/r.height;if(m.on){m.vx=nx-m.x;m.vy=ny-m.y}m.x=nx;m.y=ny;m.on=true};const lv=()=>{m.on=false;m.x=m.y=-1e4;m.vx=m.vy=0};el.addEventListener("pointermove",mv);el.addEventListener("pointerdown",mv);el.addEventListener("pointerleave",lv);el.addEventListener("pointercancel",lv);
let G=null,nx=0,ny=0,sp=0,idle=200,gt=0;
const loop=()=>{const v=V(),s=Math.max(14,Math.round(26/v.d)),wx=Math.ceil(W/s)+3,wy=Math.ceil(H/s)+3;if(!G||s!==sp||wx!==nx||wy!==ny){sp=s;nx=wx;ny=wy;G=new Float32Array(nx*ny*4)}
const ox=(W-(nx-1)*s)/2,oy=(H-(ny-1)*s)/2,steps=Math.max(1,Math.min(6,Math.round(2*v.k)));
if(m.on)idle=0;else idle++;gt+=.006*v.k;const gh=idle>90,gx=W*(.5+.36*Math.sin(gt*1.3)),gy=H*(.5+.34*Math.sin(gt*.9+1)),fx=m.on?m.x:gx,fy=m.on?m.y:gy,fw=m.on?1:Math.min(1,(idle-90)/60);if(!m.on&&Math.random()<.035*v.k){const k=((1+Math.random()*(ny-2)|0)*nx+(1+Math.random()*(nx-2)|0))*4,a=Math.random()*6.2832;G[k+2]+=Math.cos(a)*20;G[k+3]+=Math.sin(a)*20}
for(let st=0;st<steps;st++){for(let j=1;j<ny-1;j++)for(let i=1;i<nx-1;i++){const k=(j*nx+i)*4,L=k-4,R=k+4,U=k-nx*4,Dn=k+nx*4;let ax=-.02*G[k]+.2*(G[L]+G[R]+G[U]+G[Dn]-4*G[k]),ay=-.02*G[k+1]+.2*(G[L+1]+G[R+1]+G[U+1]+G[Dn+1]-4*G[k+1]);
if(m.on||gh){const dx=ox+i*s+G[k]-fx,dy=oy+j*s+G[k+1]-fy,d2=dx*dx+dy*dy;if(d2<9000){const d=Math.sqrt(d2)+1,f=(1-d2/9000)*fw;ax+=dx/d*f*1.4+m.vx*f*.05;ay+=dy/d*f*1.4+m.vy*f*.05}}
G[k+2]=(G[k+2]+ax)*.965;G[k+3]=(G[k+3]+ay)*.965}
for(let k=0;k<G.length;k+=4){G[k]+=G[k+2];G[k+1]+=G[k+3]}}
m.vx*=.8;m.vy*=.8;
const bg=rgb(v.bg),A=rgb(v.c1),B=rgb(v.c2),gr=x.createRadialGradient(W/2,H/2,0,W/2,H/2,Math.max(W,H)*.7);gr.addColorStop(0,css(mix(bg,A,.1)));gr.addColorStop(1,css(bg));x.fillStyle=gr;x.fillRect(0,0,W,H);
const P=[new Path2D(),new Path2D(),new Path2D(),new Path2D()],N=new Path2D();
for(let j=0;j<ny;j++)for(let i=0;i<nx;i++){const k=(j*nx+i)*4,x0=ox+i*s+G[k],y0=oy+j*s+G[k+1],e=Math.hypot(G[k],G[k+1]),b=Math.min(3,e/3.5|0);
if(i<nx-1){const q=k+4;P[b].moveTo(x0,y0);P[b].lineTo(ox+(i+1)*s+G[q],oy+j*s+G[q+1])}
if(j<ny-1){const q=k+nx*4;P[b].moveTo(x0,y0);P[b].lineTo(ox+i*s+G[q],oy+(j+1)*s+G[q+1])}
if(e>5){const r=1.2+Math.min(3,e/8);N.moveTo(x0+r,y0);N.arc(x0,y0,r,0,6.2832)}}
x.lineCap="round";for(let b=0;b<4;b++){x.strokeStyle=css(mix(A,B,b/3),b?.95:.6);x.lineWidth=1+b*.5;x.stroke(P[b])}x.fillStyle=v.c3;x.fill(N);
raf=requestAnimationFrame(loop)};loop();
return()=>{dead=true;cancelAnimationFrame(raf);ro.disconnect();io.disconnect();el.removeEventListener("pointermove",mv);el.removeEventListener("pointerdown",mv);el.removeEventListener("pointerleave",lv);el.removeEventListener("pointercancel",lv)};
  }, []);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-uvq16-elastic-mesh"
        style={{
          "--c1": "#7c8799",
          "--c2": "#ff5a1f",
          "--c3": "#ffd166",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <canvas></canvas>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Elastic spring mesh” block (Backgrounds) from AIMRAN Library to my project.

## What it is
A net of springs that dents and ripples as the pointer passes, then settles back, changing color where it stretches, on canvas.

## Chosen settings
- Color 1: #7c8799
- Color 2: #ff5a1f
- Color 3: #ffd166
- Speed: 1x (from 0.2 to 3x)
- Density / scale: 1x (from 0.5 to 2x)
- Opacity: 1 (from 0.2 to 1)

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck
import { useEffect, useRef } from "react";

const css = `
.pt-uvq16-elastic-mesh {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-uvq16-elastic-mesh>* {
  opacity: var(--o);
}

.pt-uvq16-elastic-mesh canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

`;

export default function PatternUvq16ElasticMesh() {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
const cv=el.querySelector("canvas"),x=cv.getContext("2d");let W=0,H=0,raf=0,LF=null,pend=null,vis=true,dead=false,RF=0;
const RM=matchMedia("(prefers-reduced-motion: reduce)").matches;
const fit=()=>{const r=Math.min(window.devicePixelRatio||1,2),w=el.clientWidth,h=el.clientHeight;if(w===W&&h===H&&cv.width===Math.round(w*r))return;W=w;H=h;cv.width=Math.round(w*r);cv.height=Math.round(h*r);x.setTransform(r,0,0,r,0,0);if(RM&&LF){RF=0;LF()}};
const ro=new ResizeObserver(fit);ro.observe(el);fit();
const io=new IntersectionObserver(e=>{vis=e[e.length-1].isIntersecting;if(vis&&pend&&!dead){const f=pend;pend=null;raf=window.requestAnimationFrame(f)}});io.observe(el);
const requestAnimationFrame=f=>{LF=f;if(dead)return 0;if(RM){if(++RF<90)f();return 0}if(!vis){pend=f;return 0}return window.requestAnimationFrame(f)};
const V=()=>{const s=getComputedStyle(el),g=n=>s.getPropertyValue(n).trim();return{c1:g("--c1"),c2:g("--c2"),c3:g("--c3"),bg:g("--bg")||"#05060a",k:+g("--k")||1,d:+g("--d")||1}};
const pc=document.createElement("canvas").getContext("2d"),CC={};
const rgb=c=>{if(CC[c])return CC[c];pc.fillStyle="#000";pc.fillStyle=c;const s=pc.fillStyle;return CC[c]=s[0]==="#"?[1,3,5].map(i=>parseInt(s.slice(i,i+2),16)):s.slice(s.indexOf("(")+1).split(",").slice(0,3).map(parseFloat)};
const mix=(a,b,p)=>[a[0]+(b[0]-a[0])*p,a[1]+(b[1]-a[1])*p,a[2]+(b[2]-a[2])*p];
const css=(a,o)=>o===undefined?"rgb("+(a[0]|0)+","+(a[1]|0)+","+(a[2]|0)+")":"rgba("+(a[0]|0)+","+(a[1]|0)+","+(a[2]|0)+","+o+")";
const lum=a=>(a[0]*.299+a[1]*.587+a[2]*.114)/255;const m={x:-1e4,y:-1e4,vx:0,vy:0,on:false};const mv=e=>{const r=el.getBoundingClientRect();if(!r.width)return;const nx=(e.clientX-r.left)*W/r.width,ny=(e.clientY-r.top)*H/r.height;if(m.on){m.vx=nx-m.x;m.vy=ny-m.y}m.x=nx;m.y=ny;m.on=true};const lv=()=>{m.on=false;m.x=m.y=-1e4;m.vx=m.vy=0};el.addEventListener("pointermove",mv);el.addEventListener("pointerdown",mv);el.addEventListener("pointerleave",lv);el.addEventListener("pointercancel",lv);
let G=null,nx=0,ny=0,sp=0,idle=200,gt=0;
const loop=()=>{const v=V(),s=Math.max(14,Math.round(26/v.d)),wx=Math.ceil(W/s)+3,wy=Math.ceil(H/s)+3;if(!G||s!==sp||wx!==nx||wy!==ny){sp=s;nx=wx;ny=wy;G=new Float32Array(nx*ny*4)}
const ox=(W-(nx-1)*s)/2,oy=(H-(ny-1)*s)/2,steps=Math.max(1,Math.min(6,Math.round(2*v.k)));
if(m.on)idle=0;else idle++;gt+=.006*v.k;const gh=idle>90,gx=W*(.5+.36*Math.sin(gt*1.3)),gy=H*(.5+.34*Math.sin(gt*.9+1)),fx=m.on?m.x:gx,fy=m.on?m.y:gy,fw=m.on?1:Math.min(1,(idle-90)/60);if(!m.on&&Math.random()<.035*v.k){const k=((1+Math.random()*(ny-2)|0)*nx+(1+Math.random()*(nx-2)|0))*4,a=Math.random()*6.2832;G[k+2]+=Math.cos(a)*20;G[k+3]+=Math.sin(a)*20}
for(let st=0;st<steps;st++){for(let j=1;j<ny-1;j++)for(let i=1;i<nx-1;i++){const k=(j*nx+i)*4,L=k-4,R=k+4,U=k-nx*4,Dn=k+nx*4;let ax=-.02*G[k]+.2*(G[L]+G[R]+G[U]+G[Dn]-4*G[k]),ay=-.02*G[k+1]+.2*(G[L+1]+G[R+1]+G[U+1]+G[Dn+1]-4*G[k+1]);
if(m.on||gh){const dx=ox+i*s+G[k]-fx,dy=oy+j*s+G[k+1]-fy,d2=dx*dx+dy*dy;if(d2<9000){const d=Math.sqrt(d2)+1,f=(1-d2/9000)*fw;ax+=dx/d*f*1.4+m.vx*f*.05;ay+=dy/d*f*1.4+m.vy*f*.05}}
G[k+2]=(G[k+2]+ax)*.965;G[k+3]=(G[k+3]+ay)*.965}
for(let k=0;k<G.length;k+=4){G[k]+=G[k+2];G[k+1]+=G[k+3]}}
m.vx*=.8;m.vy*=.8;
const bg=rgb(v.bg),A=rgb(v.c1),B=rgb(v.c2),gr=x.createRadialGradient(W/2,H/2,0,W/2,H/2,Math.max(W,H)*.7);gr.addColorStop(0,css(mix(bg,A,.1)));gr.addColorStop(1,css(bg));x.fillStyle=gr;x.fillRect(0,0,W,H);
const P=[new Path2D(),new Path2D(),new Path2D(),new Path2D()],N=new Path2D();
for(let j=0;j<ny;j++)for(let i=0;i<nx;i++){const k=(j*nx+i)*4,x0=ox+i*s+G[k],y0=oy+j*s+G[k+1],e=Math.hypot(G[k],G[k+1]),b=Math.min(3,e/3.5|0);
if(i<nx-1){const q=k+4;P[b].moveTo(x0,y0);P[b].lineTo(ox+(i+1)*s+G[q],oy+j*s+G[q+1])}
if(j<ny-1){const q=k+nx*4;P[b].moveTo(x0,y0);P[b].lineTo(ox+i*s+G[q],oy+(j+1)*s+G[q+1])}
if(e>5){const r=1.2+Math.min(3,e/8);N.moveTo(x0+r,y0);N.arc(x0,y0,r,0,6.2832)}}
x.lineCap="round";for(let b=0;b<4;b++){x.strokeStyle=css(mix(A,B,b/3),b?.95:.6);x.lineWidth=1+b*.5;x.stroke(P[b])}x.fillStyle=v.c3;x.fill(N);
raf=requestAnimationFrame(loop)};loop();
return()=>{dead=true;cancelAnimationFrame(raf);ro.disconnect();io.disconnect();el.removeEventListener("pointermove",mv);el.removeEventListener("pointerdown",mv);el.removeEventListener("pointerleave",lv);el.removeEventListener("pointercancel",lv)};
  }, []);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-uvq16-elastic-mesh"
        style={{
          "--c1": "#7c8799",
          "--c2": "#ff5a1f",
          "--c3": "#ffd166",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <canvas></canvas>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
