@nmmty/lazycanvas
Version:
A simple way to interact with @napi-rs/canvas in an advanced way!
50 lines (49 loc) • 2.13 kB
TypeScript
import { IOLazyCanvas, LazyCanvas } from "../../LazyCanvas";
/**
* Class responsible for reading and parsing JSON data into a LazyCanvas instance.
*/
export declare class JSONReader {
/**
* Reads JSON data and converts it into a LazyCanvas instance.
* @param {IOLazyCanvas} [data] - The JSON data to read.
* @param {Object} [opts] - Optional settings.
* @param {boolean} [opts.debug] - Whether to enable debug logging.
* @returns {LazyCanvas} The created LazyCanvas instance.
* @throws {LazyError} If the data contains invalid options or no layers are found.
*/
static read(data: IOLazyCanvas, opts?: {
debug?: boolean;
}): LazyCanvas;
/**
* Reads a JSON file and converts it into a LazyCanvas instance.
* @param {string} [file] - The path to the JSON file.
* @param {Object} [opts] - Optional settings.
* @param {boolean} [opts.debug] - Whether to enable debug logging.
* @returns {LazyCanvas} The created LazyCanvas instance.
* @throws {LazyError} If the file does not exist.
*/
static readFile(file: string, opts?: {
debug?: boolean;
}): LazyCanvas;
/**
* Parses an array of JSON layers into an array of AnyLayer or Group instances.
* @param {Array<JSONLayer | Group>} [data] - The array of JSON layers to parse.
* @param {Object} [opts] - Optional settings.
* @param {boolean} [opts.debug] - Whether to enable debug logging.
* @returns {Array<AnyLayer | Group>} The parsed layers.
*/
private static layersParse;
/**
* Parses a single JSON layer into an AnyLayer or Group instance.
* @param {JSONLayer | IGroup | Group} [layer] - The JSON layer to parse.
* @param {IBaseLayerMisc} [misc] - Miscellaneous options for the layer.
* @returns {AnyLayer | Group} The parsed layer.
*/
private static layerParse;
/**
* Parses the fill style of a layer.
* @param {JSONLayer} [layer] - The layer whose fill style is to be parsed.
* @returns {string | Gradient | Pattern} The parsed fill style.
*/
private static fillParse;
}