UNPKG

@nmmty/lazycanvas

Version:

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

148 lines (147 loc) 4.46 kB
import { ScaleType, LayerType, AnyCentring, AnyGlobalCompositeOperation } from "../../types"; import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas"; import { LayersManager } from "../managers"; import { IBaseLayerMisc } from "./BaseLayer"; /** * Interface representing a Clear Layer. */ export interface IClearLayer { /** * The unique identifier of the layer. */ id: string; /** * The type of the layer, which is `Clear`. */ type: LayerType.Clear; /** * The z-index of the layer, determining its stacking order. */ zIndex: number; /** * The visibility of the layer. */ visible: boolean; /** * The properties of the Clear Layer. */ props: IClearLayerProps; } /** * Interface representing the properties of a Clear Layer. */ export interface IClearLayerProps { /** * The x-coordinate of the layer. */ x: ScaleType; /** * The y-coordinate of the layer. */ y: ScaleType; /** * The size of the layer, including width and height. */ size: { /** * The width of the layer. */ width: ScaleType; /** * The height of the layer. */ height: ScaleType; }; /** * The centring type of the layer. */ centring: AnyCentring; /** * Don't use, this is just for compatibility. */ globalComposite: AnyGlobalCompositeOperation; } /** * Class representing a Clear Layer. */ export declare class ClearLayer implements IClearLayer { /** * The unique identifier of the layer. */ id: string; /** * The type of the layer, which is `Clear`. */ type: LayerType.Clear; /** * The z-index of the layer, determining its stacking order. */ zIndex: number; /** * The visibility of the layer. */ visible: boolean; /** * The properties of the Clear Layer. */ props: IClearLayerProps; /** * Constructs a new ClearLayer instance. * @param {IClearLayerProps} [props] - The properties of the Clear Layer. * @param {IBaseLayerMisc} [misc] - Miscellaneous options for the layer. */ constructor(props?: IClearLayerProps, misc?: IBaseLayerMisc); /** * Sets the position of the layer in the 2D plane. * @param {ScaleType} [x] - The x-coordinate of the layer. * @param {ScaleType} [y] - The y-coordinate of the layer. * @returns {this} The current instance for chaining. */ setPosition(x: ScaleType, y: ScaleType): this; /** * Sets the size of the layer. * @param {ScaleType} [width] - The width of the layer. * @param {ScaleType} [height] - The height of the layer. * @returns {this} The current instance for chaining. */ setSize(width: ScaleType, height: ScaleType): this; /** * Sets the unique identifier of the layer. * * @param {string} [id] - The unique identifier. * @returns {this} The current instance for chaining. */ setID(id: string): this; /** * Sets the centring type of the layer. * @param {AnyCentring} [centring] - The centring type of the layer. * @returns {this} The current instance for chaining. */ setCentring(centring: AnyCentring): this; /** * Sets the visibility of the layer. * @param {boolean} [visible] - The visibility state of the layer. * @returns {this} The current instance for chaining. */ setVisible(visible: boolean): this; /** * Sets the z-index of the layer. * @param {number} [zIndex] - The z-index value of the layer. * @returns {this} The current instance for chaining. */ setZIndex(zIndex: number): this; /** * Draws the Clear Layer on the canvas. * @param {SKRSContext2D} [ctx] - The canvas rendering context. * @param {Canvas | SvgCanvas} [canvas] - The canvas instance. * @param {LayersManager} [manager] - The layer's manager. * @param {boolean} [debug] - Whether to enable debug logging. */ draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>; /** * Converts the Clear Layer to a JSON representation. * @returns {IClearLayer} The JSON representation of the Clear Layer. */ toJSON(): IClearLayer; protected validateProps(props: IClearLayerProps): IClearLayerProps; }