UNPKG

@diffusionstudio/core-v4

Version:

2D motion graphics and video rendering engine

56 lines (55 loc) 1.49 kB
import { TextCase, TextAlign, TextBaseline, Shadow, Stroke, Glow, Font } from '../../renderer'; import { StyleOverride } from './types'; import { Token } from './token'; import { hex } from '../../types'; declare class TextPrimitiveState { text: string; font: Font; color: hex; maxWidth: number; resolution: number; leading: number; opacity: number; casing: TextCase; align: TextAlign; baseline: TextBaseline; shadows: Shadow[]; strokes: Stroke[]; styles: StyleOverride[]; glow?: Glow; } export declare class TextPrimitive extends TextPrimitiveState { private isDirty; canvas: HTMLCanvasElement; ctx: CanvasRenderingContext2D; padding: { x: number; y: number; }; lines: Token[][]; /** * Create a new Text instance * @param options Configuration options */ constructor({ alpha, willReadFrequently, ...rest }?: CanvasRenderingContext2DSettings); get width(): number; get height(): number; get fontSize(): number; set fontSize(size: number); /** * Draw/update the text on the shared canvas if needed * @param options Optional parameters to update text, fontSize, and color */ render(): void; private alignLines; private renderLines; /** * Split text into lines based on maxWidth */ private getLines; private applyFont; private applyShadow; private applyStroke; private applyGlow; } export {};