{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"mirror-ball-on-a-chain-that-throws-drifting-flecks-of-coloured-light-across-a-portrait-print","type":"registry:block","title":"Mirror Ball on a Chain That Throws Drifting Flecks of Coloured Light Across a Portrait Print","description":"A tiled mirror ball turns on its chain and scatters flecks of coloured light that reveal a portrait print in a dark room. Free React canvas code and HTML.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/mirror-ball-on-a-chain-that-throws-drifting-flecks-of-coloured-light-across-a-portrait-print.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport type { PointerEvent as ReactPointerEvent } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The print on the wall. */\nconst PHOTO = \"https://images.pexels.com/photos/15759123/pexels-photo-15759123.jpeg?auto=compress&cs=tinysrgb&w=1200\";\nconst PHOTO_ALT = \"Studio portrait of a woman in round sunglasses and a pale jacket, seen in profile with a long ponytail\";\n\n/**\n * Sets of coloured gels for the three spotlights. Each lamp has a colour and the\n * direction it shines from, as seen from the ball: right, down, towards you.\n * Lamps set to the side or overhead throw the squarest flecks on the wall.\n */\nconst gels = [\n  { name: \"Late set\", lamps: [{ tint: [255, 236, 205], from: [-0.2, -1, 0.34] }, { tint: [255, 62, 150], from: [-1, -0.34, 0.26] }, { tint: [70, 170, 255], from: [1, -0.16, 0.3] }] },\n  { name: \"Amber room\", lamps: [{ tint: [255, 222, 170], from: [-0.2, -1, 0.34] }, { tint: [255, 120, 40], from: [-1, -0.34, 0.26] }, { tint: [255, 60, 70], from: [1, -0.16, 0.3] }] },\n  { name: \"Cold blue\", lamps: [{ tint: [235, 244, 255], from: [-0.2, -1, 0.34] }, { tint: [80, 110, 255], from: [-1, -0.34, 0.26] }, { tint: [60, 230, 210], from: [1, -0.16, 0.3] }] },\n];\n\nconst ball = {\n  /** Rows of mirror tiles from pole to pole, and tiles round the equator. */\n  rows: 23,\n  around: 46,\n  /** How unevenly the tiles are glued on, in radians. This is what makes the flecks irregular. */\n  wobble: 0.014,\n  /** Resting speed in turns of a radian per second. */\n  idle: 0.42,\n  /** How far the ball hangs from the wall, as a share of the stage height. */\n  standoff: 0.4,\n  /** How much of full daylight the room keeps. The flecks show the print at full brightness. */\n  room: 0.3,\n};\n\ntype Tile = { c: number[]; n: number[]; q: number[][]; silver: number };\n\nfunction buildTiles(): Tile[] {\n  const tiles: Tile[] = [];\n  let seed = 7;\n  const rnd = () => {\n    seed = (seed * 16807) % 2147483647;\n    return seed / 2147483647;\n  };\n  const at = (lat: number, lon: number) => [Math.cos(lat) * Math.sin(lon), -Math.sin(lat), Math.cos(lat) * Math.cos(lon)];\n  const band = (Math.PI * 0.93) / ball.rows;\n  for (let j = 0; j < ball.rows; j++) {\n    const lat = -Math.PI * 0.465 + band * (j + 0.5);\n    const count = Math.max(6, Math.round(ball.around * Math.cos(lat)));\n    const step = (Math.PI * 2) / count;\n    const shift = rnd() * step * 0.5;\n    for (let i = 0; i < count; i++) {\n      const lon = shift + i * step;\n      const g = 0.46; // a tile fills 92% of its cell; the rest is the dark gap between tiles\n      const q = [at(lat - band * g, lon - step * g), at(lat - band * g, lon + step * g), at(lat + band * g, lon + step * g), at(lat + band * g, lon - step * g)];\n      const c = at(lat, lon);\n      const n = [c[0] + (rnd() - 0.5) * 2 * ball.wobble, c[1] + (rnd() - 0.5) * 2 * ball.wobble, c[2] + (rnd() - 0.5) * 2 * ball.wobble];\n      const l = Math.hypot(n[0], n[1], n[2]);\n      tiles.push({ c, n: [n[0] / l, n[1] / l, n[2] / l], q, silver: 0.72 + rnd() * 0.4 });\n    }\n  }\n  return tiles;\n}\n\nconst unit = (v: number[]) => {\n  const l = Math.hypot(v[0], v[1], v[2]) || 1;\n  return [v[0] / l, v[1] / l, v[2] / l];\n};\n\nexport default function MirrorBallPortrait() {\n  const reduce = useReducedMotion();\n  const stage = useRef<HTMLDivElement>(null);\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const print = useRef<HTMLImageElement>(null);\n  const orb = useRef<HTMLButtonElement>(null);\n  const [gel, setGel] = useState(0);\n  const gelNow = useRef(0);\n  gelNow.current = gel;\n  const spin = useRef({ speed: ball.idle, dir: 1, drag: false, lastX: 0, lastT: 0, travelled: 0 });\n  const spot = useRef({ x: 0, y: 0 });\n  const redraw = useRef<() => void>(() => {});\n\n  useEffect(() => {\n    const cv = canvas.current;\n    const el = stage.current;\n    const img = print.current;\n    const orbEl = orb.current;\n    const ctx = cv?.getContext(\"2d\");\n    if (!cv || !el || !img || !orbEl || !ctx) return;\n\n    const tiles = buildTiles();\n    const dim = document.createElement(\"canvas\");\n    const lit = document.createElement(\"canvas\");\n    const light = document.createElement(\"canvas\");\n    const px = light.getContext(\"2d\")!;\n    const mask = document.createElement(\"canvas\");\n    const mx2 = mask.getContext(\"2d\")!;\n    const glowDot = document.createElement(\"canvas\");\n    glowDot.width = glowDot.height = 64;\n    {\n      const g = glowDot.getContext(\"2d\")!;\n      const grad = g.createRadialGradient(32, 32, 0, 32, 32, 32);\n      grad.addColorStop(0, \"rgba(255,255,255,1)\");\n      grad.addColorStop(0.18, \"rgba(255,255,255,0.55)\");\n      grad.addColorStop(0.5, \"rgba(255,255,255,0.1)\");\n      grad.addColorStop(1, \"rgba(255,255,255,0)\");\n      g.fillStyle = grad;\n      g.fillRect(0, 0, 64, 64);\n    }\n\n    const grainTile = document.createElement(\"canvas\");\n    grainTile.width = grainTile.height = 128;\n    {\n      const g = grainTile.getContext(\"2d\")!;\n      const data = g.createImageData(128, 128);\n      let seed = 11;\n      for (let i = 0; i < data.data.length; i += 4) {\n        seed = (seed * 16807) % 2147483647;\n        const v = seed % 256;\n        data.data[i] = data.data[i + 1] = data.data[i + 2] = v;\n        data.data[i + 3] = 255;\n      }\n      g.putImageData(data, 0, 0);\n    }\n\n    // One soft disc of light per lamp, white-hot in the middle.\n    const blobs: { key: string; cv: HTMLCanvasElement }[] = [];\n    const blobFor = (k: number, tint: number[]) => {\n      const key = tint.join(\",\");\n      if (blobs[k]?.key === key) return blobs[k].cv;\n      const c = document.createElement(\"canvas\");\n      c.width = c.height = 96;\n      const g = c.getContext(\"2d\")!;\n      const grad = g.createRadialGradient(48, 48, 0, 48, 48, 48);\n      const hot = tint.map((v) => Math.round(v + (255 - v) * 0.55)).join(\",\");\n      grad.addColorStop(0, `rgba(${hot},1)`);\n      grad.addColorStop(0.55, `rgba(${key},1)`);\n      grad.addColorStop(0.74, `rgba(${key},0.72)`);\n      grad.addColorStop(0.88, `rgba(${key},0.12)`);\n      grad.addColorStop(1, `rgba(${key},0)`);\n      g.fillStyle = grad;\n      g.fillRect(0, 0, 96, 96);\n      blobs[k] = { key, cv: c };\n      return c;\n    };\n\n    let W = 1;\n    let H = 1;\n    let dpr = 1;\n    let bx = 0;\n    let by = 0;\n    let R = 60;\n    let angle = 0.6;\n    let raf = 0;\n    let visible = true;\n    let before = 0;\n    const key = { x: 0, y: 0 };\n\n    /** The room twice over: once as it looks in the dark, once as it would look fully lit. */\n    const paintRoom = () => {\n      const s = el.getBoundingClientRect();\n      const p = img.getBoundingClientRect();\n      const px = p.left - s.left;\n      const py = p.top - s.top;\n      const edge = Math.max(5, p.width * 0.026);\n      for (const [target, bright] of [[dim, false], [lit, true]] as const) {\n        target.width = cv.width;\n        target.height = cv.height;\n        const c = target.getContext(\"2d\")!;\n        c.setTransform(dpr, 0, 0, dpr, 0, 0);\n        // The painted wall, a little lighter where the room's own light pools.\n        const wall = c.createRadialGradient(W * 0.5, H * 0.46, 0, W * 0.5, H * 0.46, Math.max(W, H) * 0.75);\n        if (bright) {\n          wall.addColorStop(0, \"#b9b0bd\");\n          wall.addColorStop(1, \"#8f8695\");\n        } else {\n          wall.addColorStop(0, \"#191520\");\n          wall.addColorStop(1, \"#0a080d\");\n        }\n        c.fillStyle = wall;\n        c.fillRect(0, 0, W, H);\n        // Fine plaster grain, which also keeps the dark gradient from showing bands.\n        c.globalAlpha = bright ? 0.04 : 0.03;\n        c.fillStyle = c.createPattern(grainTile, \"repeat\")!;\n        c.fillRect(0, 0, W, H);\n        c.globalAlpha = 1;\n        // The print: a soft shadow under it, its white paper border, then the photograph.\n        if (!bright) {\n          c.shadowColor = \"rgba(0,0,0,0.75)\";\n          c.shadowBlur = 44;\n          c.shadowOffsetY = 22;\n        }\n        c.fillStyle = bright ? \"#f6f2ea\" : \"#2f2c33\";\n        c.fillRect(px - edge, py - edge, p.width + edge * 2, p.height + edge * 2);\n        c.shadowColor = \"transparent\";\n        if (img.complete && img.naturalWidth > 0) {\n          const scale = Math.max(p.width / img.naturalWidth, p.height / img.naturalHeight);\n          const sw = p.width / scale;\n          const sh = p.height / scale;\n          c.drawImage(img, (img.naturalWidth - sw) / 2, (img.naturalHeight - sh) * 0.3, sw, sh, px, py, p.width, p.height);\n        } else {\n          c.fillStyle = \"#8d8a8c\";\n          c.fillRect(px, py, p.width, p.height);\n        }\n        if (!bright) {\n          c.fillStyle = `rgba(9,7,16,${1 - ball.room})`;\n          c.fillRect(px, py, p.width, p.height);\n        }\n      }\n    };\n\n    const resize = () => {\n      const s = el.getBoundingClientRect();\n      W = Math.max(1, s.width);\n      H = Math.max(1, s.height);\n      dpr = Math.min(Math.max(window.devicePixelRatio || 1, 1), 1.5);\n      cv.width = Math.round(W * dpr);\n      cv.height = Math.round(H * dpr);\n      light.width = cv.width;\n      light.height = cv.height;\n      mask.width = Math.ceil(cv.width / 2);\n      mask.height = Math.ceil(cv.height / 2);\n      const o = orbEl.getBoundingClientRect();\n      R = o.width / 2;\n      bx = o.left - s.left + R;\n      by = o.top - s.top + R;\n      paintRoom();\n      draw();\n    };\n\n    const draw = () => {\n      const lamps = gels[gelNow.current].lamps;\n      const D = H * ball.standoff;\n      const far = H * 0.95;\n      const cos = Math.cos(angle);\n      const sin = Math.sin(angle);\n      const turn = (v: number[]) => [v[0] * cos + v[2] * sin, v[1], -v[0] * sin + v[2] * cos];\n      const lampAt = lamps.map((l, k) => {\n        const d = unit(k === 0 ? [l.from[0] + key.x * 0.5, l.from[1] + key.y * 0.4, l.from[2]] : l.from);\n        return { dir: d, pos: [bx + d[0] * far, by + d[1] * far, D + d[2] * far], tint: l.tint };\n      });\n\n      // 1. The flecks, drawn white-hot in each lamp's colour on black.\n      const lx = mx2;\n      lx.setTransform(dpr * 0.5, 0, 0, dpr * 0.5, 0, 0);\n      lx.globalCompositeOperation = \"source-over\";\n      lx.fillStyle = \"#000\";\n      lx.fillRect(0, 0, W, H);\n      lx.globalCompositeOperation = \"lighter\";\n      const side = (R * Math.PI * 2) / ball.around;\n      const flashes: number[][] = [];\n      const turned = tiles.map((t) => ({ c: turn(t.c), n: turn(t.n), q: t.q.map(turn), silver: t.silver }));\n      lampAt.forEach((lamp, k) => {\n        const blob = blobFor(k, lamp.tint);\n        for (const t of turned) {\n          const cx = bx + t.c[0] * R;\n          const cy = by + t.c[1] * R;\n          const cz = D + t.c[2] * R;\n          let ix = cx - lamp.pos[0];\n          let iy = cy - lamp.pos[1];\n          let iz = cz - lamp.pos[2];\n          // The tile must be on the lit side of the ball and face the lamp.\n          if (ix * t.c[0] + iy * t.c[1] + iz * t.c[2] >= 0) continue;\n          const il = Math.hypot(ix, iy, iz);\n          ix /= il; iy /= il; iz /= il;\n          const dn = ix * t.n[0] + iy * t.n[1] + iz * t.n[2];\n          if (dn >= 0) continue;\n          const rx = ix - 2 * dn * t.n[0];\n          const ry = iy - 2 * dn * t.n[1];\n          const rz = iz - 2 * dn * t.n[2];\n          if (rz > -0.2) continue; // heading away from the wall, or skimming it\n          const reach = -cz / rz;\n          const x = cx + rx * reach;\n          const y = cy + ry * reach;\n          if (x < -90 || x > W + 90 || y < -90 || y > H + 90) continue;\n          // A fleck is a small picture of the lamp, so it is round, grows with distance\n          // and stretches where it lands on the wall at a slant.\n          const rad = side * (0.5 + (0.46 * reach) / D);\n          const stretch = Math.min(1 / -rz, 3);\n          lx.globalAlpha = Math.min(1, Math.max(0.2, (1.3 * D) / reach)) * Math.min(1, 1.7 / stretch) * t.silver;\n          lx.save();\n          lx.translate(x, y);\n          lx.rotate(Math.atan2(ry, rx));\n          lx.scale(stretch, 1);\n          lx.drawImage(blob, -rad, -rad, rad * 2, rad * 2);\n          lx.restore();\n        }\n      });\n      lx.globalAlpha = 1;\n      // The flecks were drawn at half size, so scaling them up softens their edges a touch.\n      px.setTransform(1, 0, 0, 1, 0, 0);\n      px.globalCompositeOperation = \"source-over\";\n      px.imageSmoothingQuality = \"high\";\n      px.drawImage(mask, 0, 0, light.width, light.height);\n      px.globalCompositeOperation = \"multiply\";\n      px.drawImage(lit, 0, 0);\n\n      // 3. The dark room, plus the light.\n      ctx.setTransform(1, 0, 0, 1, 0, 0);\n      ctx.globalCompositeOperation = \"source-over\";\n      ctx.drawImage(dim, 0, 0);\n      ctx.globalCompositeOperation = \"lighter\";\n      ctx.drawImage(light, 0, 0);\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n\n      // 4. A trace of haze in each beam on its way to the ball.\n      for (const lamp of lampAt) {\n        const ox = bx + lamp.dir[0] * far * 0.9;\n        const oy = by + lamp.dir[1] * far * 0.9;\n        const len = Math.hypot(ox - bx, oy - by) || 1;\n        const nx = (-(oy - by) / len) * R;\n        const ny = ((ox - bx) / len) * R;\n        const grad = ctx.createLinearGradient(ox, oy, bx, by);\n        grad.addColorStop(0, `rgba(${lamp.tint.join(\",\")},0)`);\n        grad.addColorStop(1, `rgba(${lamp.tint.join(\",\")},0.11)`);\n        ctx.fillStyle = grad;\n        ctx.beginPath();\n        ctx.moveTo(ox + nx * 0.35, oy + ny * 0.35);\n        ctx.lineTo(bx + nx, by + ny);\n        ctx.lineTo(bx - nx, by - ny);\n        ctx.lineTo(ox - nx * 0.35, oy - ny * 0.35);\n        ctx.closePath();\n        ctx.fill();\n      }\n\n      // 5. The ball: its chain and cap, a dark core, then every tile that faces us.\n      ctx.globalCompositeOperation = \"source-over\";\n      ctx.strokeStyle = \"#57525c\";\n      ctx.lineWidth = 1.6;\n      ctx.setLineDash([5, 3]);\n      ctx.beginPath();\n      ctx.moveTo(bx, 0);\n      ctx.lineTo(bx, by - R - 6);\n      ctx.stroke();\n      ctx.setLineDash([]);\n      const cap = ctx.createLinearGradient(bx - R * 0.2, 0, bx + R * 0.2, 0);\n      cap.addColorStop(0, \"#2b282f\");\n      cap.addColorStop(0.4, \"#b9b4bd\");\n      cap.addColorStop(1, \"#3a363e\");\n      ctx.fillStyle = cap;\n      ctx.fillRect(bx - R * 0.16, by - R - 8, R * 0.32, 12);\n      ctx.fillStyle = \"#07060a\";\n      ctx.beginPath();\n      ctx.arc(bx, by, R * 0.995, 0, Math.PI * 2);\n      ctx.fill();\n      for (const t of turned) {\n        if (t.c[2] < 0.03) continue;\n        // What this tile mirrors back at the viewer.\n        const nz = t.n[2];\n        const rx = 2 * nz * t.n[0];\n        const ry = 2 * nz * t.n[1];\n        const rz = 2 * nz * nz - 1;\n        let r = 20 + 54 * Math.max(0, -ry);\n        let g = 19 + 50 * Math.max(0, -ry);\n        let b = 26 + 60 * Math.max(0, -ry);\n        if (rz < 0) { r += 26; g += 22; b += 30; }\n        let hot = 0;\n        for (const lamp of lampAt) {\n          const d = Math.max(0, rx * lamp.dir[0] + ry * lamp.dir[1] + rz * lamp.dir[2]);\n          const wash = d * d * 0.5;\n          const flash = Math.pow(d, 150) * 3.2;\n          r += lamp.tint[0] * (wash + flash);\n          g += lamp.tint[1] * (wash + flash);\n          b += lamp.tint[2] * (wash + flash);\n          if (flash > 0.9) { hot = Math.max(hot, flash); flashes.push([bx + t.c[0] * R, by + t.c[1] * R, Math.min(1, flash / 2.4), lamp.tint[0], lamp.tint[1], lamp.tint[2]]); }\n        }\n        const k = t.silver * (0.55 + 0.45 * t.c[2]);\n        ctx.fillStyle = hot > 1.6 ? \"#fff\" : `rgb(${Math.min(255, r * k) | 0},${Math.min(255, g * k) | 0},${Math.min(255, b * k) | 0})`;\n        ctx.beginPath();\n        ctx.moveTo(bx + t.q[0][0] * R, by + t.q[0][1] * R);\n        ctx.lineTo(bx + t.q[1][0] * R, by + t.q[1][1] * R);\n        ctx.lineTo(bx + t.q[2][0] * R, by + t.q[2][1] * R);\n        ctx.lineTo(bx + t.q[3][0] * R, by + t.q[3][1] * R);\n        ctx.closePath();\n        ctx.fill();\n      }\n      // Roundness: the rim falls away from the light, with a faint sheen up and to the left.\n      const shade = ctx.createRadialGradient(bx - R * 0.28, by - R * 0.34, R * 0.1, bx, by, R);\n      shade.addColorStop(0, \"rgba(255,255,255,0.1)\");\n      shade.addColorStop(0.45, \"rgba(0,0,0,0)\");\n      shade.addColorStop(0.86, \"rgba(0,0,0,0.3)\");\n      shade.addColorStop(1, \"rgba(0,0,0,0.72)\");\n      ctx.fillStyle = shade;\n      ctx.beginPath();\n      ctx.arc(bx, by, R, 0, Math.PI * 2);\n      ctx.fill();\n      // The tiles that catch a lamp head-on flare.\n      ctx.globalCompositeOperation = \"lighter\";\n      for (const f of flashes) {\n        const size = R * (0.5 + f[2] * 0.9);\n        ctx.globalAlpha = 0.35 + f[2] * 0.6;\n        ctx.drawImage(glowDot, f[0] - size / 2, f[1] - size / 2, size, size);\n      }\n      ctx.globalAlpha = 1;\n      ctx.globalCompositeOperation = \"source-over\";\n    };\n    redraw.current = draw;\n\n    const loop = (now: number) => {\n      raf = requestAnimationFrame(loop);\n      const dt = Math.min((now - (before || now)) / 1000, 0.05);\n      before = now;\n      const s = spin.current;\n      // Friction brings a flicked ball back to its resting speed, in whichever direction it was sent.\n      if (!s.drag) s.speed += (ball.idle * s.dir - s.speed) * (1 - Math.exp(-dt * 0.9));\n      angle += s.speed * dt;\n      const k = 1 - Math.exp(-dt * 3.5);\n      key.x += (spot.current.x - key.x) * k;\n      key.y += (spot.current.y - key.y) * k;\n      draw();\n    };\n    const wake = () => {\n      cancelAnimationFrame(raf);\n      raf = 0;\n      before = 0;\n      if (reduce) draw();\n      else if (visible && !document.hidden) raf = requestAnimationFrame(loop);\n    };\n\n    const ro = new ResizeObserver(resize);\n    ro.observe(el);\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      wake();\n    });\n    io.observe(el);\n    const arrived = () => {\n      paintRoom();\n      draw();\n    };\n    img.addEventListener(\"load\", arrived);\n    document.addEventListener(\"visibilitychange\", wake);\n    resize();\n    wake();\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      img.removeEventListener(\"load\", arrived);\n      document.removeEventListener(\"visibilitychange\", wake);\n    };\n  }, [reduce]);\n\n  useEffect(() => {\n    redraw.current();\n  }, [gel]);\n\n  function down(e: ReactPointerEvent<HTMLDivElement>) {\n    spin.current.drag = true;\n    spin.current.lastX = e.clientX;\n    spin.current.lastT = performance.now();\n    spin.current.travelled = 0;\n  }\n  function move(e: ReactPointerEvent<HTMLDivElement>) {\n    const r = e.currentTarget.getBoundingClientRect();\n    spot.current = { x: ((e.clientX - r.left) / r.width) * 2 - 1, y: ((e.clientY - r.top) / r.height) * 2 - 1 };\n    const s = spin.current;\n    if (!s.drag || reduce) return;\n    const now = performance.now();\n    const dt = Math.max(8, now - s.lastT) / 1000;\n    const pushed = (e.clientX - s.lastX) / dt / 90;\n    s.speed = Math.max(-7, Math.min(7, s.speed * 0.6 + pushed * 0.4));\n    if (Math.abs(s.speed) > 0.2) s.dir = Math.sign(s.speed);\n    s.travelled += Math.abs(e.clientX - s.lastX);\n    s.lastX = e.clientX;\n    s.lastT = now;\n  }\n  function up() {\n    spin.current.drag = false;\n  }\n  /** A click or key press on the ball is a shove against the way it is turning. */\n  function shove() {\n    const s = spin.current;\n    if (s.travelled > 8) return; // that was a flick, not a press\n    s.dir = -s.dir;\n    s.speed = reduce ? ball.idle * s.dir : 5.5 * s.dir;\n    if (reduce) redraw.current();\n  }\n\n  return (\n    <section className=\"relative isolate w-full overflow-hidden bg-[#0a080d]\">\n      <div\n        ref={stage}\n        onPointerDown={down}\n        onPointerMove={move}\n        onPointerUp={up}\n        onPointerLeave={up}\n        onPointerCancel={up}\n        className=\"relative h-[620px] w-full cursor-grab touch-pan-y select-none active:cursor-grabbing md:h-[700px]\"\n      >\n        <img\n          ref={print}\n          src={PHOTO}\n          alt={PHOTO_ALT}\n          width={800}\n          height={1200}\n          draggable={false}\n          className=\"absolute left-1/2 top-[52%] aspect-[2/3] h-[68%] w-auto max-w-[78%] -translate-x-1/2 -translate-y-1/2 bg-[#8d8a8c] object-cover object-[50%_30%] md:left-[56%] md:h-[80%]\"\n        />\n        <canvas ref={canvas} aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full\" />\n        <button\n          ref={orb}\n          type=\"button\"\n          onClick={shove}\n          aria-label=\"Mirror ball. Press to shove it the other way round.\"\n          className=\"absolute left-[9%] top-[8%] aspect-square w-[30%] max-w-[150px] rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-4 focus-visible:ring-offset-[#0a080d] md:left-[28%] md:top-[8%] md:w-[190px] md:max-w-none\"\n        />\n      </div>\n\n      <div className=\"pointer-events-none absolute inset-x-0 bottom-0 flex items-end justify-between gap-4 px-5 pb-5 sm:px-8 sm:pb-7\">\n        <p className=\"text-[13px] leading-5 text-[#cfc8d6]\">\n          <span className=\"font-semibold text-white\">Mirror ball</span>\n          <span className=\"mx-2 text-[#7d7587]\">/</span>\n          flick it sideways to spin\n        </p>\n        <button\n          type=\"button\"\n          onClick={() => setGel((g) => (g + 1) % gels.length)}\n          className=\"pointer-events-auto inline-flex h-10 shrink-0 items-center gap-2.5 rounded-full bg-black/50 pl-3 pr-4 text-[13px] font-medium text-white ring-1 ring-white/15 backdrop-blur transition-colors hover:bg-black/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white\"\n        >\n          <span aria-hidden=\"true\" className=\"flex -space-x-1\">\n            {gels[gel].lamps.map((l, i) => (\n              <span key={i} className=\"h-3 w-3 rounded-full ring-1 ring-black/40\" style={{ backgroundColor: `rgb(${l.tint.join(\",\")})` }} />\n            ))}\n          </span>\n          <span>\n            <span className=\"sr-only\">Change the lamp colours. Now showing </span>\n            {gels[gel].name}\n          </span>\n        </button>\n      </div>\n    </section>\n  );\n}\n"}]}
