mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
feat(runtime): apply color grading in preview and render
This commit is contained in:
@@ -28,6 +28,22 @@ import { type DirectTimelineAdapter } from "./timeline-adapters.js";
|
||||
const MIN_PLAYBACK_RATE = 0.1;
|
||||
const MAX_PLAYBACK_RATE = 5;
|
||||
|
||||
export type ColorGradingTarget =
|
||||
| string
|
||||
| {
|
||||
id?: string | null;
|
||||
hfId?: string | null;
|
||||
selector?: string | null;
|
||||
selectorIndex?: number | null;
|
||||
};
|
||||
|
||||
export type ColorGradingCompareState = {
|
||||
enabled: boolean;
|
||||
position?: number;
|
||||
softness?: number;
|
||||
lineWidth?: number;
|
||||
};
|
||||
|
||||
function clampPlaybackRate(rate: number): number {
|
||||
if (!Number.isFinite(rate) || rate <= 0) return 1;
|
||||
return Math.max(MIN_PLAYBACK_RATE, Math.min(MAX_PLAYBACK_RATE, rate));
|
||||
@@ -303,6 +319,25 @@ class HyperframesPlayer extends HTMLElement {
|
||||
this.controlsApi?.updateTime(this._currentTime, this._duration);
|
||||
}
|
||||
|
||||
setColorGrading(target: ColorGradingTarget, grading: unknown) {
|
||||
this._sendControl("set-color-grading", { target, grading });
|
||||
}
|
||||
|
||||
clearColorGrading(target: ColorGradingTarget) {
|
||||
this._sendControl("set-color-grading", { target, grading: null });
|
||||
}
|
||||
|
||||
setColorGradingCompare(target: ColorGradingTarget, compare: ColorGradingCompareState) {
|
||||
this._sendControl("set-color-grading-compare", { target, compare });
|
||||
}
|
||||
|
||||
clearColorGradingCompare(target: ColorGradingTarget) {
|
||||
this._sendControl("set-color-grading-compare", {
|
||||
target,
|
||||
compare: { enabled: false },
|
||||
});
|
||||
}
|
||||
|
||||
get currentTime() {
|
||||
return this._currentTime;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user