@nmmty/lazycanvas
Version:
A simple way to interact with @napi-rs/canvas in an advanced way!
87 lines (86 loc) • 3.66 kB
TypeScript
import { ScaleType, IBaseLayer, IBaseLayerProps, AnyCentring, AnyGlobalCompositeOperation } from "../../types";
import { LayerType } from "../../types/enum";
export declare class BaseLayer<T extends IBaseLayerProps> {
id: string;
type: LayerType;
zIndex: number;
visible: boolean;
props: T;
constructor(type?: LayerType, props?: T);
/**
* @description Position of the layer in the 2D plane. You can use `numbers`, `percentages`, `px`, `vw`, `vh`, `vmin`, `vmax`.
* @param x {ScaleType} - The `x` position of the layer
* @param y {ScaleType} - The `y` position of the layer
*/
setPosition(x: ScaleType, y: ScaleType): this;
/**
* @description Opacity of the layer. The value must be between `0` and `1`.
* @param opacity {number} - The `opacity` of the layer
*/
setOpacity(opacity: number): this;
/**
* @description Sets the `id` of the layer.
* @param id {string} - The `id` of the layer
*/
setID(id: string): this;
/**
* @description Sets shadow of layer.
* @param color {string} - The `color` of the filter
* @param blur {number} - The `blur` of the filter
* @param offsetX {number} - The `offsetX` of the filter
* @param offsetY {number} - The `offsetY` of the filter
*/
setShadow(color: string, blur?: number, offsetX?: number, offsetY?: number): this;
/**
* @description Matrix of the layer in the 2D plane.
* @param matrix {DOMMatrix2DInit} - The `matrix` of the layer
*/
setMatrix(matrix: DOMMatrix2DInit): this;
/**
* @description Scale of the layer in the x and y direction by the given amount from their current position.
* @param x {number} - The `x` scale of the layer
* @param y {number} - The `y` scale of the layer
*/
setScale(x: number, y: number): this;
/**
* @description Rotate of the layer in the clockwise direction by the given amount from its current position.
* @param rotate {number} - The `rotate` of the layer
*/
setRotate(rotate: number): this;
/**
* @description Translate of the layer in the x and y direction by the given amount from their current position.
* @param x {number} - The `x` translation of the layer
* @param y {number} - The `y` translation of the layer
*/
setTranslate(x: number, y: number): this;
/**
* @description The **`CanvasRenderingContext2D`**. filter property of the Canvas 2D API provides filter effects such as blurring and grayscaling.
* It is similar to the CSS [`filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/filter) property and accepts the same values.
* @param filter {string} - The `filter` of the layer. Multiple filters are supported.
*/
setFilters(...filter: string[]): this;
/**
* @description Sets type of centring of the layer.
* @param centring {AnyCentring} - The `centring` of the layer
*/
setCentring(centring: AnyCentring): this;
/**
* @description Sets the visibility of the layer.
* @param visible {boolean} - The `visibility` of the layer
*/
setVisible(visible: boolean): this;
/**
* @description Sets zIndex of the layer.
* @param zIndex {number} - The `zIndex` of the layer
*/
setZIndex(zIndex: number): this;
/**
* @description Sets global composite operation of the layer.
* @param operation {AnyGlobalCompositeOperation} - The `operation` of the layer
*/
setGlobalCompositeOperation(operation: AnyGlobalCompositeOperation): this;
/**
* @returns {IBaseLayer}
*/
toJSON(): IBaseLayer;
}