mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-01 19:42:03 +00:00
* feat(catalog): put the variables panel back, on payloads The panel drove its preview by loading an .html from docs/public, a type the host does not publish, so it showed an empty frame in production and was parked when the catalog was re-landed. It now mounts the same JSON payload the plain player uses and re-mounts it as values change, injecting them as window.__hfVariables into the composition head before any of its scripts run, which is where the runtime reads overrides from. Doing it in the markup rather than after load is what stops the composition initialising with the wrong values first. 172 items with variables get the panel back; the playhead carries across a change so a tweak mid-shot does not jump back to frame zero. * fix(docs): drop the unused url form and the needless escapes * fix(docs): the panel cannot reference a binding beside the export * feat(catalog): make importing an SVG the obvious move A reader arrives at this control with a shape, not with path data, and the panel asked for the coordinates first. Import is now the primary action in a drop target you can see is a drop target, and the raw path sits behind a disclosure for anyone who wants it. * feat(cli): let a fruitless catalog search report the gap An agent that searches by meaning and finds nothing worth installing knows something we do not: the name of a move the catalog is missing. There was no way to tell us, so that knowledge was lost at the end of every run. hyperframes feedback --search-miss "<query>" --wanted "<the move>" records it. It carries no rating, so it never lands in the rating metric, and it is a separate deliberate command rather than something catalog --query does on its own: plain search still sends nothing, which is what the CLI promises. --rating stops being required at the arg level, since a miss has no rating to give. The check moved into the run body, where an absent one is now handled rather than crashing on undefined. * feat(cli): carry tuned variable values into the install snippet Someone who tunes a block on its catalog page had no way to keep those values: the install command was the same one everybody gets, and the tuning stayed on the page. hyperframes add <item> --vars '<json>' now prints a mount element carrying data-variable-values, so the values land where the block is used. They ride on the host rather than being written into the installed file. That keeps the composition on disk byte-identical to the registry's, so a later reinstall can still tell an edit from an update, and it lets two mounts of the same block carry different values. * fix(catalog): serve the item's own directory so runtime paths resolve Some compositions assemble their asset URLs at run time — "compositions/components/" + texture + ".png" for the texture masks, a font the compiler pulled into _remote_media — and no scan of the markup can see a string that does not exist until a script concatenates it. Those items either rendered black or were dropped to a video that had never been uploaded. Each item that needs it now has its prepared directory published, and its payload carries a <base> pointing at it, so any relative path the composition invents resolves. caption-texture renders its masks again, and variable-font-flex has a preview at all for the first time: its MP4 and poster are both 403. Both layouts are published, because which one a composition asks for differs per item, and a directory only earns that if it is under 2 MB. The 12 MB texture sheet keeps the recorded video it already had. * fix(catalog): let the variables panel actually drive the composition Every control on the panel was inert. The values reached the composition and nothing repainted, because the payload had already been compiled: compiling inlines a mounted component and resolves its variables into the markup and CSS, so by the time a reader turns a knob there is nothing left to change. An item that declares variables now ships uncompiled, keeping the mount the runtime loads at run time, which is the only state where data-variable-values still means anything. The component travels inline as a data URI rather than a sibling file, because .html is the one type the docs host will not publish. The demo's own pinned values come off, so the reader's choices reach the mount instead of losing to the values the demo picked to show itself off. Measured on the rendered frame rather than the DOM: green rgb(98,207,144), blue rgb(6,6,199), violet rgb(177,147,230), and back to green. docs/public/catalog drops from 48 MB to 35 MB along the way, since an uncompiled payload carries far less than an inlined one. * feat(catalog): keep variable changes in the url A reader who tuned a piece lost it on reload, and had nothing to send anyone. The values now live in the query string, scoped by composition id so two links never read each other,and only the ones that differ from the defaults are written, so changing one knob gives a short URL rather than every variable spelled out. replaceState rather than pushState: dragging a slider should not leave a trail of history entries. An unreadable value is ignored rather than thrown, so a truncated or hand-edited link opens the piece at its defaults. * fix(catalog): only rewrite the url when a value actually changed * refactor(catalog): memoise the declared defaults on their content * feat(catalog): offer an install command carrying the tuned values The Install block is generated before anyone touches a knob, so it can only ever print the plain command. Someone who spent a minute tuning a piece copied it and got the defaults back. The panel now carries its own command in the Snippet tab, with --vars holding exactly the values that differ. An untouched piece still offers the same short command, so nothing gets noisier for the common case. * fix(catalog): a piece with nothing to render is a skip, not a failure caption-blend-difference is a stylesheet and a paragraph of prose — a class you add to your own captions, with no standalone scene to show. The generator treated that as a build failure, so every run ended by reporting something broken when nothing was. It now reports the shape it is and keeps its recorded video, which is the only honest preview such an item has. A genuine render failure still throws. * fix(catalog): restore variables from the url on a cold load A shared link opened at the defaults. The first render happens on the server, where there is no window to read the query string from, and React then hydrates against that markup and never revisits it — so the values only appeared once you touched a control. The URL is read again after mount, which is the first moment it exists. The value is also escaped once now rather than twice: URLSearchParams already decodes on the way out, and decoding a second time turned an SVG path full of percent-escapes into something that no longer parsed, besides doubling the length of every link. * fix(catalog): mount the preview with the values a link carried The frame was built from the declared defaults and the shared values were posted to it afterwards, which is too late for anything the composition reads once at init: a path arrived after the mark had already been drawn from the default one, so a link looked right in the panel and wrong on screen. * feat(catalog): the install command follows the values you tuned Copying the Install line gave the plain command back, because that block is generated before anyone touches a knob and had no way to know what changed. The tuned command only existed in the panel Snippet tab, which is not where anyone looks for it. The line now reads the same query string the panel writes, so the two agree without either component knowing the other exists, and a shared link carries the right command too. replaceState fires no event, so the panel announces its own writes. * fix(catalog): send a text variable to the preview once it is finished Every other control in the explorer reports a whole value on every event: a slider at any position is a position, a swatch is a colour. A text field is not. Typing v3 into a badge posted v first, so the preview remounted and rendered a composition built from half a word. The post now waits while a text field has focus and goes out when the edit is committed, with Enter or by clicking away. The field itself is unchanged and still tracks every keystroke. --------- Co-authored-by: Miguel Angel Simon Sierra <miguelangelsi07@gmail.com>
967 lines
44 KiB
Plaintext
967 lines
44 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."
|
|
---
|
|
|
|
import { InstallCommand } from "/snippets/install-command.jsx";
|
|
import { VariablesExplorer } from "/snippets/variables-explorer.jsx";
|
|
|
|
<VariablesExplorer
|
|
previewSrc="/public/catalog/components/grade-split-reveal.json"
|
|
compositionId="grade-split-reveal"
|
|
compositionSrc="compositions/components/grade-split-reveal.html"
|
|
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"}]}]}
|
|
>
|
|
|
|
```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>
|
|
```
|
|
|
|
</VariablesExplorer>
|
|
|
|
## Install
|
|
|
|
<InstallCommand command="npx hyperframes add grade-split-reveal" item="grade-split-reveal" />
|
|
|
|
That writes one file: `compositions/components/grade-split-reveal.html`.
|
|
|
|
## 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>
|
|
```
|
|
|
|
## Source
|
|
|
|
<Accordion title={`grade-split-reveal.html`}>
|
|
|
|
```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>
|
|
```
|
|
|
|
</Accordion>
|
|
|
|
{/* 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)
|