@nmmty/lazycanvas
Version:
A simple way to interact with @napi-rs/canvas in an advanced way!
50 lines (49 loc) • 2.1 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 data {IOLazyCanvas} - The JSON data to read.
* @param opts {Object} - Optional settings.
* @param opts.debug {boolean} - 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 file {string} - The path to the JSON file.
* @param opts {Object} - Optional settings.
* @param opts.debug {boolean} - 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 data {Array<JSONLayer | Group>} - The array of JSON layers to parse.
* @param opts {Object} - Optional settings.
* @param opts.debug {boolean} - 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 layer {JSONLayer | IGroup | Group} - The JSON layer to parse.
* @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
* @returns {AnyLayer | Group} The parsed layer.
*/
private static layerParse;
/**
* Parses the fill style of a layer.
* @param layer {JSONLayer} - The layer whose fill style is to be parsed.
* @returns {string | Gradient | Pattern} The parsed fill style.
*/
private static fillParse;
}