import { type XY } from "@thegraid/common-lib"; import { Bitmap } from "@thegraid/easeljs-module"; /** Simple async Image loader [from ImageReveal.loadImage()] * * see also: createjs.ImageLoader, which we don't use. * * Migrated from hexLib (Jun 20, 2025) */ export declare class ImageLoader { static ipser: number; static defaultSize: XY; /** * Promise to load url as HTMLImageElement */ loadImage(fname0: string, ext?: string): Promise; /** * load all fnames, return Promise.all() * @param fnames */ loadImages(fnames?: string[], ext?: string): Promise>; /** * * @param args - * - root: path to image directory with trailing '/' * - fnames: string[] basenames of each image to load * - ext: file extension (for ex: 'png' or 'jpg') * * @param imap supply or create new Map() * @param cb invoked with (imap) */ constructor(args: { root: string; fnames: string[]; ext: string; }, cb?: (imap: Map) => void); imap: Map; ipmap: Map>; readonly root: string; readonly fnames: string[]; readonly ext: string; imagePromises: Promise[]; imageMapPromise: Promise>; } export declare class AliasLoader { static loader: AliasLoader; constructor(fnames?: string[], aliases?: { [key: string]: string; }); /** * Map key name to actual file name, so imageArgs.fnames can be more stable. * * fnames: this.fromAlias(['name1', 'name2', ...]) * * 'name1' can be actual filename, or an alias. */ aliases: { [key: string]: string; }; /** * filenames, sans directory and extension (which are supplied from imageArgs) */ set fnames(fnames: string[]); get fnames(): string[]; fromAlias(names: string[]): string[]; /** initial default: 'assets/image/' [] 'png' */ imageArgs: { root: string; fnames: string[]; ext: string; }; imageLoader: ImageLoader; /** use ImageLoader to load images, THEN invoke callback. */ loadImages(cb?: (imap?: Map) => void): void; /** lookup image form ImageLoader imap, using aliases[name] ?? name. */ getImage(name: string): HTMLImageElement; /** * new Bitmap(this.getImage(name)); * * Set scaleX & scaleY to render to given size. * * offset (either regXY or XY) so image is centered at 0,0 * * @param name from this.imap.keys(); * @param size [ImageLoader.defaultSize] bitmap.scaleXY = size / max(img.width, img.height) * @param offsetReg [true] * - if true: regX/Y = (w/2, h/2) and XY = (0, 0) * - if false: regX/Y = (0, 0) and XY = (-w/2, -h/2) * - either way: image renders centered around (0, 0); * @return new Bitmap() containing the named image (no image if name was not loaded) */ getBitmap(name: string, size?: number | XY, offsetReg?: boolean): Bitmap; }