// SPDX-License-Identifier: AGPL-3.0-only // Part of the Folia lyric stage port (see ../README.md): the list of lyric styles, in Folia's order, and what a // style is given and must answer. Folia discovers its styles from /entry.tsx; here they are listed by hand. import type { AudioLevels, Line, StageTunings, Theme } from '../types'; import { LYRIC_STYLE_NAMES, type LyricStyleId } from '../names'; import { createClassic } from './classic'; import { createCadenza } from './cadenza'; import { createPartita } from './partita'; import { createTilt } from './tilt'; export interface StyleContext { /** The style's own layer, filling the stage; it is removed with everything in it when the style goes. */ layer: HTMLDivElement; theme: Theme; lines: Line[]; /** The stage's size in CSS pixels, where Folia reads the window's. */ width: number; height: number; /** Pixels in one rem. */ rem: number; audio: () => AudioLevels; /** The styles' settings (Folia's defaults unless a look changed them) and the lyric size, 1 for a style's own. */ tunings: StageTunings; fontScale: number; } export interface StyleRenderer { /** The line on screen changed; null between lines. */ setLine(line: Line | null, index: number, time: number): void; /** Every frame while the stage draws, with the song's clock in seconds. */ frame(time: number, delta: number): void; destroy(): void; } export interface LyricStyle { id: string; /** Folia's name for the style. */ name: string; english: string; /** True for a style drawn over the bare colour, without the drifting shapes. */ hideShapes?: boolean; create(context: StyleContext): StyleRenderer; } const CREATE: Record = { classic: createClassic, cadenza: createCadenza, partita: createPartita, tilt: createTilt, }; export const LYRIC_STYLES: readonly LyricStyle[] = LYRIC_STYLE_NAMES.map((style) => ({ ...style, create: CREATE[style.id] }));