-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
64 lines (64 loc) · 1.93 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
export interface ScratchConfig {
/** 刮线的宽度,默认40 */
lineWidth?: number;
/** 全显阈值 0 ~ 1,默认0.3 */
threshold?: number;
/** 遮罩层颜色,默认#ccc */
fillStyle?: string;
}
export interface ScratchConfigWidthDOM extends ScratchConfig {
/** dom的id */
id?: string;
/** dom元素 */
el?: HTMLElement;
}
export declare class Scratch {
private _config;
private _canvas;
private _ctx;
private _rect;
private _startPoint;
private _isFirstStart;
private readonly _isMobile;
readonly context: CanvasRenderingContext2D;
onScrachEnd: Function;
onScrachStart: Function;
constructor(id?: string, config?: ScratchConfig, autoDraw?: boolean);
constructor(el?: HTMLElement, config?: ScratchConfig);
constructor(config?: ScratchConfigWidthDOM);
private _init;
/**
* 初始化
* @param id DOM的id
* @param config 配置项
* @param autoDraw 是否自动画出遮罩层,默认是
*/
init(id: string, config?: ScratchConfig, autoDraw?: boolean): Scratch;
/**
* 初始化
* @param el DOM元素
* @param config 配置项
* @param autoDraw 是否自动画出遮罩层,默认是
*/
init(el: HTMLElement, config?: ScratchConfig, autoDraw?: boolean): Scratch;
/**
* 初始化
* @param config 配置项
* @param autoDraw 是否自动画出遮罩层,默认是
*/
init(config: ScratchConfigWidthDOM, autoDraw?: boolean): Scratch;
setConfig(name: 'lineWidth' | 'threshold' | 'fillStyle', value: number | string): void;
setConfig(config: ScratchConfig): void;
/**
* 画遮罩层
* @param fillStyle 填充颜色
*/
drawMask(fillStyle?: string | CanvasGradient | CanvasPattern): this;
private _loadEvent;
private _unLoadEvent;
private drawLine;
private touchStart;
private touchMove;
private touchEnd;
clearMask(): void;
}