Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: tv off
kapishdimabaeace1a0042
diff --git a/components/docs/examples/tv-power-off-example.tsx b/components/docs/examples/tv-power-off-example.tsxnew file mode 100644index 00000000..ceee0a11--- /dev/null+++ b/components/docs/examples/tv-power-off-example.tsx@@ -0,0 +1,49 @@+"use client";++import { CanvasSceneB } from "@/components/docs/examples/canvas-scenes";+import { TvPowerOff } from "@/registry/remocn/tv-power-off";++interface TvPowerOffExampleProps {+ durationInFrames?: number;+ gain?: number;+ afterglow?: number;+ phosphor?: string;+}++const LEAD = 25;++export function TvPowerOffExampleScene({+ durationInFrames,+ gain,+ afterglow,+ phosphor,+}: TvPowerOffExampleProps) {+ return (+ <TvPowerOff+ delay={LEAD}+ durationInFrames={durationInFrames}+ gain={gain}+ afterglow={afterglow}+ phosphor={phosphor}+ >+ <CanvasSceneB />+ </TvPowerOff>+ );+}++export const tvPowerOffExampleCode = (+ values: Record<string, unknown>,+): string => {+ const durationInFrames = (values.durationInFrames as number) ?? 18;+ const gain = (values.gain as number) ?? 1;+ const afterglow = (values.afterglow as number) ?? 1;+ const phosphor = (values.phosphor as string) ?? "#d8ecff";++ return `import { TvPowerOff } from "@/components/remocn/tv-power-off";++export const MyScene = () => (+ <TvPowerOff delay={${LEAD}} durationInFrames={${durationInFrames}} gain={${gain}} afterglow={${afterglow}} phosphor="${phosphor}">+ <Scene />+ </TvPowerOff>+);`;+};diff --git a/content/docs/effects/index.mdx b/content/docs/effects/index.mdxindex 96e48a65..32e837bd 100644--- a/content/docs/effects/index.mdx+++ b/content/docs/effects/index.mdx@@ -7,6 +7,12 @@ Drop-in effect overlays you compose on top of any scene — fire them on a frame<ComponentCardGriditems={[+ {+ name: "TV Power Off",+ description: "Collapses a scene into a glowing line and a phosphor dot the way a tube switches off, leaving the frame dead black",+ status: "stable",+ href: "/docs/effects/tv-power-off",+ },{name: "Confetti",description: "Deterministic confetti burst — seeded particles with gravity, spin, and flutter, fired on any frame",diff --git a/content/docs/effects/meta.json b/content/docs/effects/meta.jsonindex 172481bf..595d5a63 100644--- a/content/docs/effects/meta.json+++ b/content/docs/effects/meta.json@@ -3,6 +3,7 @@"defaultOpen": true,"pages": ["index",+ "tv-power-off","confetti","paper-wobble","ink-arrow",diff --git a/content/docs/effects/tv-power-off.mdx b/content/docs/effects/tv-power-off.mdxnew file mode 100644index 00000000..23d887b2--- /dev/null+++ b/content/docs/effects/tv-power-off.mdx@@ -0,0 +1,117 @@+---+title: TV Power Off+description: End a scene the way a tube does — the picture collapses into a glowing line, pinches to a phosphor dot, and the frame is left dead black+component: tv-power-off+vibe: tech+length: 18+useWhen:+ - "A scene should end like a device being switched off rather than fading out — the picture collapses, a dot lingers, and the frame is dead."+ - "The video is about something that lives on a screen — a terminal, a dashboard, a retro build — and powering it down is the punctuation the story already implies."+ - "A beat needs a hard, unambiguous end: everything after the collapse is black, so whatever you cut to next starts from nothing."+avoidWhen:+ - "The tube look should hold for the whole scene instead of ending it — use `crt-screen`, which is a sustained filter with no duration of its own."+ - "Both scenes should be visible while the change happens — this plays over one scene at a time, so reach for a transition such as `glitch-cut`."+ - "The frame has to stay transparent over a backdrop once the scene is gone, since what this leaves behind is opaque black."+---++<ComponentPreview name="tv-power-off" />++<CanvasFilterNote />++## Installation++<InstallBlock name="tv-power-off" />++## Usage++Wrap a scene and, on the frame you point it at, its power is cut. The picture+squashes toward the centre line while the light it loses is pushed into what is+left, so the last few rows are a blown-out band rather than a squashed+thumbnail. The band pinches to a dot, the dot decays, and the frame is black.++```tsx+import { TvPowerOff } from "@/components/remocn/tv-power-off";++export const MyScene = () => (+ <TvPowerOff delay={25}>+ <Outro />+ </TvPowerOff>+);+```++## Timing it++`delay` is counted from the start of the enclosing `Sequence`, so the scene+plays untouched for `delay` frames and the collapse runs for the next+`durationInFrames`. Budget both: a `Sequence` that ends before+`delay + durationInFrames` cuts away mid-collapse.++The default 18 frames is a hard power cut. Stretch it toward 30 and the line+hangs long enough to read as a tube giving up rather than being switched.++```tsx+<TvPowerOff delay={60} durationInFrames={26}>+ <Scene />+</TvPowerOff>+```++## Props++<PropsTable+ rows={[+ {+ name: "durationInFrames",+ type: "number",+ default: "18",+ description:+ "How long the whole collapse takes. The first 60% is the vertical squash, the next 22% pinches the line to a dot, and the rest is the dot decaying.",+ },+ {+ name: "delay",+ type: "number",+ default: "0",+ description:+ "Frames of untouched scene before the collapse starts, counted from the enclosing Sequence.",+ },+ {+ name: "gain",+ type: "number",+ default: "1",+ description:+ "How hard the picture brightens as it is squashed. At 1 the light lost to the collapse is pushed back into the remaining rows, which is what blows the line out to white. At 0 the picture simply shrinks.",+ },+ {+ name: "afterglow",+ type: "number",+ default: "1",+ description:+ "Reach of the phosphor bleed — the glow that spills above and below the line, and the halo around the dot. At 0 the collapse is geometry only.",+ },+ {+ name: "phosphor",+ type: "string",+ default: '"#d8ecff"',+ description:+ "Colour of that glow. The cool white of a monochrome tube by default; warm it toward amber for an older terminal.",+ },+ {+ name: "children",+ type: "React.ReactNode",+ description: "The scene being switched off.",+ },+ ]}+/>++## Notes++The squash is an integral, not a scale. Every output row averages the source+rows that collapse into it, so text does not alias into stripes on the way down+and the line keeps the horizontal colour of the columns above it — that is why+the last frames of the band still carry the scene rather than a grey smear.++Once the collapse begins the frame behind the picture is opaque black, and it+stays black after the dot is gone. That is a dead screen rather than a hole, so+do not expect a backdrop to show through afterwards.++Nothing is carried between frames: progress is a pure function of the current+frame, so parallel and server-side renders produce identical pixels.diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.jsonindex c8417c64..869659ea 100644--- a/registry-artifacts/registry.json+++ b/registry-artifacts/registry.json@@ -1704,6 +1704,21 @@],"type": "registry:component"},+ {+ "name": "tv-power-off",+ "title": "TV Power Off",+ "description": "End a scene the way a tube does: the picture collapses into a glowing horizontal line, the line pinches to a phosphor dot, the dot decays, and the frame is left dead black.",+ "dependencies": ["remotion"],+ "registryDependencies": ["@remocn/canvas-presentation"],+ "files": [+ {+ "path": "registry/remocn/tv-power-off/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/tv-power-off.tsx"+ }+ ],+ "type": "registry:component"+ },{"name": "camera-lens","title": "Camera Lens",diff --git a/registry-artifacts/tv-power-off.json b/registry-artifacts/tv-power-off.jsonnew file mode 100644index 00000000..301aeced--- /dev/null+++ b/registry-artifacts/tv-power-off.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "tv-power-off",+ "title": "TV Power Off",+ "description": "End a scene the way a tube does: the picture collapses into a glowing horizontal line, the line pinches to a phosphor dot, the dot decays, and the frame is left dead black.",+ "dependencies": ["remotion"],+ "registryDependencies": ["@remocn/canvas-presentation"],+ "files": [+ {+ "path": "registry/remocn/tv-power-off/index.tsx",+ "content": "\"use client\";\n\nimport type React from \"react\";\nimport { AbsoluteFill, useCurrentFrame } from \"remotion\";\nimport {\n type CanvasFilterProps,\n makeCanvasFilter,\n makeFilterShader,\n} from \"@/lib/remocn/canvas-presentation\";\n\nexport type TvPowerOffProps = {\n durationInFrames?: number;\n delay?: number;\n gain?: number;\n afterglow?: number;\n phosphor?: string;\n};\n\nconst DEFAULTS = {\n durationInFrames: 18,\n delay: 0,\n gain: 1,\n afterglow: 1,\n phosphor: \"#d8ecff\",\n};\n\nconst COLLAPSE_END = 0.6;\nconst PINCH_END = 0.82;\nconst MIN_SQUASH = 0.0055;\nconst MIN_PINCH = 0.004;\nconst CONCENTRATION = 0.3;\nconst DECAY_CURVE = 2.6;\nconst BLACKOUT_IN = 0.06;\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform vec2 u_resolution;\nuniform float u_aspect;\nuniform float u_progress;\nuniform float u_gain;\nuniform float u_afterglow;\nuniform vec3 u_phosphor;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst int TAPS = 32;\nconst int COLUMN_TAPS = 8;\nconst float GOLDEN = 0.6180339887;\nconst float COLLAPSE_END = ${COLLAPSE_END.toFixed(4)};\nconst float PINCH_END = ${PINCH_END.toFixed(4)};\nconst float MIN_SQUASH = ${MIN_SQUASH.toFixed(5)};\nconst float MIN_PINCH = ${MIN_PINCH.toFixed(5)};\nconst float CONCENTRATION = ${CONCENTRATION.toFixed(4)};\nconst float DECAY_CURVE = ${DECAY_CURVE.toFixed(4)};\nconst float BLACKOUT_IN = ${BLACKOUT_IN.toFixed(4)};\n\nvoid main() {\n float p = u_progress;\n\n if (p <= 0.0) {\n outColor = texture(u_scene, v_uv);\n return;\n }\n if (p >= 1.0) {\n outColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n\n float collapse = clamp(p / COLLAPSE_END, 0.0, 1.0);\n float pinch = clamp((p - COLLAPSE_END) / (PINCH_END - COLLAPSE_END), 0.0, 1.0);\n float decayed = clamp((p - PINCH_END) / (1.0 - PINCH_END), 0.0, 1.0);\n\n vec2 scale = vec2(pow(MIN_PINCH, pinch), pow(MIN_SQUASH, collapse));\n vec2 centered = (v_uv - 0.5) / scale + 0.5;\n vec2 span = 1.0 / (scale * u_resolution);\n\n vec3 sum = vec3(0.0);\n for (int i = 0; i < TAPS; i++) {\n float fi = float(i);\n vec2 at = centered + vec2(\n (fract(fi * GOLDEN + 0.5) - 0.5) * span.x,\n ((fi + 0.5) / float(TAPS) - 0.5) * span.y\n );\n vec2 inside = step(vec2(0.0), at) * step(at, vec2(1.0));\n sum += texture(u_scene, at).rgb * inside.x * inside.y;\n }\n\n float concentrate = pow(1.0 / (scale.x * scale.y), CONCENTRATION);\n vec3 light =\n (sum / float(TAPS)) * (1.0 + (concentrate - 1.0) * max(u_gain, 0.0));\n\n float glow = max(u_afterglow, 0.0);\n float bleed = smoothstep(0.2, 0.8, collapse) * (1.0 - pinch) * glow;\n\n if (bleed > 0.0) {\n vec3 column = vec3(0.0);\n float cx = clamp(centered.x, 0.0, 1.0);\n for (int i = 0; i < COLUMN_TAPS; i++) {\n column +=\n texture(u_scene, vec2(cx, (float(i) + 0.5) / float(COLUMN_TAPS))).rgb;\n }\n column /= float(COLUMN_TAPS);\n\n float dy = v_uv.y - 0.5;\n float reach = 0.02 + 0.03 * collapse;\n light +=\n column *\n mix(vec3(1.0), u_phosphor, 0.65) *\n exp(-(dy * dy) / (reach * reach)) *\n bleed *\n 0.9;\n }\n\n if (pinch > 0.0) {\n vec2 d = (v_uv - 0.5) * vec2(u_aspect, 1.0);\n float radius = max(0.045 * glow, 0.0005);\n light +=\n u_phosphor *\n exp(-dot(d, d) / (radius * radius)) *\n smoothstep(0.0, 0.5, pinch) *\n 1.15;\n }\n\n light *= pow(max(1.0 - decayed, 0.0001), DECAY_CURVE);\n\n float blackout = smoothstep(0.0, BLACKOUT_IN, p);\n outColor = vec4(\n clamp(light, 0.0, 1.0),\n mix(texture(u_scene, v_uv).a, 1.0, blackout)\n );\n}`;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nfunction toRgb(hex: string): [number, number, number] {\n const value = hex.replace(\"#\", \"\");\n const full =\n value.length === 3\n ? value\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : value;\n const int = Number.parseInt(full, 16);\n if (Number.isNaN(int)) return [1, 1, 1];\n return [\n ((int >> 16) & 255) / 255,\n ((int >> 8) & 255) / 255,\n (int & 255) / 255,\n ];\n}\n\nfunction powerProgress(props: TvPowerOffProps, frame: number): number {\n const {\n durationInFrames = DEFAULTS.durationInFrames,\n delay = DEFAULTS.delay,\n } = props;\n return clamp((frame - delay) / Math.max(1, durationInFrames), 0, 1);\n}\n\nconst shader = makeFilterShader<TvPowerOffProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, width, height, frame, passedProps }) => {\n const {\n gain = DEFAULTS.gain,\n afterglow = DEFAULTS.afterglow,\n phosphor = DEFAULTS.phosphor,\n } = passedProps;\n gl.uniform1f(uniform(\"u_progress\"), powerProgress(passedProps, frame));\n gl.uniform2f(uniform(\"u_resolution\"), width, height);\n gl.uniform1f(uniform(\"u_gain\"), gain);\n gl.uniform1f(uniform(\"u_afterglow\"), afterglow);\n gl.uniform3fv(uniform(\"u_phosphor\"), toRgb(phosphor));\n },\n);\n\nconst TvPowerOffFallback: React.FC<TvPowerOffProps & CanvasFilterProps> = (\n props,\n) => {\n const frame = useCurrentFrame();\n const {\n children,\n gain = DEFAULTS.gain,\n afterglow = DEFAULTS.afterglow,\n phosphor = DEFAULTS.phosphor,\n } = props;\n\n const p = powerProgress(props, frame);\n const collapse = clamp(p / COLLAPSE_END, 0, 1);\n const pinch = clamp((p - COLLAPSE_END) / (PINCH_END - COLLAPSE_END), 0, 1);\n const decayed = clamp((p - PINCH_END) / (1 - PINCH_END), 0, 1);\n\n const squash = MIN_SQUASH ** collapse;\n const pinchX = MIN_PINCH ** pinch;\n const concentrate = (1 / (squash * pinchX)) ** CONCENTRATION;\n const fade = (1 - decayed) ** DECAY_CURVE;\n\n return (\n <AbsoluteFill>\n <AbsoluteFill\n style={{\n background: \"#000000\",\n opacity: clamp(p / BLACKOUT_IN, 0, 1),\n }}\n />\n <AbsoluteFill\n style={{\n transform: `scale(${pinchX}, ${squash})`,\n filter: `brightness(${1 + (concentrate - 1) * Math.max(gain, 0)})`,\n opacity: fade,\n }}\n >\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n background: `radial-gradient(circle at 50% 50%, ${phosphor} 0%, transparent 55%)`,\n opacity: clamp(pinch * afterglow, 0, 1) * fade,\n }}\n />\n </AbsoluteFill>\n );\n};\n\nexport const TvPowerOff = makeCanvasFilter<TvPowerOffProps>({\n shader,\n fallback: TvPowerOffFallback,\n});\n",+ "type": "registry:component",+ "target": "components/remocn/tv-power-off.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex 6def4adc..93e658fd 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -116,6 +116,7 @@ import { terminalCursorZoomConfig } from "@/registry/remocn/terminal-cursor-zoomimport { terminalSimulatorConfig } from "@/registry/remocn/terminal-simulator/config";import { topDownLettersConfig } from "@/registry/remocn/top-down-letters/config";import { trackingInConfig } from "@/registry/remocn/tracking-in/config";+import { tvPowerOffConfig } from "@/registry/remocn/tv-power-off/config";import { typewriterConfig } from "@/registry/remocn/typewriter/config";import { underwaterRippleConfig } from "@/registry/remocn/underwater-ripple/config";import { v0Config } from "@/registry/remocn/v0/config";@@ -1537,6 +1538,13 @@ const registry: Record<string, RegistryEntry> = {})),config: hologramConfig,},+ "tv-power-off": {+ load: () =>+ import("@/components/docs/examples/tv-power-off-example").then((m) => ({+ default: m.TvPowerOffExampleScene,+ })),+ config: tvPowerOffConfig,+ },"slide-swap": {load: () =>import("@/components/docs/examples/slide-swap-example").then((m) => ({diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex 25de1712..7a342632 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -1704,6 +1704,21 @@}]},+ {+ "name": "tv-power-off",+ "type": "registry:component",+ "title": "TV Power Off",+ "description": "End a scene the way a tube does: the picture collapses into a glowing horizontal line, the line pinches to a phosphor dot, the dot decays, and the frame is left dead black.",+ "dependencies": ["remotion"],+ "registryDependencies": ["@remocn/canvas-presentation"],+ "files": [+ {+ "path": "tv-power-off/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/tv-power-off.tsx"+ }+ ]+ },{"name": "camera-lens","type": "registry:component",diff --git a/registry/remocn/tv-power-off/config.ts b/registry/remocn/tv-power-off/config.tsnew file mode 100644index 00000000..c19d2618--- /dev/null+++ b/registry/remocn/tv-power-off/config.ts@@ -0,0 +1,44 @@+import { tvPowerOffExampleCode } from "@/components/docs/examples/tv-power-off-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const tvPowerOffConfig: ComponentConfig = {+ componentName: "TvPowerOff",+ importPath: "@/components/remocn/tv-power-off",+ controls: {+ durationInFrames: {+ type: "number",+ default: 18,+ min: 8,+ max: 30,+ step: 1,+ label: "Duration",+ },+ gain: {+ type: "number",+ default: 1,+ min: 0,+ max: 2,+ step: 0.05,+ label: "Surge",+ },+ afterglow: {+ type: "number",+ default: 1,+ min: 0,+ max: 2,+ step: 0.05,+ label: "Afterglow",+ },+ phosphor: {+ type: "color",+ default: "#d8ecff",+ label: "Phosphor",+ },+ },+ durationInFrames: 62,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#050505" },+ snippet: tvPowerOffExampleCode,+};diff --git a/registry/remocn/tv-power-off/index.tsx b/registry/remocn/tv-power-off/index.tsxnew file mode 100644index 00000000..db5d9999--- /dev/null+++ b/registry/remocn/tv-power-off/index.tsx@@ -0,0 +1,232 @@+"use client";++import type React from "react";+import { AbsoluteFill, useCurrentFrame } from "remotion";+import {+ type CanvasFilterProps,+ makeCanvasFilter,+ makeFilterShader,+} from "@/lib/remocn/canvas-presentation";++export type TvPowerOffProps = {+ durationInFrames?: number;+ delay?: number;+ gain?: number;+ afterglow?: number;+ phosphor?: string;+};++const DEFAULTS = {+ durationInFrames: 18,+ delay: 0,+ gain: 1,+ afterglow: 1,+ phosphor: "#d8ecff",+};++const COLLAPSE_END = 0.6;+const PINCH_END = 0.82;+const MIN_SQUASH = 0.0055;+const MIN_PINCH = 0.004;+const CONCENTRATION = 0.3;+const DECAY_CURVE = 2.6;+const BLACKOUT_IN = 0.06;++const FRAGMENT_SHADER = `#version 300 es+precision highp float;++uniform sampler2D u_scene;+uniform vec2 u_resolution;+uniform float u_aspect;+uniform float u_progress;+uniform float u_gain;+uniform float u_afterglow;+uniform vec3 u_phosphor;++in vec2 v_uv;+out vec4 outColor;++const int TAPS = 32;+const int COLUMN_TAPS = 8;+const float GOLDEN = 0.6180339887;+const float COLLAPSE_END = ${COLLAPSE_END.toFixed(4)};+const float PINCH_END = ${PINCH_END.toFixed(4)};+const float MIN_SQUASH = ${MIN_SQUASH.toFixed(5)};+const float MIN_PINCH = ${MIN_PINCH.toFixed(5)};+const float CONCENTRATION = ${CONCENTRATION.toFixed(4)};+const float DECAY_CURVE = ${DECAY_CURVE.toFixed(4)};+const float BLACKOUT_IN = ${BLACKOUT_IN.toFixed(4)};++void main() {+ float p = u_progress;++ if (p <= 0.0) {+ outColor = texture(u_scene, v_uv);+ return;+ }+ if (p >= 1.0) {+ outColor = vec4(0.0, 0.0, 0.0, 1.0);+ return;+ }++ float collapse = clamp(p / COLLAPSE_END, 0.0, 1.0);+ float pinch = clamp((p - COLLAPSE_END) / (PINCH_END - COLLAPSE_END), 0.0, 1.0);+ float decayed = clamp((p - PINCH_END) / (1.0 - PINCH_END), 0.0, 1.0);++ vec2 scale = vec2(pow(MIN_PINCH, pinch), pow(MIN_SQUASH, collapse));+ vec2 centered = (v_uv - 0.5) / scale + 0.5;+ vec2 span = 1.0 / (scale * u_resolution);++ vec3 sum = vec3(0.0);+ for (int i = 0; i < TAPS; i++) {+ float fi = float(i);+ vec2 at = centered + vec2(+ (fract(fi * GOLDEN + 0.5) - 0.5) * span.x,+ ((fi + 0.5) / float(TAPS) - 0.5) * span.y+ );+ vec2 inside = step(vec2(0.0), at) * step(at, vec2(1.0));+ sum += texture(u_scene, at).rgb * inside.x * inside.y;+ }++ float concentrate = pow(1.0 / (scale.x * scale.y), CONCENTRATION);+ vec3 light =+ (sum / float(TAPS)) * (1.0 + (concentrate - 1.0) * max(u_gain, 0.0));++ float glow = max(u_afterglow, 0.0);+ float bleed = smoothstep(0.2, 0.8, collapse) * (1.0 - pinch) * glow;++ if (bleed > 0.0) {+ vec3 column = vec3(0.0);+ float cx = clamp(centered.x, 0.0, 1.0);+ for (int i = 0; i < COLUMN_TAPS; i++) {+ column +=+ texture(u_scene, vec2(cx, (float(i) + 0.5) / float(COLUMN_TAPS))).rgb;+ }+ column /= float(COLUMN_TAPS);++ float dy = v_uv.y - 0.5;+ float reach = 0.02 + 0.03 * collapse;+ light +=+ column *+ mix(vec3(1.0), u_phosphor, 0.65) *+ exp(-(dy * dy) / (reach * reach)) *+ bleed *+ 0.9;+ }++ if (pinch > 0.0) {+ vec2 d = (v_uv - 0.5) * vec2(u_aspect, 1.0);+ float radius = max(0.045 * glow, 0.0005);+ light +=+ u_phosphor *+ exp(-dot(d, d) / (radius * radius)) *+ smoothstep(0.0, 0.5, pinch) *+ 1.15;+ }++ light *= pow(max(1.0 - decayed, 0.0001), DECAY_CURVE);++ float blackout = smoothstep(0.0, BLACKOUT_IN, p);+ outColor = vec4(+ clamp(light, 0.0, 1.0),+ mix(texture(u_scene, v_uv).a, 1.0, blackout)+ );+}`;++const clamp = (value: number, min: number, max: number) =>+ Math.min(max, Math.max(min, value));++function toRgb(hex: string): [number, number, number] {+ const value = hex.replace("#", "");+ const full =+ value.length === 3+ ? value+ .split("")+ .map((c) => c + c)+ .join("")+ : value;+ const int = Number.parseInt(full, 16);+ if (Number.isNaN(int)) return [1, 1, 1];+ return [+ ((int >> 16) & 255) / 255,+ ((int >> 8) & 255) / 255,+ (int & 255) / 255,+ ];+}++function powerProgress(props: TvPowerOffProps, frame: number): number {+ const {+ durationInFrames = DEFAULTS.durationInFrames,+ delay = DEFAULTS.delay,+ } = props;+ return clamp((frame - delay) / Math.max(1, durationInFrames), 0, 1);+}++const shader = makeFilterShader<TvPowerOffProps>(+ FRAGMENT_SHADER,+ ({ gl, uniform, width, height, frame, passedProps }) => {+ const {+ gain = DEFAULTS.gain,+ afterglow = DEFAULTS.afterglow,+ phosphor = DEFAULTS.phosphor,+ } = passedProps;+ gl.uniform1f(uniform("u_progress"), powerProgress(passedProps, frame));+ gl.uniform2f(uniform("u_resolution"), width, height);+ gl.uniform1f(uniform("u_gain"), gain);+ gl.uniform1f(uniform("u_afterglow"), afterglow);+ gl.uniform3fv(uniform("u_phosphor"), toRgb(phosphor));+ },+);++const TvPowerOffFallback: React.FC<TvPowerOffProps & CanvasFilterProps> = (+ props,+) => {+ const frame = useCurrentFrame();+ const {+ children,+ gain = DEFAULTS.gain,+ afterglow = DEFAULTS.afterglow,+ phosphor = DEFAULTS.phosphor,+ } = props;++ const p = powerProgress(props, frame);+ const collapse = clamp(p / COLLAPSE_END, 0, 1);+ const pinch = clamp((p - COLLAPSE_END) / (PINCH_END - COLLAPSE_END), 0, 1);+ const decayed = clamp((p - PINCH_END) / (1 - PINCH_END), 0, 1);++ const squash = MIN_SQUASH ** collapse;+ const pinchX = MIN_PINCH ** pinch;+ const concentrate = (1 / (squash * pinchX)) ** CONCENTRATION;+ const fade = (1 - decayed) ** DECAY_CURVE;++ return (+ <AbsoluteFill>+ <AbsoluteFill+ style={{+ background: "#000000",+ opacity: clamp(p / BLACKOUT_IN, 0, 1),+ }}+ />+ <AbsoluteFill+ style={{+ transform: `scale(${pinchX}, ${squash})`,+ filter: `brightness(${1 + (concentrate - 1) * Math.max(gain, 0)})`,+ opacity: fade,+ }}+ >+ {children}+ </AbsoluteFill>+ <AbsoluteFill+ style={{+ background: `radial-gradient(circle at 50% 50%, ${phosphor} 0%, transparent 55%)`,+ opacity: clamp(pinch * afterglow, 0, 1) * fade,+ }}+ />+ </AbsoluteFill>+ );+};++export const TvPowerOff = makeCanvasFilter<TvPowerOffProps>({+ shader,+ fallback: TvPowerOffFallback,+});