# Thermal camera view

> Heat silhouettes walk across an infrared image with a temperature scale and a marker that tracks the hottest spot, on canvas.

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

## Where to use it

An infrared camera feed recreated in a few lines of code. A low resolution heat field sums soft shapes for three people walking, a lamp, a hot mug and a cold window, and every value is mapped through a five step palette from near black to white. A camera style frame, a scale bar and a crosshair that jumps to the hottest point complete the look.

The three colors are the middle stops of the palette, so you can go from classic ironbow to rainbow or a single hue. Density changes the size of the figures. Your pointer is a warm hand that shows up on the image. Great for security, hardware, energy and health tech.

## Code

### HTML

```html
<div class="pt-uvq16-thermal"><canvas></canvas><i class="hud"></i><i class="sc"><b>38°</b><b>18°</b></i><i class="mk"><b class="rd">36.0°C</b></i></div>
```

### CSS

```css
.pt-uvq16-thermal {
  --c1: #4c1d95;
  --c2: #f0541e;
  --c3: #fde68a;
  --k: 1;
  /* velocidad */
  --d: 1;
  /* densidad / escala */
  --o: 1;
  /* opacidad */
  --bg: #05060a;
  --fg: #ffffff;
  --blend: screen;
  min-height: 100vh;
}

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

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

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

.pt-uvq16-thermal {
  background: #06030f;
  font: 600 11px/1 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  color: #fff;
}

.pt-uvq16-thermal .hud {
  position: absolute;
  inset: 14px;
  pointer-events: none;
  --l: linear-gradient(#fff,#fff);
  background: var(--l) top left/18px 2px,var(--l) top left/2px 18px,var(--l) top right/18px 2px,var(--l) top right/2px 18px,var(--l) bottom left/18px 2px,var(--l) bottom left/2px 18px,var(--l) bottom right/18px 2px,var(--l) bottom right/2px 18px;
  background-repeat: no-repeat;
  opacity: .85;
}

.pt-uvq16-thermal .sc {
  position: absolute;
  right: 26px;
  top: 50%;
  width: 8px;
  height: 44%;
  translate: 0 -50%;
  border: 1px solid rgba(255,255,255,.7);
  background: linear-gradient(to top,#06030f,var(--c1) 30%,var(--c2) 60%,var(--c3) 85%,#fff);
}

.pt-uvq16-thermal .sc b {
  position: absolute;
  right: 14px;
  font-weight: 600;
  text-shadow: 0 1px 2px #000;
}

.pt-uvq16-thermal .sc b:first-child {
  top: -4px;
}

.pt-uvq16-thermal .sc b:last-child {
  bottom: -4px;
}

.pt-uvq16-thermal .mk {
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
  transition: translate .25s ease-out;
  pointer-events: none;
}

.pt-uvq16-thermal .mk::before,.pt-uvq16-thermal .mk::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: #fff;
  translate: -50% -50%;
}

.pt-uvq16-thermal .mk::before {
  width: 36px;
  height: 1.5px;
}

.pt-uvq16-thermal .mk::after {
  width: 1.5px;
  height: 36px;
}

.pt-uvq16-thermal .rd {
  position: absolute;
  left: 30px;
  top: -14px;
  white-space: nowrap;
  padding: 3px 5px;
  background: rgba(0,0,0,.55);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion:reduce) {
  .pt-uvq16-thermal .mk {
    transition: none;
  }
}
```

### 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 o=document.createElement("canvas"),g=o.getContext("2d"),mk=el.querySelector(".mk"),rd=el.querySelector(".rd");let img,buf,gw=0,gh=0,t=0,lk="",fr=0;const LUT=new Uint32Array(256);
const loop=()=>{const v=V(),p=6,nw=Math.max(4,Math.ceil(W/p)),nh=Math.max(4,Math.ceil(H/p));if(nw!==gw||nh!==gh||!img){gw=nw;gh=nh;o.width=gw;o.height=gh;img=g.createImageData(gw,gh);buf=new Uint32Array(img.data.buffer)}
const ck=v.c1+v.c2+v.c3;if(ck!==lk){lk=ck;const S=[[6,3,15],rgb(v.c1),rgb(v.c2),rgb(v.c3),[255,255,255]],T=[0,.3,.6,.85,1];for(let q=0;q<256;q++){const u=q/255;let s=0;while(s<3&&u>T[s+1])s++;const c=mix(S[s],S[s+1],(u-T[s])/(T[s+1]-T[s]));LUT[q]=((255<<24)|((c[2]|0)<<16)|((c[1]|0)<<8)|(c[0]|0))>>>0}}
t+=.01*v.k;const s0=gh*.075*Math.min(1.6,Math.max(.6,1/v.d)),PE=[0,1,2].map(q=>[(.5+.42*Math.sin(t*(.21+q*.07)+q*2.1))*gw,gh*(.6+q*.04),s0*(1+q*.15)]),hx=m.on?m.x/p:-1e4,hy=m.on?m.y/p:-1e4;
let mx=0,mi=0,mj=0;
for(let j=0;j<gh;j++)for(let i=0;i<gw;i++){let val=.17+.04*Math.sin(i*.08+t)*Math.cos(j*.07-t*.6);
if(i>gw*.06&&i<gw*.32&&j>gh*.1&&j<gh*.42)val-=.1;
const lx=i-gw*.84,ly=j-gh*.2;val+=.75*Math.exp(-(lx*lx+ly*ly)/(s0*s0*.25));const cx=i-gw*.14,cy=j-gh*.82;val+=.55*Math.exp(-(cx*cx+cy*cy*2)/(s0*s0*.35));
for(const e of PE){const dx=i-e[0],dy=j-e[1],s2=e[2]*e[2];val+=.62*Math.exp(-(dx*dx+(dy+e[2]*2)*(dy+e[2]*2))/(s2*.42))+.55*Math.exp(-(dx*dx/(s2*.8)+dy*dy/(s2*2.6)))+.4*Math.exp(-(dx*dx/(s2*.35)+(dy-e[2]*2.4)*(dy-e[2]*2.4)/(s2*2.2)))}
if(hx>-9e3){const dx=i-hx,dy=j-hy;val+=.8*Math.exp(-(dx*dx+dy*dy)/(s0*s0*.5))}
if(val>mx){mx=val;mi=i;mj=j}buf[j*gw+i]=LUT[Math.min(255,Math.max(0,val*255|0))]}
g.putImageData(img,0,0);x.imageSmoothingEnabled=true;x.drawImage(o,0,0,gw*p,gh*p);
if(fr++%6===0){mk.style.translate=(mi*p+p/2)+"px "+(mj*p+p/2)+"px";rd.textContent=(18+Math.min(1,mx)*20).toFixed(1)+"°C"}
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-thermal"));
```

### React

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

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

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

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

.pt-uvq16-thermal {
  background: #06030f;
  font: 600 11px/1 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  color: #fff;
}

.pt-uvq16-thermal .hud {
  position: absolute;
  inset: 14px;
  pointer-events: none;
  --l: linear-gradient(#fff,#fff);
  background: var(--l) top left/18px 2px,var(--l) top left/2px 18px,var(--l) top right/18px 2px,var(--l) top right/2px 18px,var(--l) bottom left/18px 2px,var(--l) bottom left/2px 18px,var(--l) bottom right/18px 2px,var(--l) bottom right/2px 18px;
  background-repeat: no-repeat;
  opacity: .85;
}

.pt-uvq16-thermal .sc {
  position: absolute;
  right: 26px;
  top: 50%;
  width: 8px;
  height: 44%;
  translate: 0 -50%;
  border: 1px solid rgba(255,255,255,.7);
  background: linear-gradient(to top,#06030f,var(--c1) 30%,var(--c2) 60%,var(--c3) 85%,#fff);
}

.pt-uvq16-thermal .sc b {
  position: absolute;
  right: 14px;
  font-weight: 600;
  text-shadow: 0 1px 2px #000;
}

.pt-uvq16-thermal .sc b:first-child {
  top: -4px;
}

.pt-uvq16-thermal .sc b:last-child {
  bottom: -4px;
}

.pt-uvq16-thermal .mk {
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
  transition: translate .25s ease-out;
  pointer-events: none;
}

.pt-uvq16-thermal .mk::before,.pt-uvq16-thermal .mk::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: #fff;
  translate: -50% -50%;
}

.pt-uvq16-thermal .mk::before {
  width: 36px;
  height: 1.5px;
}

.pt-uvq16-thermal .mk::after {
  width: 1.5px;
  height: 36px;
}

.pt-uvq16-thermal .rd {
  position: absolute;
  left: 30px;
  top: -14px;
  white-space: nowrap;
  padding: 3px 5px;
  background: rgba(0,0,0,.55);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion:reduce) {
  .pt-uvq16-thermal .mk {
    transition: none;
  }
}

`;

export default function PatternUvq16Thermal() {
  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 o=document.createElement("canvas"),g=o.getContext("2d"),mk=el.querySelector(".mk"),rd=el.querySelector(".rd");let img,buf,gw=0,gh=0,t=0,lk="",fr=0;const LUT=new Uint32Array(256);
const loop=()=>{const v=V(),p=6,nw=Math.max(4,Math.ceil(W/p)),nh=Math.max(4,Math.ceil(H/p));if(nw!==gw||nh!==gh||!img){gw=nw;gh=nh;o.width=gw;o.height=gh;img=g.createImageData(gw,gh);buf=new Uint32Array(img.data.buffer)}
const ck=v.c1+v.c2+v.c3;if(ck!==lk){lk=ck;const S=[[6,3,15],rgb(v.c1),rgb(v.c2),rgb(v.c3),[255,255,255]],T=[0,.3,.6,.85,1];for(let q=0;q<256;q++){const u=q/255;let s=0;while(s<3&&u>T[s+1])s++;const c=mix(S[s],S[s+1],(u-T[s])/(T[s+1]-T[s]));LUT[q]=((255<<24)|((c[2]|0)<<16)|((c[1]|0)<<8)|(c[0]|0))>>>0}}
t+=.01*v.k;const s0=gh*.075*Math.min(1.6,Math.max(.6,1/v.d)),PE=[0,1,2].map(q=>[(.5+.42*Math.sin(t*(.21+q*.07)+q*2.1))*gw,gh*(.6+q*.04),s0*(1+q*.15)]),hx=m.on?m.x/p:-1e4,hy=m.on?m.y/p:-1e4;
let mx=0,mi=0,mj=0;
for(let j=0;j<gh;j++)for(let i=0;i<gw;i++){let val=.17+.04*Math.sin(i*.08+t)*Math.cos(j*.07-t*.6);
if(i>gw*.06&&i<gw*.32&&j>gh*.1&&j<gh*.42)val-=.1;
const lx=i-gw*.84,ly=j-gh*.2;val+=.75*Math.exp(-(lx*lx+ly*ly)/(s0*s0*.25));const cx=i-gw*.14,cy=j-gh*.82;val+=.55*Math.exp(-(cx*cx+cy*cy*2)/(s0*s0*.35));
for(const e of PE){const dx=i-e[0],dy=j-e[1],s2=e[2]*e[2];val+=.62*Math.exp(-(dx*dx+(dy+e[2]*2)*(dy+e[2]*2))/(s2*.42))+.55*Math.exp(-(dx*dx/(s2*.8)+dy*dy/(s2*2.6)))+.4*Math.exp(-(dx*dx/(s2*.35)+(dy-e[2]*2.4)*(dy-e[2]*2.4)/(s2*2.2)))}
if(hx>-9e3){const dx=i-hx,dy=j-hy;val+=.8*Math.exp(-(dx*dx+dy*dy)/(s0*s0*.5))}
if(val>mx){mx=val;mi=i;mj=j}buf[j*gw+i]=LUT[Math.min(255,Math.max(0,val*255|0))]}
g.putImageData(img,0,0);x.imageSmoothingEnabled=true;x.drawImage(o,0,0,gw*p,gh*p);
if(fr++%6===0){mk.style.translate=(mi*p+p/2)+"px "+(mj*p+p/2)+"px";rd.textContent=(18+Math.min(1,mx)*20).toFixed(1)+"°C"}
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-thermal"
        style={{
          "--c1": "#4c1d95",
          "--c2": "#f0541e",
          "--c3": "#fde68a",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <canvas></canvas><i className="hud"></i><i className="sc"><b>38°</b><b>18°</b></i><i className="mk"><b className="rd">36.0°C</b></i>
      </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 “Thermal camera view” block (Backgrounds) from AIMRAN Library to my project.

## What it is
Heat silhouettes walk across an infrared image with a temperature scale and a marker that tracks the hottest spot, on canvas.

## Chosen settings
- Color 1: #4c1d95
- Color 2: #f0541e
- Color 3: #fde68a
- 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-thermal {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

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

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

.pt-uvq16-thermal {
  background: #06030f;
  font: 600 11px/1 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  color: #fff;
}

.pt-uvq16-thermal .hud {
  position: absolute;
  inset: 14px;
  pointer-events: none;
  --l: linear-gradient(#fff,#fff);
  background: var(--l) top left/18px 2px,var(--l) top left/2px 18px,var(--l) top right/18px 2px,var(--l) top right/2px 18px,var(--l) bottom left/18px 2px,var(--l) bottom left/2px 18px,var(--l) bottom right/18px 2px,var(--l) bottom right/2px 18px;
  background-repeat: no-repeat;
  opacity: .85;
}

.pt-uvq16-thermal .sc {
  position: absolute;
  right: 26px;
  top: 50%;
  width: 8px;
  height: 44%;
  translate: 0 -50%;
  border: 1px solid rgba(255,255,255,.7);
  background: linear-gradient(to top,#06030f,var(--c1) 30%,var(--c2) 60%,var(--c3) 85%,#fff);
}

.pt-uvq16-thermal .sc b {
  position: absolute;
  right: 14px;
  font-weight: 600;
  text-shadow: 0 1px 2px #000;
}

.pt-uvq16-thermal .sc b:first-child {
  top: -4px;
}

.pt-uvq16-thermal .sc b:last-child {
  bottom: -4px;
}

.pt-uvq16-thermal .mk {
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
  transition: translate .25s ease-out;
  pointer-events: none;
}

.pt-uvq16-thermal .mk::before,.pt-uvq16-thermal .mk::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: #fff;
  translate: -50% -50%;
}

.pt-uvq16-thermal .mk::before {
  width: 36px;
  height: 1.5px;
}

.pt-uvq16-thermal .mk::after {
  width: 1.5px;
  height: 36px;
}

.pt-uvq16-thermal .rd {
  position: absolute;
  left: 30px;
  top: -14px;
  white-space: nowrap;
  padding: 3px 5px;
  background: rgba(0,0,0,.55);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion:reduce) {
  .pt-uvq16-thermal .mk {
    transition: none;
  }
}

`;

export default function PatternUvq16Thermal() {
  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 o=document.createElement("canvas"),g=o.getContext("2d"),mk=el.querySelector(".mk"),rd=el.querySelector(".rd");let img,buf,gw=0,gh=0,t=0,lk="",fr=0;const LUT=new Uint32Array(256);
const loop=()=>{const v=V(),p=6,nw=Math.max(4,Math.ceil(W/p)),nh=Math.max(4,Math.ceil(H/p));if(nw!==gw||nh!==gh||!img){gw=nw;gh=nh;o.width=gw;o.height=gh;img=g.createImageData(gw,gh);buf=new Uint32Array(img.data.buffer)}
const ck=v.c1+v.c2+v.c3;if(ck!==lk){lk=ck;const S=[[6,3,15],rgb(v.c1),rgb(v.c2),rgb(v.c3),[255,255,255]],T=[0,.3,.6,.85,1];for(let q=0;q<256;q++){const u=q/255;let s=0;while(s<3&&u>T[s+1])s++;const c=mix(S[s],S[s+1],(u-T[s])/(T[s+1]-T[s]));LUT[q]=((255<<24)|((c[2]|0)<<16)|((c[1]|0)<<8)|(c[0]|0))>>>0}}
t+=.01*v.k;const s0=gh*.075*Math.min(1.6,Math.max(.6,1/v.d)),PE=[0,1,2].map(q=>[(.5+.42*Math.sin(t*(.21+q*.07)+q*2.1))*gw,gh*(.6+q*.04),s0*(1+q*.15)]),hx=m.on?m.x/p:-1e4,hy=m.on?m.y/p:-1e4;
let mx=0,mi=0,mj=0;
for(let j=0;j<gh;j++)for(let i=0;i<gw;i++){let val=.17+.04*Math.sin(i*.08+t)*Math.cos(j*.07-t*.6);
if(i>gw*.06&&i<gw*.32&&j>gh*.1&&j<gh*.42)val-=.1;
const lx=i-gw*.84,ly=j-gh*.2;val+=.75*Math.exp(-(lx*lx+ly*ly)/(s0*s0*.25));const cx=i-gw*.14,cy=j-gh*.82;val+=.55*Math.exp(-(cx*cx+cy*cy*2)/(s0*s0*.35));
for(const e of PE){const dx=i-e[0],dy=j-e[1],s2=e[2]*e[2];val+=.62*Math.exp(-(dx*dx+(dy+e[2]*2)*(dy+e[2]*2))/(s2*.42))+.55*Math.exp(-(dx*dx/(s2*.8)+dy*dy/(s2*2.6)))+.4*Math.exp(-(dx*dx/(s2*.35)+(dy-e[2]*2.4)*(dy-e[2]*2.4)/(s2*2.2)))}
if(hx>-9e3){const dx=i-hx,dy=j-hy;val+=.8*Math.exp(-(dx*dx+dy*dy)/(s0*s0*.5))}
if(val>mx){mx=val;mi=i;mj=j}buf[j*gw+i]=LUT[Math.min(255,Math.max(0,val*255|0))]}
g.putImageData(img,0,0);x.imageSmoothingEnabled=true;x.drawImage(o,0,0,gw*p,gh*p);
if(fr++%6===0){mk.style.translate=(mi*p+p/2)+"px "+(mj*p+p/2)+"px";rd.textContent=(18+Math.min(1,mx)*20).toFixed(1)+"°C"}
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-thermal"
        style={{
          "--c1": "#4c1d95",
          "--c2": "#f0541e",
          "--c3": "#fde68a",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <canvas></canvas><i className="hud"></i><i className="sc"><b>38°</b><b>18°</b></i><i className="mk"><b className="rd">36.0°C</b></i>
      </div>
    </>
  );
}
```

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