@nmmty/lazycanvas
Version:
A simple way to interact with @napi-rs/canvas in an advanced way!
129 lines (128 loc) • 4.42 kB
TypeScript
import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
import { ColorType, ScaleType, LayerType } from "../../types";
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
import { LayersManager } from "../managers/LayersManager";
/**
* Interface representing a Morph Layer.
*/
export interface IMorphLayer extends IBaseLayer {
/**
* The type of the layer, which is `Morph`.
*/
type: LayerType.Morph;
/**
* The properties specific to the Morph Layer.
*/
props: IMorphLayerProps;
}
/**
* Interface representing the properties of a Morph Layer.
*/
export interface IMorphLayerProps extends IBaseLayerProps {
/**
* The size of the Morph Layer, including width, height, and radius.
*/
size: {
/**
* The width of the Morph Layer.
*/
width: ScaleType;
/**
* The height of the Morph Layer.
*/
height: ScaleType;
/**
* The radius of the Morph Layer.
*/
radius: ScaleType;
};
/**
* The stroke properties of the morph.
*/
stroke: {
/**
* The width of the stroke.
*/
width: number;
/**
* The cap style of the stroke.
*/
cap: CanvasLineCap;
/**
* The join style of the stroke.
*/
join: CanvasLineJoin;
/**
* The dash offset of the stroke.
*/
dashOffset: number;
/**
* The dash pattern of the stroke.
*/
dash: number[];
/**
* The miter limit of the stroke.
*/
miterLimit: number;
};
}
/**
* Class representing a Morph Layer, extending the BaseLayer class.
*/
export declare class MorphLayer extends BaseLayer<IMorphLayerProps> {
/**
* The properties of the Morph Layer.
*/
props: IMorphLayerProps;
/**
* Constructs a new MorphLayer instance.
* @param props {IMorphLayerProps} - The properties of the Morph Layer.
* @param misc {IBaseLayerMisc} - Miscellaneous options for the layer.
*/
constructor(props?: IMorphLayerProps, misc?: IBaseLayerMisc);
/**
* Sets the size of the Morph Layer.
* @param width {ScaleType} - The width of the Morph Layer.
* @param height {ScaleType} - The height of the Morph Layer.
* @param radius {ScaleType} - The radius of the Morph Layer (optional).
* @returns {this} The current instance for chaining.
*/
setSize(width: ScaleType, height: ScaleType, radius?: ScaleType): this;
/**
* Sets the color of the Morph Layer.
* @param color {string} - The color of the Morph Layer.
* @returns {this} The current instance for chaining.
* @throws {LazyError} If the color is not provided or invalid.
*/
setColor(color: ColorType): this;
/**
* Sets the stroke properties of the Morph Layer.
* @param width {number} - The width of the stroke.
* @param cap {string} - The cap style of the stroke.
* @param join {string} - The join style of the stroke.
* @param dash {number[]} - The dash pattern of the stroke.
* @param dashOffset {number} - The dash offset of the stroke.
* @param miterLimit {number} - The miter limit of the stroke.
* @returns {this} The current instance for chaining.
*/
setStroke(width: number, cap?: CanvasLineCap, join?: CanvasLineJoin, dash?: number[], dashOffset?: number, miterLimit?: number): this;
/**
* Sets whether the Morph Layer should be filled or stroked.
* @param filled {boolean} - If true, the layer will be filled; otherwise, it will be stroked.
* @returns {this} The current instance for chaining.
*/
setFilled(filled: boolean): this;
/**
* Draws the Morph 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 Morph Layer to a JSON representation.
* @returns {IMorphLayer} The JSON representation of the Morph Layer.
*/
toJSON(): IMorphLayer;
}