/**
* Canvas rendering of resource blocks (issue #49 §7).
*
* Draws an embedded `Resource` (bitmap / svg / table) plus its caption. Image
* payloads (bitmaps, SVGs) live out-of-band in IndexedDB, which is owned by the
* sandbox — the core renderer is synchronous and cannot fetch them itself. The
* host therefore pre-populates a small in-memory registry keyed by `fileId`
* (see {@link registerResourceImage}). When an image is not yet decoded the
* renderer draws a neutral placeholder so layout stays stable.
*
* Caption + inline `:ref` segments reuse the same per-line rich-text painter as
* body text. Refs are drawn in the configured link colour; canvas has no click
* surface, so clickability is PDF-only for v1.
*/
import type { VDTBlock, ResolvedResourceBlock, RoundedOutline, VDTResourceVideo } from '../vdt.js';
/** A decoded image the canvas backend can `drawImage`. */
export type ResourceImageSource = CanvasImageSource;
export interface RegisterResourceImageOptions {
/** The source is vector art (an SVG `
`): every `drawImage` of it
* re-rasterises the document, so the backend rasterises it once at each
* size it shows at in device pixels and blits the bitmap thereafter (see
* {@link drawResourceImage}). Defaults to true for an `HTMLImageElement`
* — the host decodes rasters through `createImageBitmap`. */
vector?: boolean;
/** Whether `diagramStyle.singleInk` recolours this picture on canvas:
* `true` tints the pixels of this SVG picture — a figure, a cell image,
* a design image or box icon whose resource is an SVG — to the
* document's ink (the mapping `applySingleInkToSvg` applies to markup),
* never a bitmap; `false` paints it as given, for a picture recoloured
* with `applySingleInkToSvg` before it was decoded (`registerBundleImages`
* and the Sandbox do). Unset, the render decides
* (`RenderPageOptions.singleInk`, off by default in postext 1.x, where
* hosts recolour the markup themselves). An `
` whose `src` is an
* SVG data URI marked by `applySingleInkToSvg` (`SINGLE_INK_MARK`) is
* never tinted, whatever this says. (A design image of a VDT built
* before design images carried `imageKind` is tinted when it is a vector
* source or registered with `true`.) */
singleInk?: boolean;
}
/** Register (or replace) a decoded image for a `fileId`. */
export declare function registerResourceImage(fileId: string, image: ResourceImageSource, options?: RegisterResourceImageOptions): void;
/** Remove a cached image (e.g. when its resource is deleted). */
export declare function unregisterResourceImage(fileId: string): void;
/** Clear the entire image registry. */
export declare function clearResourceImages(): void;
/** Look up a decoded image. Exposed so the host can check what still needs
* decoding before a render. */
export declare function getResourceImage(fileId: string): ResourceImageSource | undefined;
/** Told of every image a render paints as a placeholder (nothing
* registered for its `fileId`). Set by `renderPageToCanvas` for the span of
* one synchronous page paint when the host asked for warnings. */
export type MissingImageSink = (fileId: string, resourceId?: string) => void;
/** Install the sink for the paint in progress; returns the one it replaces,
* for the caller to restore. */
export declare function setMissingImageSink(sink: MissingImageSink | null): MissingImageSink | null;
/** Set {@link tintUnflagged} for the paint in progress; returns the value it
* replaces, for the caller to restore. */
export declare function setTintUnflagged(on: boolean): boolean;
/** Bytes of vector bitmaps currently cached (diagnostics / tests). */
export declare function resourceRasterCacheBytes(): number;
/** How a picture is painted under `diagramStyle.singleInk`: the document's
* ink (null when single ink is off), and whether the picture is an SVG
* (`true`), a bitmap (`false`) or unknown — a design image of a VDT built
* before design images carried `imageKind` (`undefined`: the registry
* decides). */
export interface ImageInk {
inkHex: string | null;
svg?: boolean;
/** Paint the picture's silhouette in this colour (`VDTDesignImageBlock.tint`,
* #995), whatever the picture and the document's ink. */
tint?: string;
}
/** Draw the registered image of `fileId` into the box, through the raster
* cache for vector sources — rasterised at the size the box has on the
* device under the context's transform ({@link vectorRasterSize}), tinted
* to the document's ink for a raw SVG picture of a single-ink document
* (see {@link ImageInk}). Returns false
* when nothing is registered, so the caller can paint its placeholder (the
* miss goes to the render's {@link MissingImageSink}, with `resourceId`
* when the caller knows it). */
export declare function drawResourceImage(ctx: CanvasRenderingContext2D, fileId: string, x: number, y: number, w: number, h: number, ink?: ImageInk, resourceId?: string): boolean;
/** The play mark and the QR code of a video's poster (#454), over the body
* at (`bx`, `by`). The positions are physical and the code must not read
* mirrored: on a mirrored page they are drawn through a reflection about
* the body, which undoes the page's. */
export declare function paintVideoOverlays(ctx: CanvasRenderingContext2D, video: VDTResourceVideo, bx: number, by: number, bw: number): void;
/** Trace a rounded outline (per-corner radii) as the current path. */
export declare function roundedOutlinePath(ctx: CanvasRenderingContext2D, o: RoundedOutline): void;
/** The labels of a `:::figure` drawn on its picture (#860), its body's
* top-left corner at (`bx`, `by`): each one through its matrix, its
* plate, its halo, then its lines. */
export declare function paintFigureLabels(ctx: CanvasRenderingContext2D, rb: ResolvedResourceBlock, bx: number, by: number): void;
export declare function renderResourceBlock(ctx: CanvasRenderingContext2D, block: VDTBlock,
/** The document's single ink (`documentInkHex`), null when off. */
inkHex?: string | null): void;
//# sourceMappingURL=renderResourceBlock.d.ts.map