summaryrefslogtreecommitdiff
path: root/apps/web/src/services/renderer/resolve.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/services/renderer/resolve.ts')
-rw-r--r--apps/web/src/services/renderer/resolve.ts25
1 files changed, 15 insertions, 10 deletions
diff --git a/apps/web/src/services/renderer/resolve.ts b/apps/web/src/services/renderer/resolve.ts
index 809f7103..5335de2d 100644
--- a/apps/web/src/services/renderer/resolve.ts
+++ b/apps/web/src/services/renderer/resolve.ts
@@ -1,4 +1,4 @@
-import { mediaTimeToSeconds } from "opencut-wasm";
+import { mediaTimeToSeconds, roundMediaTime } from "@/wasm";
import { getElementLocalTime } from "@/animation";
import { resolveEffectParamsAtTime } from "@/animation/effect-param-channel";
import {
@@ -13,6 +13,7 @@ import {
resolveGraphicElementParamsAtTime,
} from "@/graphics";
import {
+ buildTextBackgroundFromElement,
getTextMeasurementContext,
measureTextElement,
} from "@/text/measure-element";
@@ -204,7 +205,7 @@ async function resolveVideoNode({
const frame = await videoCache.getFrameAt({
mediaId: node.params.mediaId,
file: node.params.file,
- time: mediaTimeToSeconds({ time: sourceTimeTicks }),
+ time: mediaTimeToSeconds({ time: roundMediaTime({ time: sourceTimeTicks }) }),
});
if (!frame) {
return null;
@@ -235,10 +236,10 @@ async function resolveImageNode({
node: ImageNode;
context: ResolveContext;
}): Promise<ResolvedVisualSourceNodeState | null> {
- const source = await loadImageSource(
- node.params.url,
- node.params.maxSourceSize,
- );
+ const source = await loadImageSource({
+ url: node.params.url,
+ maxSourceSize: node.params.maxSourceSize,
+ });
const visualState = resolveVisualState({
params: node.params,
context,
@@ -330,6 +331,7 @@ function resolveTextNode({
elementStartTime: node.params.startTime,
elementDuration: node.params.duration,
});
+ const background = buildTextBackgroundFromElement({ element: node.params });
return {
transform: resolveTransformAtTime({
@@ -343,13 +345,16 @@ function resolveTextNode({
localTime,
}),
textColor: resolveColorAtTime({
- baseColor: node.params.color,
+ baseColor:
+ typeof node.params.params.color === "string"
+ ? node.params.params.color
+ : "#ffffff",
animations: node.params.animations,
propertyPath: "color",
localTime,
}),
backgroundColor: resolveColorAtTime({
- baseColor: node.params.background.color,
+ baseColor: background.color,
animations: node.params.animations,
propertyPath: "background.color",
localTime,
@@ -421,7 +426,7 @@ async function resolveBackdropSource({
const frame = await videoCache.getFrameAt({
mediaId: node.params.mediaId,
file: node.params.file,
- time: mediaTimeToSeconds({ time: sourceTimeTicks }),
+ time: mediaTimeToSeconds({ time: roundMediaTime({ time: sourceTimeTicks }) }),
});
if (!frame) {
return null;
@@ -434,7 +439,7 @@ async function resolveBackdropSource({
};
}
- const source = await loadImageSource(node.params.url);
+ const source = await loadImageSource({ url: node.params.url });
return {
source: source.source,
width: source.width,