# Starling murmuration

> Hundreds of birds fly together at dusk in shifting clouds and scatter away from the pointer as if it were a hawk, on canvas.

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

## Where to use it

A flocking simulation in the spirit of the boids model. Each starling looks only at its close neighbours to align, stay together and keep some space, and a slow moving roost point pulls the whole flock across a dusk sky with a low sun and a dark tree line. The swirling shapes appear on their own, much like real murmurations.

The first color is the warm horizon, the second the upper sky and the third the birds and the ground. Density changes how many birds fly and speed how fast. Move the pointer into the flock and it splits around it like a hawk attack, then gathers again.

## Code

### HTML

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

### CSS

```css
.pt-uvq16-murmuration {
  --c1: #f6a670;
  --c2: #5b6d9a;
  --c3: #1d1b22;
  --k: 1;
  /* velocidad */
  --d: 1;
  /* densidad / escala */
  --o: 1;
  /* opacidad */
  --bg: #05060a;
  --fg: #ffffff;
  --blend: screen;
  min-height: 100vh;
}

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

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

.pt-uvq16-murmuration 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);
const B=[];let t=0,warm=0;
const loop=()=>{const v=V(),n=Math.min(480,Math.max(60,Math.round(260*v.d))),bg=rgb(v.bg),dk=lum(bg)<.4,c1=rgb(v.c1),c3=rgb(v.c3);t+=.01*v.k;
while(B.length<n){const a=Math.random()*6.2832,r=Math.sqrt(Math.random())*Math.min(W,H)*.18;B.push({x:W*.5+Math.cos(a)*r*1.6,y:H*.4+Math.sin(a)*r,vx:Math.cos(a+1.6)*1.5,vy:Math.sin(a+1.6)*1.5})}B.length=n;const reps=W>0&&!warm++?160:1;for(let rp=0;rp<reps;rp++){if(rp)t+=.01*v.k;
const ax=W*(.5+.28*Math.sin(t*.37)),ay=H*(.4+.15*Math.sin(t*.61+1)),sp=1.4*Math.min(2.2,v.k)+.6;
for(const b of B){let cx=0,cy=0,mx=0,my=0,sx=0,sy=0,c=0;for(const o of B){const dx=o.x-b.x,dy=o.y-b.y;if(dx>34||dx<-34||dy>34||dy<-34)continue;const d2=dx*dx+dy*dy;if(d2>1156||d2===0)continue;c++;cx+=dx;cy+=dy;mx+=o.vx;my+=o.vy;if(d2<110){sx-=dx/d2;sy-=dy/d2}}
if(c){b.vx+=(mx/c-b.vx)*.07+cx/c*.0045+sx*1.4;b.vy+=(my/c-b.vy)*.07+cy/c*.0045+sy*1.4}
b.vx+=(ax-b.x)*.00011;b.vy+=(ay-b.y)*.00011;
if(m.on){const dx=b.x-m.x,dy=b.y-m.y,d2=dx*dx+dy*dy;if(d2<16900){const d=Math.sqrt(d2)+1,f=(1-d/130)*.9/d;b.vx+=dx*f;b.vy+=dy*f}}
if(b.x<30)b.vx+=.1;if(b.x>W-30)b.vx-=.1;if(b.y<30)b.vy+=.1;if(b.y>H*.8)b.vy-=.12;
const s=Math.hypot(b.vx,b.vy)||1,cl=Math.min(sp*1.5,Math.max(sp*.7,s));b.vx*=cl/s;b.vy*=cl/s}
for(const b of B){b.x+=b.vx;b.y+=b.vy}}
const sk=x.createLinearGradient(0,0,0,H);sk.addColorStop(0,css(mix(rgb(v.c2),bg,dk?.3:.12)));sk.addColorStop(.72,css(mix(c1,bg,dk?.25:.06)));sk.addColorStop(1,css(mix(c1,[255,240,220],.3)));x.fillStyle=sk;x.fillRect(0,0,W,H);
const sg=x.createRadialGradient(W*.68,H*.88,0,W*.68,H*.88,H*.4);sg.addColorStop(0,css(mix(c1,[255,255,255],.6),.9));sg.addColorStop(1,css(c1,0));x.fillStyle=sg;x.fillRect(0,0,W,H);
x.strokeStyle=css(c3,.92);x.lineWidth=2.1;x.lineCap="round";x.beginPath();for(const b of B){x.moveTo(b.x+b.vx*.4,b.y+b.vy*.4);x.lineTo(b.x-b.vx*1.2,b.y-b.vy*1.2)}x.stroke();
x.fillStyle=css(c3);x.beginPath();x.moveTo(0,H);for(let X=0;X<=W+8;X+=6){x.lineTo(X,H*(.93-.018*Math.sin(X*.007+1))-H*.045*Math.max(0,Math.sin(X*.043)*Math.sin(X*.011+2))-(X%30<6?H*.008:0))}x.lineTo(W,H);x.fill();
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-murmuration"));
```

### React

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

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

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

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

`;

export default function PatternUvq16Murmuration() {
  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);
const B=[];let t=0,warm=0;
const loop=()=>{const v=V(),n=Math.min(480,Math.max(60,Math.round(260*v.d))),bg=rgb(v.bg),dk=lum(bg)<.4,c1=rgb(v.c1),c3=rgb(v.c3);t+=.01*v.k;
while(B.length<n){const a=Math.random()*6.2832,r=Math.sqrt(Math.random())*Math.min(W,H)*.18;B.push({x:W*.5+Math.cos(a)*r*1.6,y:H*.4+Math.sin(a)*r,vx:Math.cos(a+1.6)*1.5,vy:Math.sin(a+1.6)*1.5})}B.length=n;const reps=W>0&&!warm++?160:1;for(let rp=0;rp<reps;rp++){if(rp)t+=.01*v.k;
const ax=W*(.5+.28*Math.sin(t*.37)),ay=H*(.4+.15*Math.sin(t*.61+1)),sp=1.4*Math.min(2.2,v.k)+.6;
for(const b of B){let cx=0,cy=0,mx=0,my=0,sx=0,sy=0,c=0;for(const o of B){const dx=o.x-b.x,dy=o.y-b.y;if(dx>34||dx<-34||dy>34||dy<-34)continue;const d2=dx*dx+dy*dy;if(d2>1156||d2===0)continue;c++;cx+=dx;cy+=dy;mx+=o.vx;my+=o.vy;if(d2<110){sx-=dx/d2;sy-=dy/d2}}
if(c){b.vx+=(mx/c-b.vx)*.07+cx/c*.0045+sx*1.4;b.vy+=(my/c-b.vy)*.07+cy/c*.0045+sy*1.4}
b.vx+=(ax-b.x)*.00011;b.vy+=(ay-b.y)*.00011;
if(m.on){const dx=b.x-m.x,dy=b.y-m.y,d2=dx*dx+dy*dy;if(d2<16900){const d=Math.sqrt(d2)+1,f=(1-d/130)*.9/d;b.vx+=dx*f;b.vy+=dy*f}}
if(b.x<30)b.vx+=.1;if(b.x>W-30)b.vx-=.1;if(b.y<30)b.vy+=.1;if(b.y>H*.8)b.vy-=.12;
const s=Math.hypot(b.vx,b.vy)||1,cl=Math.min(sp*1.5,Math.max(sp*.7,s));b.vx*=cl/s;b.vy*=cl/s}
for(const b of B){b.x+=b.vx;b.y+=b.vy}}
const sk=x.createLinearGradient(0,0,0,H);sk.addColorStop(0,css(mix(rgb(v.c2),bg,dk?.3:.12)));sk.addColorStop(.72,css(mix(c1,bg,dk?.25:.06)));sk.addColorStop(1,css(mix(c1,[255,240,220],.3)));x.fillStyle=sk;x.fillRect(0,0,W,H);
const sg=x.createRadialGradient(W*.68,H*.88,0,W*.68,H*.88,H*.4);sg.addColorStop(0,css(mix(c1,[255,255,255],.6),.9));sg.addColorStop(1,css(c1,0));x.fillStyle=sg;x.fillRect(0,0,W,H);
x.strokeStyle=css(c3,.92);x.lineWidth=2.1;x.lineCap="round";x.beginPath();for(const b of B){x.moveTo(b.x+b.vx*.4,b.y+b.vy*.4);x.lineTo(b.x-b.vx*1.2,b.y-b.vy*1.2)}x.stroke();
x.fillStyle=css(c3);x.beginPath();x.moveTo(0,H);for(let X=0;X<=W+8;X+=6){x.lineTo(X,H*(.93-.018*Math.sin(X*.007+1))-H*.045*Math.max(0,Math.sin(X*.043)*Math.sin(X*.011+2))-(X%30<6?H*.008:0))}x.lineTo(W,H);x.fill();
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-murmuration"
        style={{
          "--c1": "#f6a670",
          "--c2": "#5b6d9a",
          "--c3": "#1d1b22",
          "--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 “Starling murmuration” block (Backgrounds) from AIMRAN Library to my project.

## What it is
Hundreds of birds fly together at dusk in shifting clouds and scatter away from the pointer as if it were a hawk, on canvas.

## Chosen settings
- Color 1: #f6a670
- Color 2: #5b6d9a
- Color 3: #1d1b22
- 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-murmuration {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

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

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

`;

export default function PatternUvq16Murmuration() {
  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);
const B=[];let t=0,warm=0;
const loop=()=>{const v=V(),n=Math.min(480,Math.max(60,Math.round(260*v.d))),bg=rgb(v.bg),dk=lum(bg)<.4,c1=rgb(v.c1),c3=rgb(v.c3);t+=.01*v.k;
while(B.length<n){const a=Math.random()*6.2832,r=Math.sqrt(Math.random())*Math.min(W,H)*.18;B.push({x:W*.5+Math.cos(a)*r*1.6,y:H*.4+Math.sin(a)*r,vx:Math.cos(a+1.6)*1.5,vy:Math.sin(a+1.6)*1.5})}B.length=n;const reps=W>0&&!warm++?160:1;for(let rp=0;rp<reps;rp++){if(rp)t+=.01*v.k;
const ax=W*(.5+.28*Math.sin(t*.37)),ay=H*(.4+.15*Math.sin(t*.61+1)),sp=1.4*Math.min(2.2,v.k)+.6;
for(const b of B){let cx=0,cy=0,mx=0,my=0,sx=0,sy=0,c=0;for(const o of B){const dx=o.x-b.x,dy=o.y-b.y;if(dx>34||dx<-34||dy>34||dy<-34)continue;const d2=dx*dx+dy*dy;if(d2>1156||d2===0)continue;c++;cx+=dx;cy+=dy;mx+=o.vx;my+=o.vy;if(d2<110){sx-=dx/d2;sy-=dy/d2}}
if(c){b.vx+=(mx/c-b.vx)*.07+cx/c*.0045+sx*1.4;b.vy+=(my/c-b.vy)*.07+cy/c*.0045+sy*1.4}
b.vx+=(ax-b.x)*.00011;b.vy+=(ay-b.y)*.00011;
if(m.on){const dx=b.x-m.x,dy=b.y-m.y,d2=dx*dx+dy*dy;if(d2<16900){const d=Math.sqrt(d2)+1,f=(1-d/130)*.9/d;b.vx+=dx*f;b.vy+=dy*f}}
if(b.x<30)b.vx+=.1;if(b.x>W-30)b.vx-=.1;if(b.y<30)b.vy+=.1;if(b.y>H*.8)b.vy-=.12;
const s=Math.hypot(b.vx,b.vy)||1,cl=Math.min(sp*1.5,Math.max(sp*.7,s));b.vx*=cl/s;b.vy*=cl/s}
for(const b of B){b.x+=b.vx;b.y+=b.vy}}
const sk=x.createLinearGradient(0,0,0,H);sk.addColorStop(0,css(mix(rgb(v.c2),bg,dk?.3:.12)));sk.addColorStop(.72,css(mix(c1,bg,dk?.25:.06)));sk.addColorStop(1,css(mix(c1,[255,240,220],.3)));x.fillStyle=sk;x.fillRect(0,0,W,H);
const sg=x.createRadialGradient(W*.68,H*.88,0,W*.68,H*.88,H*.4);sg.addColorStop(0,css(mix(c1,[255,255,255],.6),.9));sg.addColorStop(1,css(c1,0));x.fillStyle=sg;x.fillRect(0,0,W,H);
x.strokeStyle=css(c3,.92);x.lineWidth=2.1;x.lineCap="round";x.beginPath();for(const b of B){x.moveTo(b.x+b.vx*.4,b.y+b.vy*.4);x.lineTo(b.x-b.vx*1.2,b.y-b.vy*1.2)}x.stroke();
x.fillStyle=css(c3);x.beginPath();x.moveTo(0,H);for(let X=0;X<=W+8;X+=6){x.lineTo(X,H*(.93-.018*Math.sin(X*.007+1))-H*.045*Math.max(0,Math.sin(X*.043)*Math.sin(X*.011+2))-(X%30<6?H*.008:0))}x.lineTo(W,H);x.fill();
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-murmuration"
        style={{
          "--c1": "#f6a670",
          "--c2": "#5b6d9a",
          "--c3": "#1d1b22",
          "--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.
````
