UNPKG

@nmmty/lazycanvas

Version:

A simple way to interact with @napi-rs/canvas in an advanced way!

75 lines (74 loc) 2.16 kB
import { AnyLayer } from "../../types"; import { ILayersManager } from "../../types"; import { Group } from "../components/Group"; export declare class LayersManager implements ILayersManager { map: Map<string, AnyLayer | Group>; debug: boolean; constructor(debug?: boolean); /** * Add a layer to the map * @param layers {AnyLayer[]} - The `layer` or `group` to add to the map */ add(...layers: AnyLayer[]): this; /** * Remove a layer from the map * @param ids {string[]} - The `id` of the layer or group to remove */ remove(...ids: string[]): this; /** * ClearLayer all layers from the map */ clear(): this; /** * Get a layer from the map * @param id {string} - The `id` of the layer or group to get * @param cross {boolean} - Whether to search in groups or not */ get(id: string, cross?: boolean): AnyLayer | undefined; /** * Check if a layer exists in the map * @param id {string} - The `id` of the layer or group to check */ has(id: string): boolean; /** * Get the size of the map */ size(): number; /** * Get the values of the map */ values(): IterableIterator<AnyLayer>; /** * Get the keys of the map */ keys(): IterableIterator<string>; /** * Get the entries of the map */ entries(): IterableIterator<[string, AnyLayer]>; /** * For each layer in the map * @param callbackfn {Function} - The `callback` function to execute */ forEach(callbackfn: (value: AnyLayer, key: string, map: Map<string, AnyLayer>) => void): this; /** * Convert the map to a JSON object */ toJSON(): object; /** * Convert a JSON object to the map * @param json {object} - The `json` object to convert */ fromJSON(json: object): this; /** * Convert the map to an array */ toArray(): Array<AnyLayer>; /** * Convert an array to the map * @param array {Array<AnyLayer>} - The `array` to convert */ fromArray(array: Array<AnyLayer>): this; sort(): void; private crossSearch; }