import { type DataOrError } from "../error"; import { type CanvasRenderingContext2D } from "canvas"; import { z } from "zod/v4"; import { type Theme, ThemeManager } from "./theme"; type ModuleContext = Parameters extends infer Args extends unknown[] ? ("3" extends keyof Args ? NonNullable : unknown) : never; type PainterContext> = { [K in keyof Modules]: (context: ModuleContext) => void; }[keyof Modules] extends (context: infer Context) => void ? Context : never; export declare abstract class Painter { static registerFonts(path: string): void; protected readonly theme: ThemeManager; protected static get assetsPath(): string; protected wrapPainter>({ theme, scale, modules, painterCtx, }: { theme?: string; scale?: number; modules: Modules; painterCtx: NoInfer>; }, /** * Drawing steps of the painter. Every element of the theme is drawn in * declaration order when the callback is omitted. */ callback?: (ctx: CanvasRenderingContext2D, currentTheme: NonNullable>, drawElements: () => Promise) => unknown): Promise>; constructor({ theme: { schema, searchPaths, defaultTheme }, }: { theme: { schema: Schema; searchPaths: string[]; defaultTheme: string; }; }); abstract draw(variables: Record, options: { scale?: number; } | Record): Promise>; abstract drawWithScoreSource(source: Adapter, variables: Record, options: { scale?: number; } | Record): Promise>; } export interface Bounds { x: number; y: number; width: number; height: number; } /** * Resolved layout of the painter, available to a module while it draws. */ export interface DrawLayout { /** * Final dimensions of the canvas, including the growth of the layout contributors. */ canvas: { width: number; height: number; }; /** * Position of the anchor of the element on the canvas. */ offset: { x: number; y: number; }; } export declare abstract class PainterModule { static readonly SCHEMA: z.ZodType; private static readonly BOUNDS_ELEMENT; abstract draw(ctx: CanvasRenderingContext2D, theme: Theme, element: z.infer, painterCtx: unknown, layout?: DrawLayout): Promise; /** * Bounding box the module actually occupies, relative to the anchor of the element. * * A module only grows the theme it is a layout contributor of when this box * is larger than the one reported by {@link PainterModule.getMinimumBounds}. */ getBounds(ctx: CanvasRenderingContext2D, theme: Theme, element: z.infer, painterCtx: unknown): Promise; /** * Bounding box the module occupies with the dimensions declared in the theme, * relative to the anchor of the element. */ getMinimumBounds(_ctx: CanvasRenderingContext2D, _theme: Theme, element: z.infer, _painterCtx: unknown): Promise; } export {};