@nmmty/lazycanvas
Version:
A simple way to interact with @napi-rs/canvas in an advanced way!
147 lines (146 loc) • 4.37 kB
TypeScript
import { ScaleType, LayerType, AnyCentring, AnyGlobalCompositeOperation } from "../../types";
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
import { LayersManager } from "../managers/LayersManager";
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 props {IClearLayerProps} - The properties of the Clear Layer.
* @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
*/
constructor(props?: IClearLayerProps, misc?: IBaseLayerMisc);
/**
* Sets the position of the layer in the 2D plane.
* @param x {ScaleType} - The x-coordinate of the layer.
* @param y {ScaleType} - 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 width {ScaleType} - The width of the layer.
* @param height {ScaleType} - 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 centring {AnyCentring} - The centring type of the layer.
* @returns {this} The current instance for chaining.
*/
setCentring(centring: AnyCentring): this;
/**
* Sets the visibility of the layer.
* @param visible {boolean} - 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 zIndex {number} - 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 ctx {SKRSContext2D} - The canvas rendering context.
* @param canvas {Canvas | SvgCanvas} - The canvas instance.
* @param manager {LayersManager} - The layers manager.
* @param debug {boolean} - 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;
}