// portraitCamera is an init script for the portrait-video gates // (2026-10-21): the page's camera is a canvas held upright, 720 × 1280 — // a phone's camera as a receiver sees it, rotation applied — with a red // band across its top and a green one across its bottom, so a receiver // that shows the whole frame shows both and one that crops to fill shows // neither. window.__turnCamera(w, h) turns it (1280 × 720 is a phone // turned on its side); the captured track follows the canvas's size. The // microphone is still Chromium's fake one. export const portraitCamera = () => { const md = navigator.mediaDevices; if (!md) return; const original = md.getUserMedia.bind(md); const canvas = document.createElement('canvas'); canvas.width = 720; canvas.height = 1280; const g = canvas.getContext('2d'); let t = 0; const draw = () => { const w = canvas.width; const h = canvas.height; const sky = g.createLinearGradient(0, 0, w, h); sky.addColorStop(0, '#6d8fb3'); sky.addColorStop(1, '#2f3d2a'); g.fillStyle = sky; g.fillRect(0, 0, w, h); const u = Math.min(w, h); g.fillStyle = '#c99a78'; g.beginPath(); g.arc(w / 2, h * 0.42, u * 0.2, 0, Math.PI * 2); g.fill(); g.fillStyle = '#7a3b2e'; g.beginPath(); g.ellipse(w / 2, h * 0.42 + u * 0.55, u * 0.42, u * 0.3, 0, 0, Math.PI * 2); g.fill(); g.fillStyle = '#ff0000'; g.fillRect(0, 0, w, Math.round(h * 0.06)); g.fillStyle = '#00ff00'; g.fillRect(0, h - Math.round(h * 0.06), w, Math.round(h * 0.06)); g.fillStyle = '#ffffff'; g.fillRect((t * 7) % w, h * 0.5, 40, 4); t += 1; }; draw(); setInterval(draw, 50); window.__turnCamera = (w, h) => { canvas.width = w; canvas.height = h; draw(); }; md.getUserMedia = async (c = {}) => { const tracks = []; if (c.audio) { const mic = await original({ audio: c.audio }); tracks.push(...mic.getAudioTracks()); } if (c.video) tracks.push(canvas.captureStream(20).getVideoTracks()[0]); return new MediaStream(tracks); }; };