@nmmty/lazycanvas
Version:
A simple way to interact with @napi-rs/canvas in an advanced way!
29 lines (28 loc) • 1.05 kB
TypeScript
import { IGradient, GradientPoint, GradientColorStop, AnyGradientType } from "../../types";
import { SKRSContext2D } from "@napi-rs/canvas";
export declare class Gradient implements IGradient {
type: AnyGradientType;
points: Array<GradientPoint>;
stops: Array<GradientColorStop>;
constructor();
/**
* Set the type of the gradient
* @param type {AnyGradientType} - The `type` of the gradient. Can be `linear`, `radial`, or `conic`
*/
setType(type: AnyGradientType): this;
/**
* Add a point to the gradient
* @param points {GradientPoint[]} - The `points` to add to the gradient. `{ x: number, y: number }`
*/
addPoints(...points: GradientPoint[]): this;
/**
* Add a stop to the gradient
* @param stops {GradientColorStop[]} - The `stops` to add to the gradient. `{ color: string, position: number }`
*/
addStops(...stops: GradientColorStop[]): this;
draw(ctx: SKRSContext2D): CanvasGradient;
/**
* @returns {IGradient}
*/
toJSON(): IGradient;
}