import { EightBittr } from "../EightBittr"; import { Actor } from "../types"; import { Section } from "./Section"; /** * Miscellaneous utility functions. */ export declare class Utilities extends Section { /** * Removes an Actor from an Array using Array.splice. If the actor has an * onDelete, that is called. * * @param actor * @param array The group containing the actor. * @param location The index of the Actor in the Array, for speed's * sake (by default, it is found using Array.indexOf). */ arrayDeleteActor(actor: Actor, array: Actor[], location?: number): void; /** * Switches an object from one Array to another using splice and push. * * @param object The object to move between Arrays. * @param arrayOld The Array to take the object out of. * @param arrayNew The Array to move the object into. */ arraySwitch(object: any, arrayOld: any[], arrayNew: any[]): void; /** * Sets an Actor's position within an Array to the front by splicing and then * unshifting it. * * @param object The object to move within the Array. * @param array An Array currently containing the object. */ arrayToBeginning(object: any, array: any[]): void; /** * Sets an Actor's position within an Array to the front by splicing and then * pushing it. * * @param object The object to move within the Array. * @param array An Array currently containing the object. */ arrayToEnd(object: any, array: any[]): void; /** * Sets an Actor's position within an Array to a specific index by splicing * it ot, then back in. * * @param object The object to move within the Array. * @param array An Array currently containing the object. * @param index Where the object should be moved to in the Array. */ arrayToIndex(object: any, array: any[], index: number): void; /** * Creates and returns a new HTML element. * * @param width How wide the canvas should be. * @param height How tall the canvas should be. * @param alpha Whether to enable alpha (transparency). * @returns A canvas of the given width and height height. */ createCanvas(width: number, height: number): HTMLCanvasElement; /** * Returns a element's 2D rendering context tuned for performance. * * @param canvas element to get a context for. * @param alpha Whether to enable alpha (transparency). * @returns 2D rendering context for the element. */ getContext(canvas: HTMLCanvasElement, alpha: boolean): CanvasRenderingContext2D; /** * Creates and returns an HTMLElement of the specified type. Any additional * settings Objects may be given to be proliferated via proliferateElement. * * @template TElement Type of the element to be created. * @param type The tag of the element to be created. * @param settings Additional settings to proliferated onto the Element. * @returns The created element. */ createElement(tag?: string, ...args: any[]): TElement; /** * Follows a path inside an Object recursively, based on a given path. * * @param object A container to follow a path inside. * @param path The ordered names of attributes to descend into. * @param num The starting index in path (by default, 0). * @returns The discovered property within object, or undefined if the * full path doesn't exist. */ followPathHard(object: any, path: string[], index?: number): any; /** * "Proliferates" all properties of a donor onto a recipient by copying each * of them and recursing onto child Objects. This is a deep copy. * * @param recipient An object to receive properties from the donor. * @param donor An object do donate properties to the recipient. * @param noOverride Whether pre-existing properties of the recipient should * be skipped (defaults to false). * @returns recipient */ proliferate(recipient: any, donor: any, noOverride?: boolean): any; /** * Identical to proliferate, but instead of checking whether the recipient * hasOwnProperty on properties, it just checks if they're truthy. * * @param recipient An object to receive properties from the donor. * @param donor An object do donate properties to the recipient. * @param noOverride Whether pre-existing properties of the recipient should * be skipped (defaults to false). * @returns recipient */ proliferateHard(recipient: any, donor: any, noOverride?: boolean): any; /** * Identical to proliferate, but tailored for HTML elements because many * element attributes don't play nicely with JavaScript Array standards. * Looking at you, HTMLCollection! * * @param recipient An HTMLElement to receive properties from the donor. * @param donor An object do donate properties to the recipient. * @param noOverride Whether pre-existing properties of the recipient should * be skipped (defaults to false). * @returns recipient */ proliferateElement(recipient: HTMLElement, donor: any, noOverride?: boolean): HTMLElement; /** * Takes a snapshot of the current screen canvas by simulating a click event * on a dummy link. * * @param name A name for the image to be saved as. * @param format A format for the image to be saved as (by default, png). * @remarks For security concerns, browsers won't allow this unless it's * called within a callback of a genuine user-triggered event. */ takeScreenshot(name: string, format?: string): void; } //# sourceMappingURL=Utilities.d.ts.map