create-puzzle
Version:
在浏览器端生成滑块验证码的拼图和背景图。
28 lines (27 loc) • 728 B
TypeScript
export declare enum Point {
None = 0,// 没有
Outer = 1,// 外部
Inner = 2
}
export declare const pointArray: Point[];
export declare function getRandomPoints(pointNum?: 2 | 3 | 4): {
top: Point;
right: Point;
bottom: Point;
left: Point;
};
export declare function drawPuzzle(ctx: CanvasRenderingContext2D, options?: {
x?: number;
y?: number;
w?: number;
h?: number;
points?: 2 | 3 | 4 | {
top: Point;
right: Point;
bottom: Point;
left: Point;
};
margin?: number;
needClosePath?: boolean;
}): void;
export declare function canvasToImage(canvas: HTMLCanvasElement, formatBlob: boolean, type: string, quality: number): Promise<string>;