Files
hyperframes/docs/catalog/components/grade-split-reveal.mdx
Miguel Ángel f24ff83834 feat(catalog): add the seven 3D-motion pieces as installable registry blocks (#4056)
* feat(catalog): add the seven 3D-motion pieces as installable registry blocks

Each piece ships as a registry block with a CDN poster and preview, a live
catalog detail page and its source. Scripts travel inside the catalog payload
(shared vendor libraries fetched once, item scripts inline, the one HDR as a
data URI) because the docs host only serves fonts, images and JSON.

NO_ESSAY_COMMENTS_OK: the long comment blocks are in vendored libraries and
the ported frost source under registry/blocks, not hand-written here.
HF_MAX_NONLFS_KB=6000: four hosted texture PNGs under docs/public/catalog/items
are runtime assets the docs host must serve as files.
fallow skipped locally: it audits against origin/main and this branch is
stacked on an older main.

* chore(catalog): regenerate gallery data and nav after rebasing onto main

* fix(catalog): read the install manifest through the bounded project reader

* fix(catalog): a script the inliner missed fails the payload instead of shipping a dead URL

* refactor(catalog): the leftover-script check reuses the reference finder

* fix(catalog): frost and glass textures load from the CDN and the iteration presets are gone

* chore(catalog): regenerate the frost and glass payloads and nav

* fix(catalog): frost and glass textures are hosted through the registry url field, not hardcoded

* chore(catalog): regenerate the frost and glass payloads against the hosted texture URLs

* fix(catalog): the hosted-reference rewrite refuses a bare name it cannot safely replace

* ci(catalog): verify changed catalog payloads in headless Chrome and check the docs catalog

* feat(catalog): every item page follows the shared layout with a Tune panel and tabs

* fix(catalog): let the texture-mask item host its masks so its tile plays live

* chore(catalog): regenerate item pages, gallery data and the texture-mask payload

* chore(catalog): regenerate item pages after merging main

* fix(catalog): declared-only variables get the Tune panel, Code and Docs tabs capped

* feat(catalog): give the blend-difference caption a demo scene so its tile plays live

* chore(catalog): live payload for the blend-difference caption

* perf(catalog): heavy 3d pieces compile and draw before ready, not on the first visible frame

* feat(catalog): the avatar promo card hosts its videos, audio and fonts on the CDN

* feat(catalog): the avatar promo card tile plays live from its CDN-hosted media

* chore(catalog): the avatar promo card plays live, no allowlist left

* chore(catalog): shorten two comment blocks

* chore(catalog): trim first-party comment blocks to the comment-check limits

* chore(catalog): shorten two frost source comments

* fix(catalog): the Docs tab renders as prose again, and the detail page honours reduced motion

Frame-mode pages carry no prose wrapper, and the detail component sat inside
not-prose, so the Docs slot's headings, paragraphs, links and lists had no
styling at all. The slots now carry their own prose classes and the chrome
around them keeps not-prose.

The recorded clip also gets the reduced-motion guard the docs-snippet check
requires, and the generator reads stability from the source metadata type so
the scripts typecheck passes.

* fix(catalog): docs-tab paragraphs render as blocks

Mintlify emits paragraphs as inline spans, so two paragraphs in the Docs slot ran together.

* fix(ci): drop the duplicate docs_catalog job output

git's line-based auto-merge silently duplicated the outputs key when
main and this branch each added it on non-adjacent lines during the
rebase; oxfmt's yaml parser rejects the repeated map key.

* fix(catalog): close four CodeQL alerts in the frost source

* chore(catalog): allowlist the avatar-promo-card CDN asset deletions, format sync-docs-catalog

check-no-main-deletions.mjs was rejecting 11 local mp4/font files this branch
already deleted in favor of CDN hosting; scripts/sync-docs-catalog.mjs had one
line over the 100-col print width from an earlier edit in this branch.

* fix(catalog): detail tabs use docs prose spacing, Install first; previews skip no-WebGPU runners

* fix(catalog): the docs tab scrolls with the page instead of a capped inner box

* refactor(catalog): split the payload asset and verify scripts into single-purpose helpers

* refactor(catalog): split the preview generator into single-purpose helpers

* ci(catalog): fail when the committed catalog differs from generator output

The docs host serves the committed catalog and nothing regenerates it, so a stale
copy shipped silently. The catalog payloads job now generates into a temp dir and
compares it with the committed tree.

* chore(catalog): regenerate docs/public/catalog with the refactored scripts

One full regeneration from an empty output tree with the current scripts. The tree grows
from 58.4 MB to 65.1 MB. Two hosted assets are about 2 MB each (an avatar png and a wav);
the same bytes are already committed under assets/, so HF_MAX_NONLFS_KB is raised for
this commit only.

* fix(catalog): run the catalog script tests under the runner they are written for

The rebase put three node:test files in the vitest half of test:scripts, where they report
"No test suite found". They now sit in the node --test list.

* fix(catalog): a WebGPU item without an adapter shows its recorded clip and says why

* ci(catalog): the drift check runs from a committed fetch mirror with no network

Generation now serves every font and CDN script fetch from scripts/catalog-fetch-mirror and fails
when a fetch is not in it, even if the caller swallowed the error. CATALOG_FETCH_MIRROR=record
refreshes the mirror from the live network. The docs_catalog filter also watches packages/core,
packages/producer and the mirror, and the 13 re-hashed font files are listed in ALLOWED_DELETIONS.

* chore(catalog): clean up the temp font cache and sort the mirror index without a locale

* fix(catalog): hide Tune when the clip stands in, time out the adapter request, share one check

* fix(catalog): the adapter probe survives a sync throw and a hang; test the clip guard

* fix(catalog): keep the adapter probe inside the component, Mintlify evaluates only exports

* fix(catalog): run the detail and page generator tests in CI; no Tune flash while probing WebGPU

* docs(catalog): credit vendored libraries and make each SKILL.md list what the block installs

CREDITS.md names every vendored dependency with its upstream and licence, and flags the two leaf
textures whose origin is still to be confirmed. Each SKILL.md Files table now comes from the block
manifest and its install and render paths point at compositions/<name>/. A test checks that every
path a SKILL.md names is a manifest file that exists.

* fix(catalog): a declared WebGPU item passes verify by its manifest tag, not by console wording

verify-catalog-payloads forgave a missing adapter only by matching the markup and the message, which
library-reported errors and widgets never satisfy. The webgpu tag in the item manifest is now the
owner: a tagged item ignores its page and console errors, an untagged one gets no forgiveness, and a
marker payload with no html is listed instead of crashing the run.

* docs(catalog): correct the credits per block and guard the mount and render paths

CREDITS.md states the three.js version and vendored-or-CDN status per block, adds d3-delaunay,
Clipper on the CDN and the Google Fonts loads, and lists every texture with no known origin.
The SKILL.md test now also checks the mount and render paths against the manifest composition.

* test(catalog): read each block manifest once in the SKILL.md file test

The two checks shared a copied manifest read, which fallow flagged as a clone with a high score.

* fix(catalog): commit the hosted item files a gitignore rule kept out, and check git not the disk

The compositions/ and *-ad/ ignore rules matched folder names under docs/public/catalog/items,
so 33 hosted fonts, textures and marks were generated but never committed and would 404 on
the docs host. The rules now have a negation for that tree and the files are added.

The drift check read the checkout, where git-ignored files still exist, so it passed locally
and failed only in CI. It now unpacks HEAD with git archive and compares that.

* fix(catalog): a tile keeps its poster until the composition has painted

* fix(catalog): a tagged WebGPU item forgives only the adapter-absent error, and test the wiring

The manifest webgpu tag now decides whether an item may lack an adapter, and the error wording
decides which lines are that absence. Any other page or console error on the item, and every
failed request, still fails. The per-item decision is one exported function the tests drive,
marker payloads are parsed by a tested helper, and the SKILL.md variable counts are checked
against their tables (cuboid-carousel said forty-nine for forty).

* fix(catalog): the pinned group's posters load eagerly at high priority

* fix(catalog): type the tile reveal test so the scripts typecheck passes

* fix(catalog): stop the adapter signature matching an unrelated failed adapter request

failed to request .*adapter also matched errors about other adapters. It now matches only a
request for the WebGPU adapter, so a tagged item cannot hide an unrelated failure behind it.

* test(catalog): a tagged item still fails on an error about some other adapter

* feat(catalog): the install command sits above the preview, as on the live catalog

* fix(catalog): find the install slot through Mintlify's child wrapper

* fix(docs): catalog copy buttons keep their size when the label swaps to Copied

* refactor(docs): name the shown copy label once in the catalog copy button

* fix(docs): primary catalog button keeps a readable label on hover and after copy

* fix(docs): inset the catalog tab strip and tab content to match the boxed panels
2026-09-19 16:53:29 -04:00

529 lines
25 KiB
Plaintext

---
title: "Grade Split Reveal"
description: "The same picture twice, one flat and one finished, with a hard edge sweeping between them. It stops in the middle long enough to compare, then commits and the graded look takes the frame. Both looks are real HyperFrames color grading run through the WebGL shader, so the preview and the render match."
mode: "frame"
---
import { CatalogDetail, CatalogSlot } from "/snippets/catalog-detail.jsx";
import { InstallCommand } from "/snippets/install-command.jsx";
<CatalogDetail
previewSrc="/public/catalog/components/grade-split-reveal.json"
compositionId="grade-split-reveal"
compositionSrc="compositions/components/grade-split-reveal.html"
title="Grade Split Reveal"
description="The same picture twice, one flat and one finished, with a hard edge sweeping between them. It stops in the middle long enough to compare, then commits and the graded look takes the frame. Both looks are real HyperFrames color grading run through the WebGL shader, so the preview and the render match."
variables={[{"id":"look","type":"enum","role":"style","label":"Look","description":"Grade carried by the upper copy, and the label printed over it. All three are real grading blocks handed to the shader, not CSS filters.","default":"warm-cinematic","options":[{"value":"warm-cinematic","label":"Warm Cinematic"},{"value":"cool-teal","label":"Cool Teal"},{"value":"bleach-bypass","label":"Bleach Bypass"}]},{"id":"split","type":"number","role":"motion","label":"Split point","description":"How far across the plate the edge stops to hold the comparison, before it commits and takes the rest.","default":62,"min":25,"max":85,"step":1,"unit":"%"},{"id":"edge","type":"enum","role":"style","label":"Edge","description":"The divider line riding the wipe. Hidden drops it entirely so the grade arrives with no seam.","default":"hairline","options":[{"value":"hairline","label":"Hairline"},{"value":"bold","label":"Bold"},{"value":"hidden","label":"Hidden"}]},{"id":"labels","type":"enum","role":"style","label":"Labels","description":"Show or hide the two captions naming each half of the plate.","default":"on","options":[{"value":"on","label":"Show"},{"value":"off","label":"Hide"}]}]}
meta={{"category":"Motion Scenes","badge":"Stable","codeLines":446}}
attribution={{"path":"registry/components/grade-split-reveal","tags":["color-grading","media","compare","reveal","motion-primitive","grade"]}}
hasCode
rawUrl="https://raw.githubusercontent.com/heygen-com/hyperframes/main/registry/components/grade-split-reveal/grade-split-reveal.html"
>
<CatalogSlot slot="code">
```html grade-split-reveal.html
<!doctype html>
<!--
grade-split-reveal: the grade arrives as a moving edge.
Two copies of the same plate sit exactly on top of each other. The lower copy carries a
flat, milky look, the way ungraded footage comes off a camera. The upper copy carries the
finished warm cinematic look. A hard edge sweeps across the upper copy, so the graded
version eats the flat one from left to right and you read both halves of the same picture
at the same time. It pauses in the middle long enough for the eye to compare, then commits
and takes the whole frame.
Both looks are real HyperFrames color grading, not a CSS filter. The runtime hands each
image to a WebGL shader and swaps in a graded canvas, and the render pipeline redraws the
same shader, so what you preview is what encodes. Color grading is media only: it applies
to <video> and <img>, never to text, SVG or ordinary DOM.
The plate here is a procedural SVG scene built in this file, so the primitive is
deterministic and ships nothing licensed. Replace PLATE_SRC with your own photo or a video
poster and the whole move still works. Swap AFTER_GRADE for any preset id or hand written
adjust block.
The edge itself is never animated with clip-path. The upper copy lives in a wrapper with
overflow hidden and the wrapper's width is what moves, so the sweep is one plain numeric
tween that seeks perfectly and never re-parses a string.
Every ease is a cubic bezier written out by hand and solved in this file. No preset is used
anywhere.
Variables. Each one is read once at mount, falls back to its declared default on anything
missing or unrecognised, and changes what lands on screen. Timing is untouched: same six
seconds, same 30fps, same beats.
- look (warm-cinematic | cool-teal | bleach-bypass, default warm-cinematic): the grade the
upper copy carries, and the label printed over it. All three are real grading blocks
handed to the shader, not CSS filters.
- split (25 to 85, default 62, percent of the plate width): where the edge stops to hold
the comparison before it commits and takes the rest.
- edge (hairline | bold | hidden, default hairline): the divider line riding the wipe.
hidden removes it, so the grade arrives with no visible seam.
- labels (on | off, default on): the two captions naming each half of the plate.
Mount contract: everything lives inside <template>, styles and scripts included, and the
scripts sit INSIDE the composition root. A host clones template content into its own mount
and only runs scripts found inside the root; markup left outside is copied without its
behaviour, which renders a black card with no timeline at all.
-->
<html
lang="en"
data-composition-variables='[
{ "id": "look", "type": "enum", "role": "style", "label": "Look", "description": "Grade carried by the upper copy, and the label printed over it. All three are real grading blocks handed to the shader, not CSS filters.", "default": "warm-cinematic", "options": [{ "value": "warm-cinematic", "label": "Warm Cinematic" }, { "value": "cool-teal", "label": "Cool Teal" }, { "value": "bleach-bypass", "label": "Bleach Bypass" }] },
{ "id": "split", "type": "number", "role": "motion", "label": "Split point", "description": "How far across the plate the edge stops to hold the comparison, before it commits and takes the rest.", "default": 62, "min": 25, "max": 85, "step": 1, "unit": "%" },
{ "id": "edge", "type": "enum", "role": "style", "label": "Edge", "description": "The divider line riding the wipe. Hidden drops it entirely so the grade arrives with no seam.", "default": "hairline", "options": [{ "value": "hairline", "label": "Hairline" }, { "value": "bold", "label": "Bold" }, { "value": "hidden", "label": "Hidden" }] },
{ "id": "labels", "type": "enum", "role": "style", "label": "Labels", "description": "Show or hide the two captions naming each half of the plate.", "default": "on", "options": [{ "value": "on", "label": "Show" }, { "value": "off", "label": "Hide" }] }
]'
>
<head>
<meta charset="UTF-8" />
<title>Grade Split Reveal</title>
</head>
<body>
<template>
<div
id="root"
class="clip gs-root"
data-composition-id="grade-split-reveal"
data-duration="6"
data-fps="30"
>
<style>
[data-composition-id="grade-split-reveal"] {
--ink: #f6f4ef;
--rule: rgba(246, 244, 239, 0.55);
position: absolute;
inset: 0;
overflow: hidden;
background: transparent;
pointer-events: none;
}
#gs-plate {
position: absolute;
overflow: hidden;
border-radius: 10px;
background: #08080a;
box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}
.gs-layer {
position: absolute;
left: 0;
top: 0;
height: 100%;
overflow: hidden;
}
.gs-layer img {
display: block;
object-fit: cover;
}
#gs-edge {
position: absolute;
top: 0;
left: 0;
width: 2px;
height: 100%;
background: var(--ink);
box-shadow: 0 0 18px rgba(0, 0, 0, 0.7);
}
.gs-tag {
position: absolute;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.16em;
color: var(--ink);
opacity: 0;
white-space: nowrap;
text-shadow: 0 2px 12px rgba(0, 0, 0, 0.85);
}
.gs-tag::before {
content: "";
position: absolute;
left: 0;
top: -0.7em;
width: 1.8em;
height: 2px;
background: var(--rule);
}
#gs-tag-before::before {
left: auto;
right: 0;
}
</style>
<div id="gs-plate">
<div class="gs-layer" id="gs-before"><img id="gs-img-before" alt="" /></div>
<div class="gs-layer" id="gs-after"><img id="gs-img-after" alt="" /></div>
<div id="gs-edge"></div>
<div class="gs-tag" id="gs-tag-before">Ungraded</div>
<div class="gs-tag" id="gs-tag-after">Warm Cinematic</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<script>
(function () {
gsap.defaults({ immediateRender: false });
/* Cubic bezier solved by hand. Newton first, bisection when the slope dies. */
function bezier(x1, y1, x2, y2) {
function curve(t, a1, a2) {
var A = 1 - 3 * a2 + 3 * a1;
var B = 3 * a2 - 6 * a1;
var C = 3 * a1;
return ((A * t + B) * t + C) * t;
}
function slope(t, a1, a2) {
var A = 1 - 3 * a2 + 3 * a1;
var B = 3 * a2 - 6 * a1;
var C = 3 * a1;
return (3 * A * t + 2 * B) * t + C;
}
return function (p) {
if (p <= 0) return 0;
if (p >= 1) return 1;
var t = p;
for (var i = 0; i < 8; i++) {
var d = slope(t, x1, x2);
if (Math.abs(d) < 1e-6) break;
var e = curve(t, x1, x2) - p;
if (Math.abs(e) < 1e-7) return curve(t, y1, y2);
t -= e / d;
}
var lo = 0;
var hi = 1;
t = p;
for (var j = 0; j < 24; j++) {
var x = curve(t, x1, x2);
if (Math.abs(x - p) < 1e-7) break;
if (x > p) hi = t;
else lo = t;
t = (lo + hi) / 2;
}
return curve(t, y1, y2);
};
}
/* Plate settles, never bounces. */
var EASE_PLATE = bezier(0.16, 0.84, 0.24, 1);
/* The sweep loiters, then finishes fast, the way a hand drags a compare slider. */
var EASE_WIPE = bezier(0.62, 0, 0.14, 1);
/* The commit is decisive from the first frame. */
var EASE_COMMIT = bezier(0.4, 0, 0.05, 1);
var EASE_TAG = bezier(0.22, 0.8, 0.3, 1);
var EASE_FADE = bezier(0.4, 0, 0.7, 1);
var DUR = 6;
/* ---- the plate. Swap PLATE_SRC for your own photo or video poster. ---- */
var SCENE =
/* width and height are not decoration. An SVG served to an <img> with only a
viewBox has no intrinsic size, and a texture upload from it comes back
empty, so the shader grades a blank plate. */
'<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900" viewBox="0 0 1600 900">' +
"<defs>" +
'<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">' +
'<stop offset="0" stop-color="#1b2340"/><stop offset="0.42" stop-color="#5b4a63"/>' +
'<stop offset="0.68" stop-color="#c8794a"/><stop offset="0.78" stop-color="#f0a75c"/>' +
'<stop offset="1" stop-color="#f7c988"/></linearGradient>' +
'<linearGradient id="sea" x1="0" y1="0" x2="0" y2="1">' +
'<stop offset="0" stop-color="#c98a55"/><stop offset="0.3" stop-color="#6a5560"/>' +
'<stop offset="1" stop-color="#1a1d30"/></linearGradient>' +
'<radialGradient id="glow" cx="0.62" cy="0.74" r="0.42">' +
'<stop offset="0" stop-color="#ffdfa8" stop-opacity="0.9"/>' +
'<stop offset="1" stop-color="#ffdfa8" stop-opacity="0"/></radialGradient>' +
"</defs>" +
'<rect width="1600" height="900" fill="url(#sky)"/>' +
'<rect width="1600" height="900" fill="url(#glow)"/>' +
'<circle cx="992" cy="660" r="58" fill="#fff0cd"/>' +
'<path d="M0 640 L250 578 L430 618 L640 552 L820 606 L1010 566 L1240 620 L1430 578 L1600 616 L1600 700 L0 700 Z" fill="#3a2f45"/>' +
'<path d="M0 668 L210 634 L400 664 L610 622 L840 662 L1080 630 L1330 668 L1600 638 L1600 700 L0 700 Z" fill="#2a2337"/>' +
'<rect y="700" width="1600" height="200" fill="url(#sea)"/>' +
'<rect x="962" y="700" width="60" height="200" fill="#ffdfa8" opacity="0.42"/>' +
'<rect x="978" y="700" width="28" height="200" fill="#fff3d4" opacity="0.5"/>' +
'<g fill="#f4e3c2" opacity="0.34">' +
'<rect x="120" y="742" width="1360" height="3"/><rect x="240" y="786" width="1120" height="3"/>' +
'<rect x="60" y="828" width="1480" height="4"/><rect x="300" y="868" width="1000" height="4"/></g>' +
'<g fill="#e8d3b4" opacity="0.5">' +
'<rect x="180" y="330" width="420" height="7" rx="3"/><rect x="300" y="372" width="260" height="6" rx="3"/>' +
'<rect x="1010" y="286" width="380" height="7" rx="3"/><rect x="1130" y="326" width="220" height="6" rx="3"/></g>' +
'<path d="M0 760 L118 700 L268 760 L268 900 L0 900 Z" fill="#12121e"/>' +
'<path d="M1600 742 L1462 700 L1318 742 L1318 900 L1600 900 Z" fill="#0f0f1a"/>' +
"</svg>";
var PLATE_SRC = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(SCENE);
/* ---- the two looks. Both are real color grading, applied by the shader. ---- */
var BEFORE_GRADE = {
preset: "neutral",
intensity: 1,
adjust: {
exposure: 0.1,
contrast: -0.42,
highlights: -0.1,
shadows: 0.24,
whites: -0.14,
blacks: 0.3,
temperature: -0.06,
vibrance: -0.22,
saturation: -0.34,
},
colorSpace: "rec709",
};
var AFTER_GRADE = {
preset: "deep-contrast",
intensity: 1,
adjust: {
exposure: 0.02,
contrast: 0.28,
highlights: -0.16,
shadows: 0.08,
whites: 0.06,
blacks: -0.16,
temperature: 0.18,
tint: -0.04,
vibrance: 0.26,
saturation: 0.1,
},
details: { vignette: 0.3, vignetteFeather: 0.7, grain: 0.1, grainSize: 0.3 },
colorSpace: "rec709",
};
/* ---- variables. Unrecognised overrides return to their declared defaults. ---- */
var vars =
window.__hyperframes && window.__hyperframes.getVariables
? window.__hyperframes.getVariables()
: {};
function pick(table, value, fallback) {
return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;
}
var LOOKS = {
"warm-cinematic": { label: "Warm Cinematic", grade: AFTER_GRADE },
"cool-teal": {
label: "Cool Teal",
grade: {
preset: "deep-contrast",
intensity: 1,
adjust: {
exposure: 0,
contrast: 0.32,
highlights: -0.2,
shadows: 0.14,
whites: 0.04,
blacks: -0.2,
temperature: -0.26,
tint: 0.08,
vibrance: 0.22,
saturation: 0.04,
},
details: { vignette: 0.34, vignetteFeather: 0.68, grain: 0.1, grainSize: 0.3 },
colorSpace: "rec709",
},
},
"bleach-bypass": {
label: "Bleach Bypass",
grade: {
preset: "neutral",
intensity: 1,
adjust: {
exposure: 0.08,
contrast: 0.54,
highlights: 0.12,
shadows: -0.1,
whites: 0.18,
blacks: -0.28,
temperature: 0.04,
vibrance: -0.18,
saturation: -0.46,
},
details: { vignette: 0.24, vignetteFeather: 0.72, grain: 0.18, grainSize: 0.34 },
colorSpace: "rec709",
},
},
};
var LOOK = LOOKS[pick(LOOKS, vars.look, "warm-cinematic")];
var EDGE_WIDTHS = { hairline: "2px", bold: "6px", hidden: "0px" };
var EDGE = pick(EDGE_WIDTHS, vars.edge, "hairline");
/* A number arrives as a number from --variables, but a hand written override can
still be a string or nonsense. parseFloat plus a range test covers both. */
var SPLIT = parseFloat(vars.split);
if (!isFinite(SPLIT) || SPLIT < 25 || SPLIT > 85) SPLIT = 62;
var LABELS_ON = vars.labels !== "off";
var root = document.getElementById("gs-plate").parentElement;
var FRAME_W = root.clientWidth || 1920;
var FRAME_H = root.clientHeight || 1080;
/* The plate keeps the frame's own shape, inset by a constant margin, so one file
reads correctly in landscape, portrait and square. */
var INSET = Math.min(FRAME_W, FRAME_H) * 0.085;
var PW = Math.round(FRAME_W - INSET * 2);
var PH = Math.round(FRAME_H - INSET * 2);
var plate = document.getElementById("gs-plate");
plate.style.left = INSET + "px";
plate.style.top = INSET + "px";
plate.style.width = PW + "px";
plate.style.height = PH + "px";
var before = document.getElementById("gs-before");
var after = document.getElementById("gs-after");
var edge = document.getElementById("gs-edge");
var tagBefore = document.getElementById("gs-tag-before");
var tagAfter = document.getElementById("gs-tag-after");
/* Both images are laid out at the full plate width. Only the wrapper narrows, so
the shader canvas the runtime drops in keeps its measured box and the edge is a
clean crop rather than a squeeze. */
[
[document.getElementById("gs-img-before"), BEFORE_GRADE],
[document.getElementById("gs-img-after"), LOOK.grade],
].forEach(function (pair) {
pair[0].style.width = PW + "px";
pair[0].style.height = PH + "px";
pair[0].setAttribute("data-color-grading", JSON.stringify(pair[1]));
pair[0].src = PLATE_SRC;
});
before.style.width = PW + "px";
var TAG = Math.max(11, Math.round(Math.min(FRAME_W, FRAME_H) * 0.019));
var PAD = Math.round(INSET * 0.62);
[tagBefore, tagAfter].forEach(function (t) {
t.style.fontSize = TAG + "px";
t.style.bottom = PAD + "px";
});
/* The graded copy grows from the left, so its label sits on the left. Putting
these the other way round labels each half with the look it is not. */
tagAfter.style.left = PAD + "px";
tagBefore.style.right = PAD + "px";
tagBefore.style.textAlign = "right";
tagAfter.textContent = LOOK.label;
edge.style.width = EDGE_WIDTHS[EDGE];
/* The edge also casts a shadow, so zero width alone would leave a smudge. */
if (EDGE === "hidden") edge.style.display = "none";
if (!LABELS_ON) {
tagBefore.style.display = "none";
tagAfter.style.display = "none";
}
/* Rest state lives outside the timeline so frame zero is already correct. */
/* The plate is lit at frame zero and arrives on scale alone. Fading it up from
nothing would leave the first frames of the clip literally blank, which reads
as a broken card in any grid of thumbnails. */
gsap.set(plate, { transformOrigin: "50% 50%", scale: 1.05, opacity: 1 });
gsap.set(after, { width: 0 });
gsap.set(edge, { x: 0, opacity: 0 });
gsap.set([tagBefore, tagAfter], { opacity: 0, y: 10 });
var tl = gsap.timeline({ paused: true });
/* The plate arrives. */
tl.fromTo(plate, { scale: 1.05 }, { scale: 1, duration: 0.62, ease: EASE_PLATE }, 0);
tl.fromTo(
tagBefore,
{ opacity: 0, y: 10 },
{ opacity: 0.82, y: 0, duration: 0.34, ease: EASE_TAG },
0.36,
);
/* The grade sweeps in and stops short, so both halves are readable together. */
var HOLD = Math.round(PW * (SPLIT / 100));
tl.fromTo(after, { width: 0 }, { width: HOLD, duration: 1.6, ease: EASE_WIPE }, 0.7);
tl.fromTo(edge, { x: 0 }, { x: HOLD, duration: 1.6, ease: EASE_WIPE }, 0.7);
tl.fromTo(edge, { opacity: 0 }, { opacity: 1, duration: 0.2, ease: EASE_FADE }, 0.7);
tl.fromTo(
tagAfter,
{ opacity: 0, y: 10 },
{ opacity: 1, y: 0, duration: 0.34, ease: EASE_TAG },
1.16,
);
/* Then it commits and takes the whole plate. */
tl.fromTo(after, { width: HOLD }, { width: PW, duration: 1.2, ease: EASE_COMMIT }, 3.1);
tl.fromTo(edge, { x: HOLD }, { x: PW, duration: 1.2, ease: EASE_COMMIT }, 3.1);
tl.fromTo(
tagBefore,
{ opacity: 0.82 },
{ opacity: 0, duration: 0.5, ease: EASE_FADE },
3.1,
);
tl.fromTo(edge, { opacity: 1 }, { opacity: 0, duration: 0.3, ease: EASE_FADE }, 4.05);
/* A small push in lands the finished look instead of just stopping on it. */
tl.fromTo(plate, { scale: 1 }, { scale: 1.03, duration: 1.5, ease: EASE_COMMIT }, 3.1);
tl.set({}, {}, DUR);
tl.seek(0);
window.__timelines = window.__timelines || {};
window.__timelines["grade-split-reveal"] = tl;
})();
</script>
</div>
</template>
</body>
</html>
```
</CatalogSlot>
<CatalogSlot slot="install">
<InstallCommand command="npx hyperframes add grade-split-reveal" item="grade-split-reveal" />
That writes one file: `compositions/components/grade-split-reveal.html`.
</CatalogSlot>
<CatalogSlot slot="docs">
## Paste it into your composition
Open `compositions/components/grade-split-reveal.html` and copy what is inside into your own composition.
A component has no size or duration of its own. It takes both from the composition
you paste it into.
## Variables
Every one of these has a default, so the piece works untouched. Set the ones you
want to change on the element:
| Variable | Default | Accepts | What it does |
| --- | --- | --- | --- |
| `look` | `warm-cinematic` | `warm-cinematic`, `cool-teal`, `bleach-bypass` | Grade carried by the upper copy, and the label printed over it. All three are real grading blocks handed to the shader, not CSS filters. |
| `split` | `62` | 25% to 85%, step 1% | How far across the plate the edge stops to hold the comparison, before it commits and takes the rest. |
| `edge` | `hairline` | `hairline`, `bold`, `hidden` | The divider line riding the wipe. Hidden drops it entirely so the grade arrives with no seam. |
| `labels` | `on` | `on`, `off` | Show or hide the two captions naming each half of the plate. |
Set them with `data-variable-values` on the element that mounts it. These are the
defaults, so this behaves exactly like the preview above until you change one:
```html wrap
<div
data-composition-id="grade-split-reveal"
data-composition-src="compositions/components/grade-split-reveal.html"
data-variable-values='{"look":"warm-cinematic","split":62,"edge":"hairline","labels":"on"}'
></div>
```
{/* hf:generated-footer */}
Tagged `color-grading` `media` `compare` `reveal` `motion-primitive` `grade`.
## Related topics
- [Browse the complete Catalog](/catalog)
- [Add assets and Catalog items in Studio](/studio/assets-and-blocks)
- [Build a richer composition](/go-further)
</CatalogSlot>
</CatalogDetail>