Videos
This commit is contained in:
parent
b98f0e3904
commit
a8165249a4
24 changed files with 1486 additions and 105 deletions
|
|
@ -4,8 +4,10 @@ import type { Page } from 'playwright';
|
|||
import { LEAD_IN_S, OUTPUT_DIR } from './config.js';
|
||||
import {
|
||||
clearVignette,
|
||||
hideAdScene,
|
||||
hideCaption,
|
||||
setCursorScale,
|
||||
showAdScene,
|
||||
showCaption,
|
||||
showOutro,
|
||||
zoomReset,
|
||||
|
|
@ -195,8 +197,9 @@ async function runActivity(ctx: ScriptCtx, step: Activity): Promise<void> {
|
|||
const point = await resolveTarget(ctx, step.target);
|
||||
await ctx.page.mouse.move(point.x, point.y);
|
||||
const perStepMs = Math.floor(step.durationMs / Math.max(1, step.steps));
|
||||
const delta = step.direction === 'out' ? -MAP_ZOOM_WHEEL_DELTA : MAP_ZOOM_WHEEL_DELTA;
|
||||
for (let i = 0; i < step.steps; i++) {
|
||||
await ctx.page.mouse.wheel(0, MAP_ZOOM_WHEEL_DELTA);
|
||||
await ctx.page.mouse.wheel(0, delta);
|
||||
if (perStepMs > 0) await sleep(perStepMs);
|
||||
}
|
||||
return;
|
||||
|
|
@ -219,6 +222,12 @@ async function runActivity(ctx: ScriptCtx, step: Activity): Promise<void> {
|
|||
case 'showOutro':
|
||||
await showOutro(ctx.page, step.brand, step.tagline, step.url);
|
||||
return;
|
||||
case 'showAdScene':
|
||||
await showAdScene(ctx.page, step.scene);
|
||||
return;
|
||||
case 'hideAdScene':
|
||||
await hideAdScene(ctx.page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -232,6 +241,13 @@ async function resolveTarget(
|
|||
if (targets.length === 0) throw new Error('No visible hexagon to target');
|
||||
return { x: targets[0].x, y: targets[0].y };
|
||||
}
|
||||
if (target.kind === 'viewportFraction') {
|
||||
const viewport = ctx.page.viewportSize() ?? { width: 1920, height: 1080 };
|
||||
return {
|
||||
x: Math.round(Math.min(1, Math.max(0, target.xFrac)) * viewport.width),
|
||||
y: Math.round(Math.min(1, Math.max(0, target.yFrac)) * viewport.height),
|
||||
};
|
||||
}
|
||||
const box = await ctx.page.locator(target.selector).boundingBox();
|
||||
if (!box) throw new Error(`No bounding box for selector: ${target.selector}`);
|
||||
return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue