Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
feat: refine comment sticker motion and styling
kashorina3db3e8758be
diff --git a/packages/comment-sticker/src/author.ts b/packages/comment-sticker/src/author.tsindex 2ea051ef..70c7c741 100644--- a/packages/comment-sticker/src/author.ts+++ b/packages/comment-sticker/src/author.ts@@ -129,7 +129,7 @@ export function decodeCommentStickerStyle(recipe: SvsRecipe, fonts: FontStackRefoffsetYPx: number(recipe, "enter-offset-y", -180),startScale: number(recipe, "enter-start-scale", 0.78),rotationDeltaDeg: number(recipe, "enter-rotation-delta", -4.5),- easing: oneOf(recipe, "enter-easing", ["linear", "ease-in", "ease-out", "ease-in-out"] as const, "ease-out"),+ easing: oneOf(recipe, "enter-easing", ["linear", "ease-in", "ease-out", "ease-in-out", "out-back"] as const, "ease-out"),},exit: {kind: oneOf(recipe, "exit", ["none", "fade", "fade-up"] as const, "fade-up"),diff --git a/packages/comment-sticker/src/manifest.ts b/packages/comment-sticker/src/manifest.tsindex a161a7eb..a192f7a7 100644--- a/packages/comment-sticker/src/manifest.ts+++ b/packages/comment-sticker/src/manifest.ts@@ -101,7 +101,7 @@ const style = object({enter: { schema: object({kind: { schema: enumString(["none", "fade", "pop", "slide-pop"]) }, durationFrames: { schema: unsignedInteger },offsetYPx: { schema: number }, startScale: { schema: positive }, rotationDeltaDeg: { schema: number },- easing: { schema: enumString(["linear", "ease-in", "ease-out", "ease-in-out"]) },+ easing: { schema: enumString(["linear", "ease-in", "ease-out", "ease-in-out", "out-back"]) },}) },exit: { schema: object({kind: { schema: enumString(["none", "fade", "fade-up"]) }, durationFrames: { schema: unsignedInteger },diff --git a/packages/comment-sticker/src/program.ts b/packages/comment-sticker/src/program.tsindex a129be89..72c56225 100644--- a/packages/comment-sticker/src/program.ts+++ b/packages/comment-sticker/src/program.ts@@ -69,6 +69,13 @@ function color(value: string, label: string): void {assert(/^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/iu.test(value), `${label} must be a six- or eight-digit hexadecimal color.`);}+function background(value: string, label: string): void {+ assert(+ /^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/iu.test(value) || /^linear-gradient\(.+\)$/iu.test(value),+ `${label} must be a hexadecimal color or linear gradient.`,+ );+}+function optionalText(value: string | undefined, label: string): void {if (value !== undefined) assert(value.trim().length > 0, `${label} cannot be blank.`);}@@ -106,7 +113,7 @@ export function assertCommentStickerStyle(value: CommentStickerStyle): void {positive(value.avatar.sizePx, "CommentStickerStyle.avatar.sizePx");nonNegative(value.avatar.borderWidthPx, "CommentStickerStyle.avatar.borderWidthPx");color(value.avatar.borderColor, "CommentStickerStyle.avatar.borderColor");- color(value.avatar.background, "CommentStickerStyle.avatar.background");+ background(value.avatar.background, "CommentStickerStyle.avatar.background");color(value.avatar.textColor, "CommentStickerStyle.avatar.textColor");assertTextStyle(value.header, "CommentStickerStyle.header");assertTextStyle(value.body, "CommentStickerStyle.body");@@ -117,7 +124,7 @@ export function assertCommentStickerStyle(value: CommentStickerStyle): void {finite(value.motion.enter.offsetYPx, "CommentStickerStyle enter offset");positive(value.motion.enter.startScale, "CommentStickerStyle enter scale");finite(value.motion.enter.rotationDeltaDeg, "CommentStickerStyle enter rotation");- assert(["linear", "ease-in", "ease-out", "ease-in-out"].includes(value.motion.enter.easing), "CommentStickerStyle enter easing is invalid.");+ assert(["linear", "ease-in", "ease-out", "ease-in-out", "out-back"].includes(value.motion.enter.easing), "CommentStickerStyle enter easing is invalid.");assert(["none", "fade", "fade-up"].includes(value.motion.exit.kind), "CommentStickerStyle exit kind is invalid.");integer(value.motion.exit.durationFrames, "CommentStickerStyle exit duration");finite(value.motion.exit.offsetYPx, "CommentStickerStyle exit offset");@@ -310,11 +317,15 @@ function transform(y: number, rotation: number, scale: number): string {return `translate3d(0px,${px(y)},0) rotate(${Number(rotation.toFixed(6))}deg) scale(${Number(scale.toFixed(6))})`;}-function motionProgress(value: number, easing: "linear" | "ease-in" | "ease-out" | "ease-in-out"): number {+function motionProgress(value: number, easing: "linear" | "ease-in" | "ease-out" | "ease-in-out" | "out-back"): number {const progress = Math.max(0, Math.min(1, value));if (easing === "linear") return progress;if (easing === "ease-in") return progress * progress * progress;if (easing === "ease-out") return 1 - Math.pow(1 - progress, 3);+ if (easing === "out-back") {+ const overshoot = 1.70158;+ return 1 + (overshoot + 1) * Math.pow(progress - 1, 3) + overshoot * Math.pow(progress - 1, 2);+ }return progress < 0.5 ? 4 * progress * progress * progress : 1 - Math.pow(-2 * progress + 2, 3) / 2;}@@ -327,7 +338,11 @@ function motionAnimation(style: CommentStickerStyle, duration: number): VisualAnreturn {keyframes: Array.from({ length: duration + 1 }, (_, atFrame) => {const enter = style.motion.enter;- const enterProgress = enterDuration === 0 ? 1 : motionProgress(atFrame / enterDuration, enter.easing);+ const enterRawProgress = enterDuration === 0 ? 1 : Math.max(0, Math.min(1, atFrame / enterDuration));+ const enterProgress = motionProgress(enterRawProgress, enter.easing);+ const enterOpacity = enter.easing === "out-back" && enter.kind !== "fade"+ ? Math.min(1, enterRawProgress * 1.35)+ : Math.max(0, Math.min(1, enterProgress));const exit = style.motion.exit;const exitProgress = exitDuration === 0 ? 0 : motionProgress((atFrame - exitStart) / exitDuration, exit.easing);const holdActive = style.motion.hold.kind === "float" && atFrame >= enterDuration && atFrame <= exitStart;@@ -342,7 +357,7 @@ function motionAnimation(style: CommentStickerStyle, duration: number): VisualAnatFrame,easing: "linear" as const,style: [- { name: "opacity", value: enterProgress * (1 - exitProgress) },+ { name: "opacity", value: enterOpacity * (1 - exitProgress) },{ name: "transform", value: transform(enterY + holdY + exitY, baseRotation + enterRotation + holdRotation, enterScale) },],};@@ -427,6 +442,7 @@ function bodyElement(input: {readonly width: number;readonly height: number;}): VisualElement {+ const bodyTypography = typography(input.style);const flow: VisualTextFlow = {form: { kind: "area" },inlineSize: "fixed",@@ -448,7 +464,7 @@ function bodyElement(input: {order: 6,kind: "text-flow",document: { paragraphs: [{ id: "body-paragraph", inlines: [{ kind: "text", id: "body-copy", text: input.text }] }] },- typography: typography(input.style),+ typography: { ...bodyTypography, trackingPx: input.style.sizePx * -0.02 },paints: [{ kind: "fill", paint: { kind: "solid", color: input.style.color } }],flow,sequences: [],@@ -572,7 +588,7 @@ function stickerElements(item: CommentStickerItemProgram): readonly VisualElemenkind: "box",style: [{ name: "align-items", value: "center" },- { name: "background-color", value: style.avatar.background },+ { name: "background", value: style.avatar.background },{ name: "border", value: `${px(style.avatar.borderWidthPx)} solid ${style.avatar.borderColor}` },{ name: "border-radius", value: "50%" },{ name: "box-sizing", value: "border-box" },diff --git a/packages/comment-sticker/src/types.ts b/packages/comment-sticker/src/types.tsindex b671bb16..6b08174d 100644--- a/packages/comment-sticker/src/types.ts+++ b/packages/comment-sticker/src/types.ts@@ -56,7 +56,7 @@ export type CommentStickerStyle = {readonly offsetYPx: number;readonly startScale: number;readonly rotationDeltaDeg: number;- readonly easing: "linear" | "ease-in" | "ease-out" | "ease-in-out";+ readonly easing: "linear" | "ease-in" | "ease-out" | "ease-in-out" | "out-back";};readonly exit: {readonly kind: "none" | "fade" | "fade-up";