import { DisplayObject, Stage } from "@thegraid/easeljs-module"; /** basic fields for layout of graphics on template */ export type LayoutSpec = { /** pixel width of png template */ width: number; /** pixel height of png template */ height: number; /** amount to extend card image beyond cardw & cardh; (typically: .1 inch, 25-30 mm) */ bleed?: number; /** indent from width & height for safe text & graphics */ safe?: number; /** if defined, paint a bg RectShape behind the ImageGrid */ bgColor?: string; /** [1: already in pixels] scale factor for [x0/x1, y0, delx, dely] --> pixels */ dpi?: number; /** set scale on View canvas [.1] */ scale?: number; }; /** layout for grid of graphics for print & punch */ export type GridSpec = LayoutSpec & { /** pixel width of png template */ width: number; /** pixel height of png template */ height: number; /** number of rows in grid */ nrow: number; /** number of items per row */ ncol: number; /** top margin 'indent' to center of card */ y0: number; /** even row indent to center of card [required] */ x0: number; /** odd row indent [x0] used for hex-packed templates */ x1?: number; /** offset per column: cardw + icg; with dely --> landscape vs portrait */ delx: number; dely: number; /** cut size of card image on template (blue lines) [cardw <= delx]; */ cardw?: number; /** cut size of card image on template (blue lines) [cardh <= dely]; */ cardh?: number; /** for close-packed shapes, exclude bleed on Central edges, include on L & R */ trimLCR?: boolean; /** true if template includes slots for double-sided images [symetric from bottom] */ double?: boolean; /** true to split images into frontAry & backAry (for mini-card double/split template) */ split?: boolean; /** set true or false to override orientation derived from delx/dely */ land?: boolean; }; export type PageSpec = { layoutSpec?: LayoutSpec; frontObjs?: DisplayObject[]; backObjs?: (DisplayObject | undefined)[] | undefined; canvas?: HTMLCanvasElement; basename?: string; }; /** make canvas pages for previewing & download for print * * Setup html buttons, manage canvases, delegate to addObjects() */ export declare class PageMaker { makePageSpecs: () => PageSpec[]; buttonId: string; label: string; constructor(makePageSpecs: () => PageSpec[], buttonId?: string, label?: string); /** stage for addObjects */ stage: Stage; /** draw objects on this canvas, retain in pageSpec.canvas */ canvas: HTMLCanvasElement; scales: string[]; scalePlus(): void; scaleMinus(): void; setScale(newScale?: string): void; /** * create a stage on given canvas, for addObjects() * @param layoutSpec with { height, width, dpi, scale, bgColor } * @param canvasId ['gridCanvas'] any string or an HTMLCanvasElement; suitable for new Stage() * @param scale [.2] canvasDiv.style.setProperty('scale', `${scale}`) */ setStageAndCanvas(layoutSpec: LayoutSpec, canvasId?: string | HTMLCanvasElement): void; setCanvasSize(width?: number, height?: number): void; setAnchorClick(id: string, label: string, onclick?: ((ev: MouseEvent) => void) | 'stop'): void; downloadPageSpecs(pageSpecs: PageSpec[]): void; /** Id of current canvas to view */ canvasId: string | undefined; /** add canvas to 'canvasDiv' */ addCanvas(canvas: HTMLCanvasElement | undefined): void; downloadImage(canvas: HTMLCanvasElement, filename?: string, downloadId?: string): void; /** * Make a single page image, injecting the canvas into given pageSpec. * * Make a Stage on canvas (maybe create from canvasId); * fill background then place objects using gridSpec. * * Set pageSpec.canvas with completed HTMLCanvasElement. * * @param pageSpec \{ layoutSpec, width, height } * @param canvas a Canvas or canvasId * @returns (pageSpec.canvas holding the page image) */ makePage(pageSpec: PageSpec, canvas?: HTMLCanvasElement | string): PageSpec; /** * override this abstract method to add objects to this.stage & canvas * @param pageSpec: { frontObjs, backObjs? } */ addObjects(pageSpec: PageSpec, x0?: number, y0?: number): void; } /** add "Tile" (cards, tokens) to a grid; per GridSpec. */ export declare class ImageGrid extends PageMaker { static circle_1_inch: GridSpec; /** 5 rows of 7 columns */ static hexSingle_1_19: GridSpec; /** 5 rows of 7 columns */ static hexDouble_1_19: GridSpec; /** 8 rows of 8 columns */ static circDouble_0_79: GridSpec; static euroPoker: GridSpec; static cardSingle_3_5: GridSpec; static cardSingle_1_75X: GridSpec; /** new PPG mini-card portrait, split */ static cardSingle_1_75: GridSpec; /** new PPG mini-card portrait */ static cardDouble_1_75: GridSpec; /** place objects (front & back) on this.stage, filling rows by column, until nrows filled. * * @returns number of child ojects added */ addObjects(pageSpec: PageSpec): number; }