@mastra/core
Version:
64 lines • 2.57 kB
TypeScript
/**
* Pure functions for caption overlay rendering on screencast frames.
*
* Kept separate from browser-recording.ts so the lifecycle/tool code stays
* focused and the pixel-level logic is easy to test.
*/
/** A caption is a short piece of agent-authored text shown for a window of time. */
export interface RecordingCaption {
/** Milliseconds since recording start when the caption was added. */
timestampMs: number;
/** Plain text caption. */
text: string;
/** How long the caption should remain visible (ms). */
durationMs: number;
}
/** Decoded RGBA frame buffer. */
export interface RgbaFrame {
width: number;
height: number;
/** Tightly packed RGBA pixels (width * height * 4 bytes). */
data: Uint8ClampedArray;
}
/**
* Pick the caption that should be visible at a given timestamp.
*
* If multiple captions overlap (a new caption starts before the previous
* expires), the newer one wins.
*
* Returns undefined when no caption is active at `t`.
*/
export declare function selectCaptionAt(captions: readonly RecordingCaption[], t: number): RecordingCaption | undefined;
/**
* Decode a JPEG buffer into an RGBA pixel array.
* Throws when the JPEG cannot be parsed.
*/
export declare function decodeJpeg(jpegBytes: Uint8Array): RgbaFrame;
/** Options controlling how a caption is drawn over a frame. */
export interface CaptionOverlayOptions {
/** Integer scaling factor for the bitmap font. Default 2. */
fontScale?: number;
/** Vertical padding (in pixels) above and below the text inside the strip. */
padding?: number;
/** Bottom margin between the strip and the bottom of the frame. */
marginBottom?: number;
/** Background RGB color. Default black. */
backgroundColor?: [number, number, number];
/** Background alpha 0..255. Default ~180 (semi-transparent). */
backgroundAlpha?: number;
/** Text RGB color. Default white. */
textColor?: [number, number, number];
}
/**
* Draw a caption at the bottom of the frame in-place.
*
* Renders a semi-transparent dark strip with the text centered on top.
* Long captions are truncated with an ellipsis to fit the frame width.
*/
export declare function drawCaptionOnFrame(frame: RgbaFrame, caption: string, options?: CaptionOverlayOptions): void;
/**
* Encode an RGBA frame back into JPEG bytes. Used by the recording pipeline
* when re-encoding a frame after burning a caption onto it.
*/
export declare function encodeJpeg(frame: RgbaFrame, quality?: number): Uint8Array;
//# sourceMappingURL=overlay.d.ts.map