lottery-scratch
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

how to use

初始化

const sc = new Scratch('#div');

const el = document.getElementById('#div');
const sc = new Scratch(el);
const sc = new Scratch({
  id: '#div'
});
const el = document.getElementById('#div');
const sc = new Scratch({
  el
});
const sc = new Scratch();
sc.init('#div');
const sc = new Scratch();
const el = document.getElementById('#div');
sc.init(el);
const sc = new Scratch();
sc.init({
  id: '#div'
});
const sc = new Scratch();
const el = document.getElementById('#div');
sc.init({
  el
});

配置项

interface ScratchConfig {
  /** 刮线的宽度,默认40 */
  lineWidth?: number;
  /** 全显阈值 0 ~ 1,默认0.3 */
  threshold?: number;
  /** 遮罩层颜色,默认#ccc */
  fillStyle?: string;
}

有两种方法改变配置项:1、在初始化时将配置项传入;2、调用setConfig方法设置配置项 注意:在初始化之后,,改变fillStyle不会立即改变遮罩层颜色,想要更新需要重新调用drawMask方法;

drawMask 和 clearMask

drawMask:画出遮罩层;

clearMask:清除遮罩层;

Package Sidebar

Install

npm i lottery-scratch

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

21.2 kB

Total Files

6

Last publish

Collaborators

  • frontlich