import { Constructor } from "@thegraid/common-lib"; import { Container, DisplayObject } from "@thegraid/easeljs-module"; import { ImageGrid, PageSpec, type GridSpec } from "./image-grid"; import { NamedContainer } from "./named-container"; import { type Paintable } from "./paintable"; /** An exportable "Tile"; implemented by CardObject. */ export interface Tile extends DisplayObject { makeShape(size?: number): Paintable; makeBleed(bleed?: number): DisplayObject; } /** * Basic implementation, with RectShape. Example of use for TileExporter. */ export declare class TileImpl extends NamedContainer implements Tile { /** RectShape; override to make any Paintable */ makeShape(size?: number): Paintable; /** For TileExporter. base implementation: scale up from this.makeShape() * * Override to suit * @param bleed size of bleed to add, typically from GridSpec.bleed (0) */ makeBleed(bleed?: number, bleedColor?: string): Paintable; } /** * Claz has static if defined, * then rotateBack: number of backTile. */ interface Claz extends Constructor { /** 0 => flip-on-horiz-axiz, 180 => flip-on-vert-axis, undefined => blank */ rotateBack?: number | undefined; } /** [number of copies, Constructor, ... constructor args] */ export type CountClaz = [count: number, claz: Claz, ...args: any]; /** an Exporter of a Grid of Tiles, uses ImageGrid */ export declare class TileExporter { imageGrid: ImageGrid; constructor(pageMaker?: typeof ImageGrid); /** override using clazToTemplate() to fill PageSpecs[] */ makeImagePages(): PageSpec[]; /** rotate card to align with template orientation */ setOrientation(card: Tile, gridSpec: GridSpec, rot?: number): void; /** Compose tile = new claz(...args) with bleedShape = makeBleed(tile) * @returns Container[bleedShape, tile] */ composeTile(claz: Claz, args: any[], gridSpec: GridSpec, back?: boolean, edge?: 'L' | 'R' | 'C'): Container; /** * Make outer bleed for the given tile. Trim bounds if on L or R edge */ makeBleed(tile: Tile, gridSpec: GridSpec, back: boolean, edge?: 'L' | 'R' | 'C'): DisplayObject; /** defered page to continue filling */ openSpec?: PageSpec; openNt: number; /** * Each invocation adds images & increments nt (from 0 ... ) * * Append a new PageSpec to pageSpecs when a page is full; * * Ultimately, each PageSpec contains a CanvasElement (filled with Tiles/Images: frontObjs & backObjs) * That canvas will be available to view & download as .png file * * Some of this implementation may eventually be refactored into the ImageGrid PageMaker. * Depending on whether split & double & open are generally useful. * * @param countClaz [count, class, ...args] * @param gridSpec * @param pageSpecs * @param open [false] set true to append next images to current pageSpec * @returns the given PageSpec[] extended to hold the new pages */ clazToTemplate(countClaz: CountClaz[], gridSpec?: GridSpec, pageSpecs?: PageSpec[], open?: boolean): PageSpec[]; } export {};