UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

32 lines • 1.67 kB
/** * Whether these bytes are an SVG. * * The test reads a prefix, not the whole type. A server may send `image/svg+xml; charset=utf-8`, * and these images come from customer origins and CDNs, not only from this repository's own * server. An exact match lets that form through to `createImageBitmap`, which rejects SVG bytes, * and the image then disappears with no sign of why. * @param blob - The bytes to test. * @returns Whether the bytes are an SVG. */ export declare function isSvgBlob(blob: Blob): boolean; /** * Draws an SVG into a canvas at its own intrinsic size. * * `createImageBitmap` refuses SVG bytes (`InvalidStateError`, measured in Chrome 153, even for an * SVG with an explicit `width` and `height`), so an SVG cannot travel to the atlas worker as it is. * An `<img>` element renders the same bytes. This function does that conversion once, at load time. * @param blob - The SVG bytes. * @returns The rasterized canvas, or null when the SVG does not render, or declares no size. */ export declare function rasterizeSvg(blob: Blob): Promise<HTMLCanvasElement | null>; /** * Rasterizes an SVG and hands the pixels back as PNG bytes. * * The result is a `Blob` and not a canvas on purpose. A layer packs in the atlas worker only while * every one of its sources is a `Blob`, so one canvas among a thousand booth logos would drop the * whole layer back onto the main thread — the exact layer the worker exists for. * @param blob - The SVG bytes. * @returns The PNG bytes, or null when the SVG does not render. */ export declare function svgToPngBlob(blob: Blob): Promise<Blob | null>; //# sourceMappingURL=rasterize-svg.d.ts.map