Full Code of buuing/lucky-canvas for AI

master da677e362e27 cached
186 files
2.1 MB
561.0k tokens
477 symbols
1 requests
Download .txt
Showing preview only (2,240K chars total). Download the full file or copy to clipboard to get everything.
Repository: buuing/lucky-canvas
Branch: master
Commit: da677e362e27
Files: 186
Total size: 2.1 MB

Directory structure:
gitextract_o394m47x/

├── .github/
│   └── ISSUE_TEMPLATE.md
├── .gitignore
├── LICENSE
├── README.md
├── lerna.json
├── package.json
└── packages/
    ├── core/
    │   ├── .babelrc
    │   ├── .eslintrc.js
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── examples/
    │   │   ├── grid.html
    │   │   ├── index.html
    │   │   ├── slot.html
    │   │   └── wheel.html
    │   ├── index.js
    │   ├── package.json
    │   ├── postinstall.js
    │   ├── rollup.config.build.js
    │   ├── rollup.config.dev.js
    │   ├── src/
    │   │   ├── index.ts
    │   │   ├── lib/
    │   │   │   ├── grid.ts
    │   │   │   ├── lucky.ts
    │   │   │   ├── slot.ts
    │   │   │   └── wheel.ts
    │   │   ├── observer/
    │   │   │   ├── array.ts
    │   │   │   ├── dep.ts
    │   │   │   ├── index.ts
    │   │   │   ├── utils.ts
    │   │   │   └── watcher.ts
    │   │   ├── types/
    │   │   │   ├── grid.ts
    │   │   │   ├── index.ts
    │   │   │   ├── slot.ts
    │   │   │   └── wheel.ts
    │   │   └── utils/
    │   │       ├── image.ts
    │   │       ├── index.ts
    │   │       ├── math.ts
    │   │       ├── polyfill.js
    │   │       └── tween.ts
    │   ├── tsconfig.json
    │   └── types/
    │       └── index.d.ts
    ├── mini/
    │   ├── .babelrc
    │   ├── .eslintrc.js
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── gulpfile.js
    │   ├── package.json
    │   ├── src/
    │   │   ├── lucky-grid/
    │   │   │   ├── index.js
    │   │   │   ├── index.json
    │   │   │   ├── index.wxml
    │   │   │   └── index.wxss
    │   │   ├── lucky-wheel/
    │   │   │   ├── index.js
    │   │   │   ├── index.json
    │   │   │   ├── index.wxml
    │   │   │   └── index.wxss
    │   │   ├── slot-machine/
    │   │   │   ├── index.js
    │   │   │   ├── index.json
    │   │   │   ├── index.wxml
    │   │   │   └── index.wxss
    │   │   └── utils.js
    │   ├── test/
    │   │   ├── index.test.js
    │   │   ├── utils.js
    │   │   └── wx.test.js
    │   ├── tools/
    │   │   ├── build.js
    │   │   ├── checkcomponents.js
    │   │   ├── checkwxss.js
    │   │   ├── config.js
    │   │   ├── demo/
    │   │   │   ├── app.js
    │   │   │   ├── app.json
    │   │   │   ├── app.wxss
    │   │   │   ├── package.json
    │   │   │   ├── pages/
    │   │   │   │   ├── cjl/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── index/
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── jd/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── slot/
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── xc/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── xdf/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── ymc/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── yx/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── yyjk/
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   └── yyx/
    │   │   │   │       ├── img.js
    │   │   │   │       ├── index.js
    │   │   │   │       ├── index.json
    │   │   │   │       ├── index.wxml
    │   │   │   │       └── index.wxss
    │   │   │   └── project.config.json
    │   │   └── utils.js
    │   └── tsconfig.json
    ├── react/
    │   ├── .babelrc
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── example/
    │   │   ├── react16.8.html
    │   │   └── react18.0.html
    │   ├── package.json
    │   ├── rollup.config.build.js
    │   ├── rollup.config.dev.js
    │   └── src/
    │       ├── app.js
    │       ├── components/
    │       │   ├── LuckyGrid.js
    │       │   ├── LuckyWheel.js
    │       │   └── SlotMachine.js
    │       ├── demo/
    │       │   ├── LuckyGrid.js
    │       │   ├── LuckyWheel.js
    │       │   └── SlotMachine.js
    │       └── index.js
    ├── taro/
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── package.json
    │   ├── react/
    │   │   ├── LuckyGrid.js
    │   │   ├── LuckyWheel.js
    │   │   ├── SlotMachine.js
    │   │   └── index.js
    │   ├── utils/
    │   │   ├── index.css
    │   │   └── index.js
    │   └── vue/
    │       ├── LuckyGrid.vue
    │       ├── LuckyWheel.vue
    │       ├── SlotMachine.vue
    │       └── index.js
    ├── uni/
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── lucky-grid.vue
    │   ├── lucky-wheel.vue
    │   ├── package.json
    │   ├── slot-machine.vue
    │   └── utils.js
    └── vue/
        ├── .gitignore
        ├── .npmignore
        ├── LICENSE
        ├── README.md
        ├── composition-api.js
        ├── index.js
        ├── package.json
        ├── rollup.config.build.js
        ├── rollup.config.dev.js
        ├── shims-vue.d.ts
        ├── src/
        │   ├── components/
        │   │   ├── LuckyGrid.ts
        │   │   ├── LuckyWheel.ts
        │   │   └── SlotMachine.ts
        │   ├── index.ts
        │   └── utils/
        │       └── h-demi.ts
        ├── tsconfig.json
        ├── types/
        │   └── index.d.ts
        ├── vue-demi.js
        ├── vue2.html
        └── vue3.html

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================

<!-- 

提问前必看! 提问前必看! 提问前必看!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
https://github.com/buuing/lucky-canvas/issues/177

-->

<!-- vue / react / electron / uniapp / taro / 原生微信小程序 / 普通html页面 -->
- 你当前是什么框架(必填):

<!-- 不要当这个是重复问题, 也有人在uniapp里使用原生微信小程序的包, 魔改我的代码 -->
- 你使用的是哪个包(必填):

<!-- 如果你是通过npm安装的,那你可以在根目录下的 package.json 文件中查看插件的版本情况 -->
- 你当前插件的版本(必填):

<!-- uni-app 和 taro 顺便提供一下 -->
- 当前环境是小程序还是浏览器(选填):

<!-- 你的bug在什么情况下可以复现? bug具体的表现形式, 或者是截图 -->
- 详细描述你的bug:

<!-- 如果你能复现一个小demo压缩一下发给我, 就更完美了, 我会极快的定位问题并修复 -->
- 问题代码(重要):

<!-- 看到下面的三个小点了吗, 那个叫做代码块, 总有人把代码放在外面... 我都无语了 -->
```
// 代码开始, 别再放歪了行吗

// 代码结束
```


================================================
FILE: .gitignore
================================================
.DS_Store
node_modules
yarn.lock
package-lock.json

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

packages/demo-taro-vue
packages/demo-taro-react
packages/uni-app-demo

================================================
FILE: LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [2021] [Li Dong Qi]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================

<div align="center">
  <img src="https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.png" width="128" alt="logo" />
  <h1>lucky-canvas 抽奖插件</h1>
  <p>一个基于 JavaScript 的跨平台 ( 大转盘 / 九宫格 / 老虎机 ) 抽奖插件</p>
  <p>
    <a href="https://github.com/buuing/lucky-canvas/stargazers" target="_black">
      <img src="https://img.shields.io/github/stars/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="stars" />
    </a>
    <a href="https://github.com/buuing/lucky-canvas/network/members" target="_black">
      <img src="https://img.shields.io/github/forks/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="forks" />
    </a>
    <a href="https://github.com/buuing" target="_black">
      <img src="https://img.shields.io/badge/Author-%20buuing%20-7289da.svg?&logo=github&style=flat-square" alt="author" />
    </a>
    <a href="https://github.com/buuing/lucky-canvas/blob/master/LICENSE" target="_black">
      <img src="https://img.shields.io/github/license/buuing/lucky-canvas?color=%232dce89&logo=github&style=flat-square" alt="license" />
    </a>
    <a href="https://www.jsdelivr.com/package/npm/lucky-canvas" target="_black">
      <img src="https://data.jsdelivr.com/v1/package/npm/lucky-canvas/badge" alt="downloads" />
    </a>
  </p>
</div>

<div align="center">

|适配框架|npm包|最新版本|npm下载量|
| :-: | :-: | :-: | :-: |
|`JS` / `JQ`|[lucky-canvas](https://100px.net/usage/js.html)|<img src="https://img.shields.io/npm/v/lucky-canvas?color=%23ffba15&logo=npm&style=flat-square" alt="version" />|<a href="https://www.npmjs.com/package/lucky-canvas" target="_black"><img src="https://img.shields.io/npm/dm/lucky-canvas?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|
|`Vue`|[@lucky-canvas/vue](https://100px.net/usage/vue.html)|<img src="https://img.shields.io/npm/v/@lucky-canvas/vue?color=%23ffba15&logo=npm&style=flat-square" alt="version" />|<a href="https://www.npmjs.com/package/@lucky-canvas/vue" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/vue?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|<a href="https://www.jsdelivr.com/package/npm/@lucky-canvas/vue" target="_black"><img src="https://data.jsdelivr.com/v1/package/npm/@lucky-canvas/vue/badge" alt="downloads" /></a>|
|`React`|[@lucky-canvas/react](https://100px.net/usage/react.html)|<img src="https://img.shields.io/npm/v/@lucky-canvas/react?color=%23ffba15&logo=npm&style=flat-square" alt="version" />|<a href="https://www.npmjs.com/package/@lucky-canvas/react" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/react?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|-|
|`UniApp`|[@lucky-canvas/uni](https://100px.net/usage/uni.html)|<img src="https://img.shields.io/npm/v/@lucky-canvas/uni?color=%23ffba15&logo=npm&style=flat-square" alt="version" />|<a href="https://www.npmjs.com/package/@lucky-canvas/uni" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/uni?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|-|
|`Taro3.x`|[@lucky-canvas/taro](https://100px.net/usage/taro.html)|<img src="https://img.shields.io/npm/v/@lucky-canvas/taro?color=%23ffba15&logo=npm&style=flat-square" alt="version" />|<a href="https://www.npmjs.com/package/@lucky-canvas/taro" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/taro?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|-|
|`微信小程序`|[@lucky-canvas/mini](https://100px.net/usage/wx.html)|<img src="https://img.shields.io/npm/v/@lucky-canvas/mini?color=%23ffba15&logo=npm&style=flat-square" alt="version" />|<a href="https://www.npmjs.com/package/@lucky-canvas/mini" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/mini?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|-|

</div>

<br />

## 官方文档 & Demo演示

> **中文**:[https://100px.net](https://100px.net)

> **English**:**If anyone can help translate the document, please contact me** `ldq404@qq.com`
  
<br />

## 贡献者

<table align="center">
  <tr>
    <td align="center"><a href="https://github.com/buuing" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/36689704?v=4"></a><div><span title="核心开发">🤖</span> <span title="基础建设">🛰</span> <span title="维护文档">📚</span></div></td>
    <td align="center"><a href="https://github.com/httpcheck" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/26322785?v=4"></a><div><span title="逻辑优化">🦄</span></div></td>
    <td align="center"><a href="https://github.com/Xutaotaotao" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/24652625?v=4"></a><div><span title="基础建设">🛰</span></div></td>
    <td align="center"><a href="https://github.com/yushen7" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/35678187?v=4"></a><div><span title="基础建设">🛰</span></div></td>
    <td align="center"><a href="https://github.com/qingtiantongxie" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/24731632?v=4"></a><div><span title="基础建设">🛰</span></div></td>
    <td align="center"><a href="https://github.com/Deja-vuuu" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/27748682?v=4"></a><div><span title="基础建设">🛰</span></div></td>
    <td align="center"><a href="https://github.com/shenyixuanV1" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/52775847?v=4"></a><div><span title="修复bug">🛠</span> <span title="贡献Demo">🎨</span></div></td>
    <td align="center"><a href="https://github.com/health901" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/1503105?v=4"></a><div><span title="修复bug">🛠</span></div></td>
    <td align="center"><a href="https://github.com/fantacytyx" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/8966236?v=4"></a><div><span title="修复bug">🛠</span></div></td>
    <td align="center"><a href="https://github.com/wfs498121294" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/12890610?v=4"></a><div><span title="修复bug">🛠</span></div></td>
  <tr>
  </tr>
    <td align="center"><a href="https://github.com/Eaoncan" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/70514533?v=4"></a><div><span title="修复bug">🛠</span></div></td>
    <td align="center"><a href="https://github.com/Haoz03" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/18543217?v=4"></a><div><span title="修复bug">🛠</span></div></td>
    <td align="center"><a href="https://github.com/theozhang32" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/92575976?v=4"></a><div><span title="修复bug">🛠</span></div></td>
    <td align="center"><a href="https://github.com/pointline" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/26851754?v=4"></a><div><span title="修复bug">🛠</span></div></td>
    <td align="center"><a href="https://github.com/saltedfishDing" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/26900681?v=4"></a><div><span title="维护文档">📚</span></div></td>
    <td align="center"><a href="https://github.com/igxm" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/32808955?v=4"></a><div><span title="维护文档">📚</span></div></td>
    <td align="center"><a href="https://github.com/nanjing910823" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/18729086?v=4"></a><div><span title="贡献Demo">🎨</span></div></td>
    <td align="center"><a href="https://github.com/fatcat712" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/60590060?v=4"></a><div><span title="贡献Demo">🎨</span></div></td>
    <td align="center"><a href="https://github.com/FlowerFestival" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/23180446?v=4"></a><div><span title="贡献Demo">🎨</span></div></td>
    <td align="center"><a href="https://github.com/yang302" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/20217508?v=4"></a><div><span title="贡献Demo">🎨</span></div></td>
  </tr>
  <tr>
    <td align="center"><a href="https://github.com/ywymoshi" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/46644748?v=4"></a><div><span title="贡献Demo">🎨</span></div></td>
    <td align="center"><a href="https://github.com/yyy917172" target="_blank"><img width="50px" src="https://avatars.githubusercontent.com/u/37855143?v=4"></a><div><span title="基础建设">🛰</span></div></td>
  </tr>
</table>

<br />

## 🙏🙏🙏 点个Star

**如果您觉得这个项目还不错, 可以在 [Github](https://github.com/buuing/lucky-canvas) 上面帮我点个`star`, 支持一下作者 ☜(゚ヮ゚☜)**

<br />

## 问题反馈

<img align="left" width="180" src="https://unpkg.com/buuing@0.0.2/imgs/pay.png" />

- Bug 反馈请直接去 Github 上面提 Issues,我会实时收到邮件提醒前去查看
- **如果是小白需要技术指导的话, 左边是我的赞赏码, 备注好你的微信号, 我看到后会主动加你**
- 但如果是因为我文档没写清楚,或者是插件本身的bug,导致你无法正常使用的话,赞赏全额返还

> **`注好你的微信号!`** **`微信看不到赞赏人信息`** **`所以你必须在备注里写上`**

<br />
<br />

## 友情链接

- [🎁 h5-Dooring 一款功能强大,高可扩展的H5可视化编辑器](https://github.com/MrXujiang/h5-Dooring)
- [🎁 right-menu 功能强大的右键菜单插件, 支持 JS / TS / Vue / React 等多端框架](https://github.com/buuing/right-menu)


<!-- lerna过滤器配置 -->
<!-- https://github.com/lerna/lerna/tree/main/core/filter-options#readme -->


================================================
FILE: lerna.json
================================================
{
  "packages": [
    "packages/*"
  ],
  "version": "0.0.4",
  "npmClient": "npm",
  "useWorkspaces": true
}

================================================
FILE: package.json
================================================
{
  "name": "lucky-canvas",
  "devDependencies": {
    "lerna": "^4.0.0"
  },
  "scripts": {
    "install": "lerna bootstrap",
    "dev": "lerna exec --scope=lucky-canvas -- npm run dev",
    "dev:vue": "lerna run --scope=lucky-canvas --scope=@lucky-canvas/vue dev --parallel",
    "dev:react": "lerna run --scope=lucky-canvas --scope=@lucky-canvas/react dev --parallel",
    "dev:uni": "",
    "dev:taro": "",
    "dev:mini": "",
    "build": "lerna run build --sort --stream",
    "update-version": "lerna version --conventional-commits --no-push --no-changelog --no-git-tag-version",
    "publish-to-npm": "lerna publish from-package",
    "publish-beta": "lerna publish --no-git-tag-version --dist-tag beta"
  },
  "private": true,
  "workspaces": [
    "packages/*"
  ]
}


================================================
FILE: packages/core/.babelrc
================================================
{
  "presets": [
    [
      "@babel/preset-env", {
        "modules": false
      }
    ]
  ]
}

================================================
FILE: packages/core/.eslintrc.js
================================================
// module.exports = {
//   "env": {
//     "browser": true,
//     "es6": true,
//     "node": true
//   },
//   "parser": "@typescript-eslint/parser",
//   // "plugins": ['prettier'],
//   "extends": "eslint:recommended",
//   "globals": {
//     "Atomics": "readonly",
//     "SharedArrayBuffer": "readonly",
//     "ENV": true
//   },
//   "parserOptions": {
//     "ecmaVersion": 2018,
//     "sourceType": "module"
//   },
//   "rules": {
//     "linebreak-style": 'off'
//   }
// }


================================================
FILE: packages/core/.gitignore
================================================
.DS_Store
node_modules
yarn.lock
package-lock.json
dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?


================================================
FILE: packages/core/.npmignore
================================================
*

================================================
FILE: packages/core/LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [2021] [Li Dong Qi]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: packages/core/README.md
================================================


<div align="center">
  <img src="https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.png" width="128" alt="logo" />
  <h1>lucky-canvas 抽奖插件</h1>
  <p>一个基于 JavaScript 的跨平台 ( 大转盘 / 九宫格 / 老虎机 ) 抽奖插件</p>
  <p>
    <a href="https://github.com/buuing/lucky-canvas/stargazers" target="_black">
      <img src="https://img.shields.io/github/stars/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="stars" />
    </a>
    <a href="https://github.com/buuing/lucky-canvas/network/members" target="_black">
      <img src="https://img.shields.io/github/forks/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="forks" />
    </a>
    <a href="https://github.com/buuing" target="_black">
      <img src="https://img.shields.io/badge/Author-%20buuing%20-7289da.svg?&logo=github&style=flat-square" alt="author" />
    </a>
    <a href="https://github.com/buuing/lucky-canvas/blob/master/LICENSE" target="_black">
      <img src="https://img.shields.io/github/license/buuing/lucky-canvas?color=%232dce89&logo=github&style=flat-square" alt="license" />
    </a>
  </p>
</div>

<br />

## 官方文档 & Demo演示

> **中文**:[https://100px.net/usage/js.html](https://100px.net/usage/js.html)  

> **English**:**If anyone can help translate the document, please contact me** `ldq404@qq.com`


<br />

## 在 JS / TS 中使用

- [跳转官网 查看详情](https://100px.net/usage/js.html)

<br />

## 🙏🙏🙏 点个Star

**如果您觉得这个项目还不错, 可以在 [Github](https://github.com/buuing/lucky-canvas) 上面帮我点个`star`, 支持一下作者 ☜(゚ヮ゚☜)**


================================================
FILE: packages/core/examples/grid.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="my-lucky"></div>
  <button onclick="myLucky.play()">play()</button>
  <button onclick="myLucky.stop(0)">stop(0)</button>
  <button onclick="myLucky.stop(1)">stop(1)</button>
  <button onclick="myLucky.stop(2)">stop(2)</button>
  <button onclick="myLucky.stop(-1)">stop(-1)</button>
  <button onclick="myLucky.init()">init()</button>
  <script src="../dist/index.umd.js"></script>
    <script>
      const myLucky = new LuckyCanvas.LuckyGrid('#my-lucky', {
        width: '200px',
        height: '200px',
        rows: 4,
        cols: 4,
        blocks: [
          { padding: '1rem 2px', background: 'red' }
        ],
        prizes: [
          { x: 0, y: 0 },
          { x: 1, y: 0 },
          { x: 2, y: 0 },
          { x: 3, y: 0 },
          { x: 3, y: 1 },
          { x: 3, y: 2 },
          { x: 3, y: 3 },
          { x: 2, y: 3 },
          { x: 1, y: 3 },
          { x: 0, y: 3 },
          { x: 0, y: 2 },
          { x: 0, y: 1 },
        ],
        buttons: [
          {
            x: 1, y: 1,
            row: 2, col: 2,
          },
        ],
        defaultStyle: {
          background: '#f4f5f5'
        }
      })
  </script>
</body>
</html>


================================================
FILE: packages/core/examples/index.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1><a href="https://100px.net">官网文档: 100px.net</a></h1>
  大转盘示例
  <ul>
    <li><a href="./wheel.html">大转盘</a></li>
  </ul>
  九宫格示例
  <ul>
    <li><a href="./grid.html">九宫格</a></li>
  </ul>
  老虎机示例
  <ul>
    <li><a href="./slot.html">老虎机</a></li>
  </ul>
</body>
</html>


================================================
FILE: packages/core/examples/slot.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body style="background: #000;">
  <div id="my-lucky"></div>
  <button onclick="myLucky.play()">play()</button>
  <button onclick="myLucky.stop(0)">stop(0)</button>
  <button onclick="myLucky.stop(1)">stop(1)</button>
  <button onclick="myLucky.stop(2)">stop(2)</button>
  <button onclick="myLucky.stop(-1)">stop(-1)</button>
  <button onclick="myLucky.init()">init()</button>
  <hr>
  <canvas id="off" style="border: 2px solid red;"></canvas>
  <script src="../dist/index.umd.js"></script>
  <!-- <script src="https://unpkg.com/lucky-canvas@1.7.23"></script> -->
  <script>
    const myLucky = new LuckyCanvas.SlotMachine('#my-lucky', {
      width: '240px',
      height: '180px',
      blocks: [
        { padding: '10px', background: '#869cfa' },
        { padding: '10px', background: '#e9e8fe' },
      ],
      slots: [
        { speed: 1 },
        { speed: 4 },
        { speed: 20 },
      ],
      prizes: [
        {
          background: '#bac5ee',
          borderRadius: '10px',
          imgs: [{
            width: '60%',
            top: '20%',
            src: 'https://unpkg.com/buuing@0.0.1/demo/prize.png'
          }]
        },
        {
          background: '#bac5ee',
          borderRadius: '10px',
          imgs: [{
            width: '60%',
            top: '20%',
            src: 'https://unpkg.com/buuing@0.0.1/demo/active.png'
          }]
        },
      ],
      defaultConfig: {
        rowSpacing: '10px',
        colSpacing: '10px'
      }
    })
    const canvas = document.querySelector('#off')
    const ctx = canvas.getContext('2d')
    canvas.style['transform-origin'] = 'left top'
    canvas.style.transform = `scale(${1 / myLucky.config.dpr})`
    setTimeout(_ => {
      canvas.width = myLucky._offscreenCanvas.width
      canvas.height = myLucky._offscreenCanvas.height
      ctx.drawImage(myLucky._offscreenCanvas, 0, 0)
    }, 500)
  </script>
</body>
</html>


================================================
FILE: packages/core/examples/wheel.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body style="opacity: 1;">
  <body>
    <!-- <script>
      var documentElement = document.documentElement;
      function callback() {
        var clientWidth = documentElement.clientWidth;
        // 屏幕宽度大于780,不在放大
        clientWidth = clientWidth < 780 ? clientWidth : 780;
        documentElement.style.fontSize = clientWidth / 10 + 'px';
      }
      document.addEventListener('DOMContentLoaded', callback);
      window.addEventListener('orientationchange' in window ? 'orientationchange' : 'resize', callback);
    </script> -->
    <div id="my-lucky"></div>
    <br />
    <button onclick="myLucky.play()">play()</button>
    <button onclick="myLucky.stop(0)">stop(0)</button>
    <button onclick="myLucky.stop(1)">stop(1)</button>
    <button onclick="myLucky.stop(-1)">stop(-1)</button>
    <button onclick="myLucky.init()">init()</button>
    <br />
    <button onclick="test1()">test1()</button>
    <script src="../dist/index.umd.js"></script>
    <script>
      function test1() {
        myLucky.defaultStyle.background = '#ddd'
      }
      const myLucky = new LuckyCanvas.LuckyWheel('#my-lucky', {
        width: '200px',
        height: '200px',
        blocks: [{ padding: '1px', background: '#ccc' }],
        prizes: [
          { fonts: [{ text: '0', top: '0%', left: '49%' }],  },
          { fonts: [{ text: '1', top: '10%' }] },
          { fonts: [{ text: '2', top: '10%' }] },
          { fonts: [{ text: '3', top: '10%' }] },
          { fonts: [{ text: '4', top: '10%' }] },
          { fonts: [{ text: '5', top: '10%' }] },
        ],
        buttons: [
          { radius: '50%', background: '#fff' },
        ],
        defaultStyle: {
          background: '#fff'
        },
        defaultConfig: {
          gutter: 1
        },
        start () {
          myLucky.play()
          setTimeout(() => {
          myLucky.stop(0)
          })
        }
      })
    </script>
  </body>
</body>
</html>


================================================
FILE: packages/core/index.js
================================================
module.exports = require('./dist/index.umd.js')


================================================
FILE: packages/core/package.json
================================================
{
  "name": "lucky-canvas",
  "version": "1.7.26",
  "description": "一个基于原生 js 的(大转盘 / 九宫格 / 老虎机)抽奖插件",
  "main": "dist/index.cjs.js",
  "module": "dist/index.esm.js",
  "unpkg": "dist/index.umd.js",
  "jsdelivr": "dist/index.umd.js",
  "types": "types/index.d.ts",
  "scripts": {
    "dev": "rollup --config rollup.config.dev.js -w",
    "build": "rollup --config rollup.config.build.js"
  },
  "homepage": "https://100px.net",
  "bugs": "https://github.com/LuckDraw/lucky-canvas/issues",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/LuckDraw/lucky-canvas.git",
    "directory": "packages/lucky-canvas"
  },
  "author": "ldq <ldq404@qq.com>",
  "license": "Apache-2.0",
  "files": [
    "dist",
    "types",
    "index.js"
  ],
  "keywords": [
    "大转盘抽奖",
    "九宫格抽奖",
    "老虎机抽奖",
    "抽奖插件",
    "js抽奖",
    "移动端抽奖",
    "canvas抽奖"
  ],
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@babel/preset-env": "^7.12.1",
    "@babel/plugin-transform-runtime": "^7.16.4",
    "@babel/runtime": "^7.16.3",
    "core-js": "^3.19.2",
    "@rollup/plugin-commonjs": "^16.0.0",
    "@rollup/plugin-eslint": "^8.0.1",
    "@rollup/plugin-json": "^4.1.0",
    "@rollup/plugin-node-resolve": "^10.0.0",
    "@rollup/plugin-typescript": "^6.1.0",
    "@typescript-eslint/parser": "^4.14.0",
    "babel-plugin-external-helpers": "^6.22.0",
    "babel-preset-latest": "^6.24.1",
    "eslint": "^7.18.0",
    "eslint-plugin-prettier": "^3.3.1",
    "prettier": "^2.2.1",
    "rollup": "^2.33.1",
    "rollup-plugin-babel": "^4.4.0",
    "rollup-plugin-livereload": "^2.0.0",
    "rollup-plugin-serve": "^1.1.0",
    "rollup-plugin-terser": "^7.0.2",
    "rollup-plugin-delete": "^2.0.0",
    "rollup-plugin-dts": "^3.0.2",
    "rollup-plugin-typescript2": "^0.30.0",
    "tslib": "^2.3.1",
    "typescript": "^4.0.5"
  },
  "dependencies": {}
}


================================================
FILE: packages/core/postinstall.js
================================================
console.log(`  \u001B[93m╭────────────────────────────────────────────────────╮\u001b[0m
  \u001B[93m│\u001b[0m                                                    \u001B[93m│\u001b[0m
  \u001B[93m│\u001b[0m           \u001B[97m欢迎使用\u001B[0m \u001B[46mlucky-canvas\u001B[0m \u001B[97m抽奖插件\u001B[0m           \u001B[93m│\u001b[0m
  \u001B[93m│\u001b[0m            \u001B[96m官网文档: https://100px.net\u001B[0m             \u001B[93m│\u001b[0m
  \u001B[93m│\u001b[0m                                                    \u001B[93m│\u001b[0m
  \u001B[93m│\u001b[0m        \u001B[93m如果您用着顺手可以点个 Star 支持一下\u001B[0m        \u001B[93m│\u001b[0m
  \u001B[93m│\u001b[0m  \u001B[96mGitHub: https://github.com/LuckDraw/lucky-canvas\u001b[0m  \u001B[93m│\u001b[0m
  \u001B[93m│\u001b[0m                                                    \u001B[93m│\u001b[0m
  \u001B[93m╰────────────────────────────────────────────────────╯\u001b[0m`)


================================================
FILE: packages/core/rollup.config.build.js
================================================
import path from 'path'
import ts from 'rollup-plugin-typescript2'
import dts from 'rollup-plugin-dts'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from 'rollup-plugin-babel'
import { terser } from 'rollup-plugin-terser'
import del from 'rollup-plugin-delete'
import pkg from './package.json'

export default [
  {
    input: 'src/index.ts',
    output: [
      {
        file: pkg.main,
        format: 'cjs',
        sourcemap: true,
      },
      {
        file: pkg.module,
        format: 'esm',
        sourcemap: true,
      },
      {
        file: pkg.jsdelivr,
        format: 'umd',
        name: 'LuckyCanvas',
        sourcemap: false,
      },
    ],
    plugins: [
      ts({
        tsconfig: path.resolve(__dirname, './tsconfig.json'),
        extensions: ['.js', '.ts'],
        "declaration": true,
      }),
      json(),
      resolve(),
      commonjs(),
      babel({
        runtimeHelpers: true,
        exclude: 'node_modules/**',
      }),
      terser()
    ]
  }, {
    input: "dist/src/index.d.ts",
    output: [
      {
        file: "types/index.d.ts",
        format: "es"
      }
    ],
    plugins: [
      dts(),
      del({
        targets: ['dist/src'],
        hook: 'buildEnd'
      })
    ],
  },
]


================================================
FILE: packages/core/rollup.config.dev.js
================================================
import path from 'path'
import ts from 'rollup-plugin-typescript2'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from 'rollup-plugin-babel'
import livereload from 'rollup-plugin-livereload'
import serve from 'rollup-plugin-serve'
// import eslint from '@rollup/plugin-eslint'
import pkg from './package.json'

export default {
  input: 'src/index.ts',
  output: [
    {
      file: pkg.jsdelivr,
      format: 'umd',
      name: 'LuckyCanvas',
      sourcemap: true,
    },
    {
      file: pkg.module,
      format: 'es',
      sourcemap: true,
    },
  ],
  plugins: [
    resolve(),
    commonjs(),
    json(),
    // eslint({
    //   throwOnError: true,
    //   throwOnWarning: true,
    //   include: ['src/**'],
    //   exclude: ['node_modules/**']
    // }),
    ts({
      tsconfig: path.resolve(__dirname, './tsconfig.json'),
      extensions: ['.js', '.ts']
    }),
    babel({
      runtimeHelpers: true,
      exclude: 'node_modules/**',
    }),
    livereload(),
    serve({
      open: true,
      port: 13000,
      contentBase: './',
      openPage: '/examples/index.html'
    }),
  ]
}


================================================
FILE: packages/core/src/index.ts
================================================
export { default as LuckyWheel } from './lib/wheel'
export { default as LuckyGrid } from './lib/grid'
export { default as SlotMachine } from './lib/slot'
export { cutRound, opacity } from './utils/image'

// export type { default as LuckyWheelConfig } from './types/wheel'
// export type { default as LuckyGridConfig } from './types/grid'
// export type { default as SlotMachineConfig } from './types/slot'


================================================
FILE: packages/core/src/lib/grid.ts
================================================
import Lucky from './lucky'
import { UserConfigType, ImgType } from '../types/index'
import LuckyGridConfig, {
  BlockType,
  PrizeType,
  ButtonType,
  CellFontType,
  CellImgType,
  RowsType,
  ColsType,
  CellType,
  DefaultConfigType,
  DefaultStyleType,
  ActiveStyleType,
  StartCallbackType,
  EndCallbackType,
} from '../types/grid'
import {
  has,
  isExpectType,
  removeEnter,
  computePadding,
  hasBackground,
  computeRange,
  splitText
} from '../utils/index'
import { roundRectByArc, getLinearGradient } from '../utils/math'
import { quad } from '../utils/tween'

export default class LuckyGrid extends Lucky {
  private rows: RowsType = 3
  private cols: ColsType = 3
  private blocks: Array<BlockType> = []
  private prizes: Array<PrizeType> = []
  private buttons: Array<ButtonType> = []
  private button?: ButtonType
  private defaultConfig: DefaultConfigType = {}
  private defaultStyle: DefaultStyleType = {}
  private activeStyle: ActiveStyleType = {}
  private _defaultConfig: Required<DefaultConfigType> = {} as Required<DefaultConfigType>
  private _defaultStyle: Required<DefaultStyleType> = {} as Required<DefaultStyleType>
  private _activeStyle: Required<ActiveStyleType> = {} as Required<ActiveStyleType>
  private startCallback?: StartCallbackType
  private endCallback?: EndCallbackType
  private cellWidth = 0                 // 格子宽度
  private cellHeight = 0                // 格子高度
  private startTime = 0                 // 开始时间戳
  private endTime = 0                   // 结束时间戳
  private currIndex = 0                 // 当前index累加
  private stopIndex = 0                 // 刻舟求剑
  private endIndex = 0                  // 停止索引
  private demo = false                  // 是否自动游走
  private timer = 0                     // 游走定时器
  private FPS = 16.6                    // 屏幕刷新率
  /**
   * 游戏当前的阶段
   * step = 0 时, 游戏尚未开始
   * step = 1 时, 此时处于加速阶段
   * step = 2 时, 此时处于匀速阶段
   * step = 3 时, 此时处于减速阶段
   */
  private step: 0 | 1 | 2 | 3 = 0
  /**
   * 中奖索引
   * prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
   * prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
   * prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
   */
  private prizeFlag: number | undefined = -1
  // 所有格子
  private cells: CellType<CellFontType, CellImgType>[] = []
  // 奖品区域几何信息
  private prizeArea: { x: number, y: number, w: number, h: number } | undefined
  // 图片缓存
  private ImageCache = new Map()

  /**
   * 九宫格构造器
   * @param config 配置项
   * @param data 抽奖数据
   */
  constructor (config: UserConfigType, data: LuckyGridConfig) {
    super(config, {
      width: data.width,
      height: data.height
    })
    this.initData(data)
    this.initWatch()
    this.initComputed()
    // 创建前回调函数
    config.beforeCreate?.call(this)
    // 首次初始化
    this.init()
  }

  protected resize(): void {
    super.resize()
    this.draw()
    this.config.afterResize?.()
  }

  protected initLucky (): void {
    this.cellWidth = 0
    this.cellHeight = 0
    this.startTime = 0
    this.endTime = 0
    this.currIndex = 0
    this.stopIndex = 0
    this.endIndex = 0
    this.demo = false
    this.timer = 0
    this.FPS = 16.6
    this.prizeFlag = -1
    this.step = 0
    super.initLucky()
  }

  /**
   * 初始化数据
   * @param data
   */
  private initData (data: LuckyGridConfig): void {
    this.$set(this, 'width', data.width)
    this.$set(this, 'height', data.height)
    this.$set(this, 'rows', Number(data.rows) || 3)
    this.$set(this, 'cols', Number(data.cols) || 3)
    this.$set(this, 'blocks', data.blocks || [])
    this.$set(this, 'prizes', data.prizes || [])
    this.$set(this, 'buttons', data.buttons || [])
    // 临时过渡代码, 升级到2.x即可删除
    this.$set(this, 'button', data.button)
    this.$set(this, 'defaultConfig', data.defaultConfig || {})
    this.$set(this, 'defaultStyle', data.defaultStyle || {})
    this.$set(this, 'activeStyle', data.activeStyle || {})
    this.$set(this, 'startCallback', data.start)
    this.$set(this, 'endCallback', data.end)
  }

  /**
   * 初始化属性计算
   */
  private initComputed (): void {
    // 默认配置
    this.$computed(this, '_defaultConfig', () => {
      const config = {
        gutter: 5,
        speed: 20,
        accelerationTime: 2500,
        decelerationTime: 2500,
        ...this.defaultConfig
      }
      config.gutter = this.getLength(config.gutter)
      config.speed = config.speed / 40
      return config
    })
    // 默认样式
    this.$computed(this, '_defaultStyle', () => {
      return {
        borderRadius: 20,
        fontColor: '#000',
        fontSize: '18px',
        fontStyle: 'sans-serif',
        fontWeight: '400',
        background: 'rgba(0,0,0,0)',
        shadow: '',
        wordWrap: true,
        lengthLimit: '90%',
        ...this.defaultStyle
      }
    })
    // 中奖样式
    this.$computed(this, '_activeStyle', () => {
      return {
        background: '#ffce98',
        shadow: '',
        ...this.activeStyle
      }
    })
  }

  /**
   * 初始化观察者
   */
  private initWatch (): void {
    // 重置宽度
    this.$watch('width', (newVal: string | number) => {
      this.data.width = newVal
      this.resize()
    })
    // 重置高度
    this.$watch('height', (newVal: string | number) => {
      this.data.height = newVal
      this.resize()
    })
    // 监听 blocks 数据的变化
    this.$watch('blocks', (newData: Array<BlockType>) => {
      this.initImageCache()
    }, { deep: true })
    // 监听 prizes 数据的变化
    this.$watch('prizes', (newData: Array<PrizeType>) => {
      this.initImageCache()
    }, { deep: true })
    // 监听 button 数据的变化
    this.$watch('buttons', (newData: Array<ButtonType>) => {
      this.initImageCache()
    }, { deep: true })
    this.$watch('rows', () => this.init())
    this.$watch('cols', () => this.init())
    this.$watch('defaultConfig', () => this.draw(), { deep: true })
    this.$watch('defaultStyle', () => this.draw(), { deep: true })
    this.$watch('activeStyle', () => this.draw(), { deep: true })
    this.$watch('startCallback', () => this.init())
    this.$watch('endCallback', () => this.init())
  }

  /**
   * 初始化 canvas 抽奖
   */
  public async init (): Promise<void> {
    this.initLucky()
    const { config } = this
    // 初始化前回调函数
    config.beforeInit?.call(this)
    // 先画一次防止闪烁
    this.draw()
    // 异步加载图片
    await this.initImageCache()
    // 初始化后回调函数
    config.afterInit?.call(this)
  }

  private initImageCache (): Promise<void> {
    return new Promise((resolve) => {
      const btnImgs = this.buttons.map(btn => btn.imgs)
      if (this.button) btnImgs.push(this.button.imgs)
      const willUpdateImgs = {
        blocks: this.blocks.map(block => block.imgs),
        prizes: this.prizes.map(prize => prize.imgs),
        buttons: btnImgs,
      }
      ;(<(keyof typeof willUpdateImgs)[]>Object.keys(willUpdateImgs)).forEach(imgName => {
        const willUpdate = willUpdateImgs[imgName]
        // 循环遍历所有图片
        const allPromise: Promise<void>[] = []
        willUpdate && willUpdate.forEach((imgs, cellIndex) => {
          imgs && imgs.forEach((imgInfo, imgIndex) => {
            allPromise.push(this.loadAndCacheImg(imgName, cellIndex, imgIndex))
          })
        })
        Promise.all(allPromise).then(() => {
          this.draw()
          resolve()
        })
      })
    })
  }

  /**
   * canvas点击事件
   * @param e 事件参数
   */
  protected handleClick (e: MouseEvent): void {
    const { ctx } = this
    ;[
      ...this.buttons,
      this.button
    ].forEach(btn => {
      if (!btn) return
      const [x, y, width, height] = this.getGeometricProperty([
        btn.x, btn.y, btn.col || 1, btn.row || 1
      ])
      ctx.beginPath()
      ctx.rect(x, y, width, height)
      if (!ctx.isPointInPath(e.offsetX, e.offsetY)) return
      if (this.step !== 0) return
      // 如果btn里有单独的回调方法, 优先触发
      if (typeof btn.callback === 'function') btn.callback.call(this, btn)
      // 最后触发公共回调
      this.startCallback?.(e, btn)
    })
  }

  /**
   * 根据索引单独加载指定图片并缓存
   * @param cellName 模块名称
   * @param cellIndex 模块索引
   * @param imgName 模块对应的图片缓存
   * @param imgIndex 图片索引
   */
  private async loadAndCacheImg (
    cellName: 'blocks' | 'prizes' | 'buttons',
    cellIndex: number,
    imgIndex: number
  ): Promise<void> {
    return new Promise((resolve, reject) => {
      let cell: BlockType | PrizeType | ButtonType = this[cellName][cellIndex]
      // 临时过渡代码, 升级到2.x即可删除
      if (cellName === 'buttons' && !this.buttons.length && this.button) {
        cell = this.button
      }
      if (!cell || !cell.imgs) return
      const imgInfo = cell.imgs[imgIndex]
      if (!imgInfo) return
      // 异步加载图片
      const request = [
        this.loadImg(imgInfo.src, imgInfo),
        imgInfo['activeSrc'] && this.loadImg(imgInfo['activeSrc'], imgInfo, '$activeResolve')
      ]
      Promise.all(request).then(async ([defaultImg, activeImg]) => {
        const formatter = imgInfo.formatter
        // 对图片进行处理
        if (typeof formatter === 'function') {
          defaultImg = await Promise.resolve(formatter.call(this, defaultImg))
          if (activeImg) {
            activeImg = await Promise.resolve(formatter.call(this, activeImg))
          }
        }
        this.ImageCache.set(imgInfo['src'], defaultImg)
        activeImg && this.ImageCache.set(imgInfo['activeSrc'], activeImg)
        resolve()
      }).catch(err => {
        console.error(`${cellName}[${cellIndex}].imgs[${imgIndex}] ${err}`)
        reject()
      })
    })
  }

  /**
   * 绘制九宫格抽奖
   */
  protected draw (): void {
    const { config, ctx, _defaultConfig, _defaultStyle, _activeStyle } = this
    // 触发绘制前回调
    config.beforeDraw?.call(this, ctx)
    // 清空画布
    ctx.clearRect(0, 0, this.boxWidth, this.boxHeight)
    // 合并奖品和按钮
    this.cells = [
      ...this.prizes,
      ...this.buttons
    ]
    if (this.button) this.cells.push(this.button)
    this.cells.forEach(cell => {
      cell.col = cell.col || 1
      cell.row = cell.row || 1
    })
    // 计算获取奖品区域的几何信息
    this.prizeArea = this.blocks.reduce(({x, y, w, h}, block, blockIndex) => {
      const [paddingTop, paddingBottom, paddingLeft, paddingRight] = computePadding(block, this.getLength.bind(this))
      const r = block.borderRadius ? this.getLength(block.borderRadius) : 0
      // 绘制边框
      const background = block.background
      if (hasBackground(background)) {
        ctx.fillStyle = this.handleBackground(x, y, w, h, background!)
        roundRectByArc(ctx, x, y, w, h, r)
        ctx.fill()
      }
      // 绘制图片
      block.imgs && block.imgs.forEach((imgInfo, imgIndex) => {
        const blockImg = this.ImageCache.get(imgInfo.src)
        if (!blockImg) return
        // 绘制图片
        const [trueWidth, trueHeight] = this.computedWidthAndHeight(blockImg, imgInfo, w, h)
        const [xAxis, yAxis] = [
          this.getOffsetX(trueWidth, w) + this.getLength(imgInfo.left, w),
          this.getLength(imgInfo.top, h)
        ]
        this.drawImage(ctx, blockImg, x + xAxis, y + yAxis, trueWidth, trueHeight)
      })
      return {
        x: x + paddingLeft,
        y: y + paddingTop,
        w: w - paddingLeft - paddingRight,
        h: h - paddingTop - paddingBottom
      }
    }, { x: 0, y: 0, w: this.boxWidth, h: this.boxHeight })
    // 计算单一奖品格子的宽度和高度
    this.cellWidth = (this.prizeArea.w - _defaultConfig.gutter * (this.cols - 1)) / this.cols
    this.cellHeight = (this.prizeArea.h - _defaultConfig.gutter * (this.rows - 1)) / this.rows
    // 绘制所有格子
    this.cells.forEach((cell, cellIndex) => {
      let [x, y, width, height] = this.getGeometricProperty([cell.x, cell.y, cell.col!, cell.row!])
      // 默认不显示中奖标识
      let isActive = false
      // 只要 prizeFlag 不是负数, 就显示中奖标识
      if (this.prizeFlag === void 0 || this.prizeFlag > -1) {
        isActive = cellIndex === this.currIndex % this.prizes.length >> 0
      }
      // 绘制背景色
      const background = isActive ? _activeStyle.background : (cell.background || _defaultStyle.background)
      if (hasBackground(background)) {
        // 处理阴影 (暂时先用any, 这里后续要优化)
        const shadow: any = (
          isActive ? _activeStyle.shadow : (cell.shadow || _defaultStyle.shadow)
        )
          .replace(/px/g, '') // 清空px字符串
          .split(',')[0].split(' ') // 防止有人声明多个阴影, 截取第一个阴影
          .map((n, i) => i < 3 ? Number(n) : n) // 把数组的前三个值*像素比
        // 绘制阴影
        if (shadow.length === 4) {
          ctx.shadowColor = shadow[3]
          ctx.shadowOffsetX = shadow[0] * config.dpr
          ctx.shadowOffsetY = shadow[1] * config.dpr
          ctx.shadowBlur = shadow[2]
          // 修正(格子+阴影)的位置, 这里使用逗号运算符
          shadow[0] > 0 ? (width -= shadow[0]) : (width += shadow[0], x -= shadow[0])
          shadow[1] > 0 ? (height -= shadow[1]) : (height += shadow[1], y -= shadow[1])
        }
        // 绘制背景
        ctx.fillStyle = this.handleBackground(x, y, width, height, background)
        const borderRadius = this.getLength(cell.borderRadius ? cell.borderRadius : _defaultStyle.borderRadius)
        roundRectByArc(ctx, x, y, width, height, borderRadius)
        ctx.fill()
        // 清空阴影
        ctx.shadowColor = 'rgba(0, 0, 0, 0)'
        ctx.shadowOffsetX = 0
        ctx.shadowOffsetY = 0
        ctx.shadowBlur = 0
      }
      // 修正图片缓存
      let cellName = 'prizes'
      if (cellIndex >= this.prizes.length) {
        cellName = 'buttons'
        cellIndex -= this.prizes.length
      }
      // 绘制图片
      cell.imgs && cell.imgs.forEach((imgInfo, imgIndex) => {
        const cellImg = this.ImageCache.get(imgInfo.src)
        const activeImg = this.ImageCache.get(imgInfo['activeSrc'])
        if (!cellImg) return
        const renderImg = (isActive && activeImg) || cellImg
        if (!renderImg) return
        const [trueWidth, trueHeight] = this.computedWidthAndHeight(renderImg, imgInfo, width, height)
        const [xAxis, yAxis] = [
          x + this.getOffsetX(trueWidth, width) + this.getLength(imgInfo.left, width),
          y + this.getLength(imgInfo.top, height)
        ]
        this.drawImage(ctx, renderImg, xAxis, yAxis, trueWidth, trueHeight)
      })
      // 绘制文字
      cell.fonts && cell.fonts.forEach(font => {
        // 字体样式
        const style = isActive && _activeStyle.fontStyle
          ? _activeStyle.fontStyle
          : (font.fontStyle || _defaultStyle.fontStyle)
        // 字体加粗
        const fontWeight = isActive && _activeStyle.fontWeight
          ? _activeStyle.fontWeight
          : (font.fontWeight || _defaultStyle.fontWeight)
        // 字体大小
        const size = isActive && _activeStyle.fontSize
          ? this.getLength(_activeStyle.fontSize)
          : this.getLength(font.fontSize || _defaultStyle.fontSize)
        // 字体行高
        const lineHeight = isActive && _activeStyle.lineHeight
          ? _activeStyle.lineHeight
          : font.lineHeight || _defaultStyle.lineHeight || font.fontSize || _defaultStyle.fontSize
        const wordWrap = has(font, 'wordWrap') ? font.wordWrap : _defaultStyle.wordWrap
        const lengthLimit = font.lengthLimit || _defaultStyle.lengthLimit
        const lineClamp = font.lineClamp || _defaultStyle.lineClamp
        ctx.font = `${fontWeight} ${size >> 0}px ${style}`
        ctx.fillStyle = (isActive && _activeStyle.fontColor) ? _activeStyle.fontColor : (font.fontColor || _defaultStyle.fontColor)
        let lines = [], text = String(font.text)
        // 计算文字换行
        if (wordWrap) {
          // 最大宽度
          let maxWidth = this.getLength(lengthLimit, width)
          lines = splitText(ctx, removeEnter(text), () => maxWidth, lineClamp)
        } else {
          lines = text.split('\n')
        }
        lines.forEach((line, lineIndex) => {
          ctx.fillText(
            line,
            x + this.getOffsetX(ctx.measureText(line).width, width) + this.getLength(font.left, width),
            y + this.getLength(font.top, height) + (lineIndex + 1) * this.getLength(lineHeight)
          )
        })
      })
    })
    // 触发绘制后回调
    config.afterDraw?.call(this, ctx)
  }

  /**
   * 处理背景色
   * @param x
   * @param y
   * @param width
   * @param height
   * @param background
   * @param isActive
   */
  private handleBackground (
    x: number,
    y: number,
    width: number,
    height: number,
    background: string,
  ) {
    const { ctx } = this
    // 处理线性渐变
    if (background.includes('linear-gradient')) {
      background = getLinearGradient(ctx, x, y, width, height, background)
    }
    return background
  }

  /**
   * 刻舟求剑
   */
  private carveOnGunwaleOfAMovingBoat (): void {
    const { _defaultConfig, prizeFlag, currIndex } = this
    this.endTime = Date.now()
    const stopIndex = this.stopIndex = currIndex
    const speed = _defaultConfig.speed
    let i = 0, prevSpeed = 0, prevIndex = 0
    while (++i) {
      const endIndex = this.prizes.length * i + prizeFlag! - (stopIndex)
      const currSpeed = quad.easeOut(this.FPS, stopIndex, endIndex, _defaultConfig.decelerationTime) - stopIndex
      if (currSpeed > speed) {
        this.endIndex = (speed - prevSpeed > currSpeed - speed) ? endIndex : prevIndex
        break
      }
      prevIndex = endIndex
      prevSpeed = currSpeed
    }
  }

  /**
   * 对外暴露: 开始抽奖方法
   */
  public play (): void {
    if (this.step !== 0) return
    // 记录游戏开始的时间
    this.startTime = Date.now()
    // 重置中奖索引
    this.prizeFlag = void 0
    // 开始加速
    this.step = 1
    // 触发回调
    this.config.afterStart?.()
    // 开始运行
    this.run()
  }

  /**
   * 对外暴露: 缓慢停止方法
   * @param index 中奖索引
   */
  public stop (index?: number): void {
    if (this.step === 0 || this.step === 3) return
    // 如果没有传递中奖索引, 则通过range属性计算一个
    if (!index && index !== 0) {
      const rangeArr = this.prizes.map(item => item.range)
      index = computeRange(rangeArr)
    }
    // 如果index是负数则停止游戏, 反之则传递中奖索引
    if (index < 0) {
      this.step = 0
      this.prizeFlag = -1
    } else {
      this.step = 2
      this.prizeFlag = index % this.prizes.length
    }
  }

  /**
   * 实际开始执行方法
   * @param num 记录帧动画执行多少次
   */
  private run (num: number = 0): void {
    const { rAF, step, prizes, prizeFlag, _defaultConfig } = this
    const { accelerationTime, decelerationTime, speed } = _defaultConfig
    // 结束游戏
    if (step === 0) {
      this.endCallback?.(this.prizes.find((prize, index) => index === prizeFlag) || {})
      return
    }
    // 如果等于 -1 就直接停止游戏
    if (prizeFlag === -1) return
    // 计算结束位置
    if (step === 3 && !this.endIndex) this.carveOnGunwaleOfAMovingBoat()
    // 计算时间间隔
    const startInterval = Date.now() - this.startTime
    const endInterval = Date.now() - this.endTime
    let currIndex = this.currIndex
    // 
    if (step === 1 || startInterval < accelerationTime) { // 加速阶段
      // 记录帧率
      this.FPS = startInterval / num
      const currSpeed = quad.easeIn(startInterval, 0.1, speed - 0.1, accelerationTime)
      // 加速到峰值后, 进入匀速阶段
      if (currSpeed === speed) {
        this.step = 2
      }
      currIndex = currIndex + currSpeed % prizes.length
    } else if (step === 2) { // 匀速阶段
      // 速度保持不变
      currIndex = currIndex + speed % prizes.length
      // 如果 prizeFlag 有值, 则进入减速阶段
      if (prizeFlag !== void 0 && prizeFlag >= 0) {
        this.step = 3
        // 清空上一次的位置信息
        this.stopIndex = 0
        this.endIndex = 0
      }
    } else if (step === 3) { // 减速阶段
      // 开始缓慢停止
      currIndex = quad.easeOut(endInterval, this.stopIndex, this.endIndex, decelerationTime)
      if (endInterval >= decelerationTime) {
        this.step = 0
      }
    } else {
      // 出现异常
      this.stop(-1)
    }
    this.currIndex = currIndex
    this.draw()
    rAF(this.run.bind(this, num + 1))
  }

  /**
   * 计算奖品格子的几何属性
   * @param { array } [...矩阵坐标, col, row]
   * @return { array } [...真实坐标, width, height]
   */
  private getGeometricProperty ([x, y, col = 1, row = 1]: number[]) {
    const { cellWidth, cellHeight } = this
    const gutter = this._defaultConfig.gutter
    let res = [
      this.prizeArea!.x + (cellWidth + gutter) * x,
      this.prizeArea!.y + (cellHeight + gutter) * y
    ]
    col && row && res.push(
      cellWidth * col + gutter * (col - 1),
      cellHeight * row + gutter * (row - 1),
    )
    return res
  }

  /**
   * 换算渲染坐标
   * @param x
   * @param y
   */
  protected conversionAxis (x: number, y: number): [number, number] {
    const { config } = this
    return [x / config.dpr, y / config.dpr]
  }
}


================================================
FILE: packages/core/src/lib/lucky.ts
================================================
import '../utils/polyfill'
import { has, isExpectType, throttle } from '../utils/index'
import { name, version } from '../../package.json'
import { ConfigType, UserConfigType, ImgItemType, ImgType, Tuple } from '../types/index'
import { defineReactive } from '../observer'
import Watcher, { WatchOptType } from '../observer/watcher'

export default class Lucky {
  static version: string = version
  protected readonly version: string = version
  protected readonly config: ConfigType
  protected readonly ctx: CanvasRenderingContext2D
  protected htmlFontSize: number = 16
  protected rAF: Function = function () {}
  protected boxWidth: number = 0
  protected boxHeight: number = 0
  protected data: {
    width: string | number,
    height: string | number
  }

  /**
   * 公共构造器
   * @param config
   */
  constructor (
    config: string | HTMLDivElement | UserConfigType,
    data: {
      width: string | number,
      height: string | number
    }
  ) {
    // 兼容代码开始: 为了处理 v1.0.6 版本在这里传入了一个 dom
    if (typeof config === 'string') config = { el: config } as UserConfigType
    else if (config.nodeType === 1) config = { el: '', divElement: config } as UserConfigType
    // 这里先野蛮的处理, 等待后续优化, 对外暴露的类型是UserConfigType, 但内部期望是ConfigType
    config = config as UserConfigType
    this.config = config as ConfigType
    this.data = data
    // 开始初始化
    if (!config.flag) config.flag = 'WEB'
    if (config.el) config.divElement = document.querySelector(config.el) as HTMLDivElement
    // 如果存在父盒子, 就创建canvas标签
    if (config.divElement) {
      // 无论盒子内有没有canvas都执行覆盖逻辑
      config.canvasElement = document.createElement('canvas')
      config.divElement.appendChild(config.canvasElement)
    }
    // 获取 canvas 上下文
    if (config.canvasElement) {
      config.ctx = config.canvasElement.getContext('2d')!
      // 添加版本信息到标签上, 方便定位版本问题
      config.canvasElement.setAttribute('package', `${name}@${version}`)
      config.canvasElement.addEventListener('click', e => this.handleClick(e))
    }
    this.ctx = config.ctx as CanvasRenderingContext2D
    // 初始化 window 方法
    this.initWindowFunction()
    // 如果最后得不到 canvas 上下文那就无法进行绘制
    if (!this.config.ctx) {
      console.error('无法获取到 CanvasContext2D')
    }
    // 监听 window 触发 resize 时重置
    if (window && typeof window.addEventListener === 'function') {
      window.addEventListener('resize', throttle(() => this.resize(), 300))
    }
    // 监听异步设置 html 的 fontSize 并重新绘制
    if (window && typeof window.MutationObserver === 'function') {
      new window.MutationObserver(() => {
        this.resize()
      }).observe(document.documentElement, { attributes: true })
    }
  }

  /**
   * 初始化组件大小/单位
   */
  protected resize(): void {
    this.config.beforeResize?.()
    // 先初始化 fontSize 以防后面有 rem 单位
    this.setHTMLFontSize()
    // 拿到 config 即可设置 dpr
    this.setDpr()
    // 初始化宽高
    this.resetWidthAndHeight()
    // 根据 dpr 来缩放 canvas
    this.zoomCanvas()
  }

  /**
   * 初始化方法
   */
  protected initLucky () {
    this.resize()
    if (!this.boxWidth || !this.boxHeight) {
      return console.error('无法获取到宽度或高度')
    }
  }

  /**
   * 鼠标点击事件
   * @param e 事件参数
   */
  protected handleClick (e: MouseEvent): void {}

  /**
   * 根标签的字体大小
   */
  protected setHTMLFontSize (): void {
  if (!window || !window.getComputedStyle) return
    this.htmlFontSize = +window.getComputedStyle(document.documentElement).fontSize.slice(0, -2)
  }

  // 清空画布
  public clearCanvas (): void {
    const [width, height] = [this.boxWidth, this.boxHeight]
    this.ctx.clearRect(-width, -height, width * 2, height * 2)
  }

  /**
   * 设备像素比
   * window 环境下自动获取, 其余环境手动传入
   */
  protected setDpr (): void {
    const { config } = this
    if (config.dpr) {
      // 优先使用 config 传入的 dpr
    } else if (window) {
      window['dpr'] = config.dpr = window.devicePixelRatio || 1
    } else if (!config.dpr) {
      console.error(config, '未传入 dpr 可能会导致绘制异常')
    }
  }

  /**
   * 重置盒子和canvas的宽高
   */
  private resetWidthAndHeight (): void {
    const { config, data } = this
    // 如果是浏览器环境并且存在盒子
    let boxWidth = 0, boxHeight = 0
    if (config.divElement) {
      boxWidth = config.divElement.offsetWidth
      boxHeight = config.divElement.offsetHeight
    }
    // 先从 data 里取宽高, 如果 config 上面没有, 就从 style 上面取
    this.boxWidth = this.getLength(data.width || config['width']) || boxWidth
    this.boxHeight = this.getLength(data.height || config['height']) || boxHeight
    // 重新把宽高赋给盒子
    if (config.divElement) {
      config.divElement.style.overflow = 'hidden'
      config.divElement.style.width = this.boxWidth + 'px'
      config.divElement.style.height = this.boxHeight + 'px'
    }
  }

  /**
   * 根据 dpr 缩放 canvas 并处理位移
   */
  protected zoomCanvas (): void {
    const { config, ctx } = this
    const { canvasElement, dpr } = config
    const [width, height] = [this.boxWidth * dpr, this.boxHeight * dpr]
    if (!canvasElement) return
    canvasElement.width = width
    canvasElement.height = height
    canvasElement.style.width = `${width}px`
    canvasElement.style.height = `${height}px`
    canvasElement.style['transform-origin'] = 'left top'
    canvasElement.style.transform = `scale(${1 / dpr})`
    ctx.scale(dpr, dpr)
  }

  /**
   * 从 window 对象上获取一些方法
   */
  private initWindowFunction (): void {
    const { config } = this
    if (window) {
      this.rAF = window.requestAnimationFrame ||
        window['webkitRequestAnimationFrame'] ||
        window['mozRequestAnimationFrame'] ||
        function (callback: Function) {
          window.setTimeout(callback, 1000 / 60)
        }
      config.setTimeout = window.setTimeout
      config.setInterval = window.setInterval
      config.clearTimeout = window.clearTimeout
      config.clearInterval = window.clearInterval
      return
    }
    if (config.rAF) {
      // 优先使用帧动画
      this.rAF = config.rAF
    } else if (config.setTimeout) {
      // 其次使用定时器
      const timeout = config.setTimeout
      this.rAF = (callback: Function): number => timeout(callback, 16.7)
    } else {
      // 如果config里面没有提供, 那就假设全局方法存在setTimeout
      this.rAF = (callback: Function): number => setTimeout(callback, 16.7)
    }
  }

  public isWeb () {
    return ['WEB', 'UNI-H5', 'TARO-H5'].includes(this.config.flag)
  }

  /**
   * 异步加载图片并返回图片的几何信息
   * @param src 图片路径
   * @param info 图片信息
   */
  protected loadImg (
    src: string,
    info: ImgItemType,
    resolveName = '$resolve'
  ): Promise<ImgType> {
    return new Promise((resolve, reject) => {
      if (!src) reject(`=> '${info.src}' 不能为空或不合法`)
      if (this.config.flag === 'WEB') {
        let imgObj = new Image()
        imgObj['crossorigin'] = 'anonymous'
        imgObj.onload = () => resolve(imgObj)
        imgObj.onerror = () => reject(`=> '${info.src}' 图片加载失败`)
        imgObj.src = src
      } else {
        // 其余平台向外暴露, 交给外部自行处理
        info[resolveName] = resolve
        info['$reject'] = reject
        return
      }
    })
  }

  /**
   * 公共绘制图片的方法
   * @param imgObj 图片对象
   * @param rectInfo: [x轴位置, y轴位置, 渲染宽度, 渲染高度] 
   */
  protected drawImage(
    ctx: CanvasRenderingContext2D,
    imgObj: ImgType,
    ...rectInfo: [...Tuple<number, 4>, ...Partial<Tuple<number, 4>>]
  ): void {
    let drawImg
    const { flag, dpr } = this.config
    if (['WEB', 'MP-WX'].includes(flag)) {
      // 浏览器和新版小程序中直接绘制即可
      drawImg = imgObj
    } else if (['UNI-H5', 'UNI-MP', 'TARO-H5', 'TARO-MP'].includes(flag)) {
      // 旧版本的小程序需要绘制 path, 这里特殊处理一下
      type OldImageType = ImgType & { path: CanvasImageSource }
      drawImg = (imgObj as OldImageType).path
    } else {
      // 如果传入了未知的标识
      return console.error('意料之外的 flag, 该平台尚未兼容!')
    }
    const miniProgramOffCtx = (drawImg['canvas'] || drawImg).getContext?.('2d')
    if (miniProgramOffCtx && !this.isWeb()) {
      rectInfo = rectInfo.map(val => val! * dpr) as Tuple<number, 8>
      const temp = miniProgramOffCtx.getImageData(...rectInfo.slice(0, 4))
      ctx.putImageData(temp, ...(rectInfo.slice(4, 6) as Tuple<number, 2>))
    } else {
      if (rectInfo.length === 8) {
        rectInfo = rectInfo.map((val, index) => index < 4 ? val! * dpr : val) as Tuple<number, 8>
      }
      // 尝试捕获错误
      try {
        ctx.drawImage(drawImg, ...rectInfo as Tuple<number, 8>)
      } catch (err) {
        /**
         * TODO: safari浏览器下, init() 会出现奇怪的报错
         * IndexSizeError: The index is not in the allowed range
         * 但是这个报错并不影响实际的绘制, 目前先放一放, 等待有缘人
         */
        // console.log(err)
      }
    }
  }

  /**
   * 计算图片的渲染宽高
   * @param imgObj 图片标签元素
   * @param imgInfo 图片信息
   * @param maxWidth 最大宽度
   * @param maxHeight 最大高度
   * @return [渲染宽度, 渲染高度]
   */
  protected computedWidthAndHeight (
    imgObj: ImgType,
    imgInfo: ImgItemType,
    maxWidth: number,
    maxHeight: number
  ): [number, number] {
    // 根据配置的样式计算图片的真实宽高
    if (!imgInfo.width && !imgInfo.height) {
      // 如果没有配置宽高, 则使用图片本身的宽高
      return [imgObj.width, imgObj.height]
    } else if (imgInfo.width && !imgInfo.height) {
      // 如果只填写了宽度, 没填写高度
      let trueWidth = this.getLength(imgInfo.width, maxWidth)
      // 那高度就随着宽度进行等比缩放
      return [trueWidth, imgObj.height * (trueWidth / imgObj.width)]
    } else if (!imgInfo.width && imgInfo.height) {
      // 如果只填写了宽度, 没填写高度
      let trueHeight = this.getLength(imgInfo.height, maxHeight)
      // 那宽度就随着高度进行等比缩放
      return [imgObj.width * (trueHeight / imgObj.height), trueHeight]
    }
    // 如果宽度和高度都填写了, 就如实计算
    return [
      this.getLength(imgInfo.width, maxWidth),
      this.getLength(imgInfo.height, maxHeight)
    ]
  }

  /**
   * 转换单位
   * @param { string } value 将要转换的值
   * @param { number } denominator 分子
   * @return { number } 返回新的字符串
   */
  protected changeUnits (value: string, denominator = 1): number {
    const { config } = this
    return Number(value.replace(/^([-]*[0-9.]*)([a-z%]*)$/, (val, num, unit) => {
      const handleCssUnit = {
        '%': (n: number) => n * (denominator / 100),
        'px': (n: number) => n * 1,
        'rem': (n: number) => n * this.htmlFontSize,
        'vw': (n: number) => n / 100 * window.innerWidth,
      }[unit]
      if (handleCssUnit) return handleCssUnit(num)
      // 如果找不到默认单位, 就交给外面处理
      const otherHandleCssUnit = config.handleCssUnit || config['unitFunc']
      return otherHandleCssUnit ? otherHandleCssUnit(num, unit) : num
    }))
  }

  /**
   * 获取长度
   * @param length 将要转换的长度
   * @param maxLength 最大长度
   * @return 返回长度
   */
  protected getLength (length: string | number | undefined, maxLength?: number): number {
    if (isExpectType(length, 'number')) return length as number
    if (isExpectType(length, 'string')) return this.changeUnits(length as string, maxLength)
    return 0
  }

  /**
   * 获取相对(居中)X坐标
   * @param width
   * @param col
   */
  protected getOffsetX (width: number, maxWidth: number = 0): number {
    return (maxWidth - width) / 2
  }

  protected getOffscreenCanvas (width: number, height: number): {
    _offscreenCanvas: HTMLCanvasElement,
    _ctx: CanvasRenderingContext2D
  } | void {
    if (!has(this, '_offscreenCanvas')) {
      if (window && window.document && this.config.flag === 'WEB') {
        this['_offscreenCanvas'] = document.createElement('canvas')
      } else {
        this['_offscreenCanvas'] = this.config['offscreenCanvas']
      }
      if (!this['_offscreenCanvas']) return console.error('离屏 Canvas 无法渲染!')
    }
    const dpr = this.config.dpr
    const _offscreenCanvas = this['_offscreenCanvas'] as HTMLCanvasElement
    _offscreenCanvas.width = (width || 300) * dpr
    _offscreenCanvas.height = (height || 150) * dpr
    const _ctx = _offscreenCanvas.getContext('2d')!
    _ctx.clearRect(0, 0, width, height)
    _ctx.scale(dpr, dpr)
    _ctx['dpr'] = dpr
    return { _offscreenCanvas, _ctx }
  }

  /**
   * 添加一个新的响应式数据 (临时)
   * @param data 数据
   * @param key 属性
   * @param value 新值
   */
  public $set (data: object, key: string | number, value: any) {
    if (!data || typeof data !== 'object') return
    defineReactive(data, key, value)
  }

  /**
   * 添加一个属性计算 (临时)
   * @param data 源数据
   * @param key 属性名
   * @param callback 回调函数
   */
  protected $computed (data: object, key: string, callback: Function) {
    Object.defineProperty(data, key, {
      get: () => {
        return callback.call(this)
      }
    })
  }

  /**
   * 添加一个观察者 create user watcher
   * @param expr 表达式
   * @param handler 回调函数
   * @param watchOpt 配置参数
   * @return 卸载当前观察者的函数 (暂未返回)
   */
  protected $watch (
    expr: string | Function,
    handler: Function | WatchOptType,
    watchOpt: WatchOptType = {}
  ): Function {
    if (typeof handler === 'object') {
      watchOpt = handler
      handler = watchOpt.handler!
    }
    // 创建 user watcher
    const watcher = new Watcher(this, expr, handler, watchOpt)
    // 判断是否需要初始化时触发回调
    if (watchOpt.immediate) {
      handler.call(this, watcher.value)
    }
    // 返回一个卸载当前观察者的函数
    return function unWatchFn () {}
  }
}


================================================
FILE: packages/core/src/lib/slot.ts
================================================
import Lucky from './lucky'
import { UserConfigType, ImgType, ImgItemType, Tuple } from '../types/index'
import SlotMachineConfig, {
  BlockType,
  PrizeType,
  SlotType,
  DefaultConfigType,
  DefaultStyleType,
  EndCallbackType,
} from '../types/slot'
import {
  get, has,
  isExpectType,
  removeEnter,
  computePadding,
  hasBackground,
  computeRange,
  splitText,
  getSortedArrayByIndex
} from '../utils/index'
import { roundRectByArc } from '../utils/math'
import { quad } from '../utils/tween'

export default class SlotMachine extends Lucky {
  // 背景
  private blocks: Array<BlockType> = []
  // 奖品列表
  private prizes: Array<PrizeType> = []
  // 插槽列表
  private slots: Array<SlotType> = []
  // 默认配置
  private defaultConfig: DefaultConfigType = {}
  private _defaultConfig: Required<DefaultConfigType> = {} as Required<DefaultConfigType>
  // 默认样式
  private defaultStyle: DefaultStyleType = {}
  private _defaultStyle: Required<DefaultStyleType> = {} as Required<DefaultStyleType>
  private endCallback: EndCallbackType = () => {}
  // 离屏canvas
  private _offscreenCanvas?: HTMLCanvasElement
  private cellWidth = 0             // 格子宽度
  private cellHeight = 0            // 格子高度
  private cellAndSpacing = 0        // 格子+间距
  private widthAndSpacing = 0       // 格子宽度+列间距
  private heightAndSpacing = 0      // 格子高度+行间距
  private FPS = 16.6                // 屏幕刷新率
  private scroll: number[] = []     // 滚动的长度
  private stopScroll: number[] = [] // 刻舟求剑
  private endScroll: number[] = []  // 最终停止的长度
  private startTime = 0             // 开始游戏的时间
  private endTime = 0               // 开始停止的时间
  // 默认顺序由 prizes 生成
  private defaultOrder: number[] = []
  /**
   * 游戏当前的阶段
   * step = 0 时, 游戏尚未开始
   * step = 1 时, 此时处于加速阶段
   * step = 2 时, 此时处于匀速阶段
   * step = 3 时, 此时处于减速阶段
   */
  private step: 0 | 1 | 2 | 3 = 0
  /**
   * 中奖索引
   * prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
   * prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
   * prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
   */
  private prizeFlag: number[] | undefined = void 0
  // 奖品区域几何信息
  private prizeArea?: { x: number, y: number, w: number, h: number }
  // 图片缓存
  private ImageCache = new Map()

  /**
   * 老虎机构造器
   * @param config 配置项
   * @param data 抽奖数据
   */
   constructor (config: UserConfigType, data: SlotMachineConfig) {
    super(config, {
      width: data.width,
      height: data.height
    })
    this.initData(data)
    this.initWatch()
    this.initComputed()
    // 创建前回调函数
    config.beforeCreate?.call(this)
    // 首次初始化
    this.init()
  }

  protected resize(): void {
    super.resize()
    this.draw()
    this.config.afterResize?.()
  }

  protected initLucky (): void {
    this.cellWidth = 0
    this.cellHeight = 0
    this.cellAndSpacing = 0
    this.widthAndSpacing = 0
    this.heightAndSpacing = 0
    this.FPS = 16.6
    this.scroll = []
    this.stopScroll = []
    this.endScroll = []
    this.startTime = 0
    this.endTime = 0
    this.prizeFlag = void 0
    this.step = 0
    super.initLucky()
  }

  /**
   * 初始化数据
   * @param data
   */
  private initData (data: SlotMachineConfig): void {
    this.$set(this, 'width', data.width)
    this.$set(this, 'height', data.height)
    this.$set(this, 'blocks', data.blocks || [])
    this.$set(this, 'prizes', data.prizes || [])
    this.$set(this, 'slots', data.slots || [])
    this.$set(this, 'defaultConfig', data.defaultConfig || {})
    this.$set(this, 'defaultStyle', data.defaultStyle || {})
    this.$set(this, 'endCallback', data.end)
  }

  /**
   * 初始化属性计算
   */
  private initComputed (): void {
    // 默认配置
    this.$computed(this, '_defaultConfig', () => {
      const config = {
        mode: 'vertical',
        rowSpacing: 0,
        colSpacing: 5,
        speed: 20,
        direction: 1,
        accelerationTime: 2500,
        decelerationTime: 2500,
        ...this.defaultConfig
      }
      config.rowSpacing = this.getLength(config.rowSpacing)
      config.colSpacing = this.getLength(config.colSpacing)
      return config
    })
    // 默认样式
    this.$computed(this, '_defaultStyle', () => {
      return {
        borderRadius: 0,
        fontColor: '#000',
        fontSize: '18px',
        fontStyle: 'sans-serif',
        fontWeight: '400',
        background: 'rgba(0,0,0,0)',
        wordWrap: true,
        lengthLimit: '90%',
        ...this.defaultStyle
      }
    })
  }

  /**
   * 初始化观察者
   */
  private initWatch (): void {
    // 重置宽度
    this.$watch('width', (newVal: string | number) => {
      this.data.width = newVal
      this.resize()
    })
    // 重置高度
    this.$watch('height', (newVal: string | number) => {
      this.data.height = newVal
      this.resize()
    })
    // 监听 blocks 数据的变化
    this.$watch('blocks', (newData: Array<BlockType>) => {
      this.initImageCache()
    }, { deep: true })
    // 监听 prizes 数据的变化
    this.$watch('prizes', (newData: Array<PrizeType>) => {
      this.initImageCache()
    }, { deep: true })
    // 监听 prizes 数据的变化
    this.$watch('slots', (newData: Array<PrizeType>) => {
      this.drawOffscreenCanvas()
      this.draw()
    }, { deep: true })
    this.$watch('defaultConfig', () => this.draw(), { deep: true })
    this.$watch('defaultStyle', () => this.draw(), { deep: true })
    this.$watch('endCallback', () => this.init())
  }

  /**
   * 初始化 canvas 抽奖
   */
  public async init (): Promise<void> {
    this.initLucky()
    const { config } = this
    // 初始化前回调函数
    config.beforeInit?.call(this)
    // 先绘制一次
    this.drawOffscreenCanvas()
    this.draw()
    // 异步加载图片
    await this.initImageCache()
    // 初始化后回调函数
    config.afterInit?.call(this)
  }

  private initImageCache (): Promise<void> {
    return new Promise((resolve) => {
      const willUpdateImgs = {
        blocks: this.blocks.map(block => block.imgs),
        prizes: this.prizes.map(prize => prize.imgs),
      }
      ;(<(keyof typeof willUpdateImgs)[]>Object.keys(willUpdateImgs)).forEach(imgName => {
        const willUpdate = willUpdateImgs[imgName]
        // 循环遍历所有图片
        const allPromise: Promise<void>[] = []
        willUpdate && willUpdate.forEach((imgs, cellIndex) => {
          imgs && imgs.forEach((imgInfo, imgIndex) => {
            allPromise.push(this.loadAndCacheImg(imgName, cellIndex, imgIndex))
          })
        })
        Promise.all(allPromise).then(() => {
          this.drawOffscreenCanvas()
          this.draw()
          resolve()
        })
      })
    })
  }

  /**
   * 根据索引单独加载指定图片并缓存
   * @param cellName 模块名称
   * @param cellIndex 模块索引
   * @param imgName 模块对应的图片缓存
   * @param imgIndex 图片索引
   */
  private async loadAndCacheImg (
    cellName: 'blocks' | 'prizes',
    cellIndex: number,
    imgIndex: number
  ): Promise<void> {
    return new Promise((resolve, reject) => {
      let cell: BlockType | PrizeType = this[cellName][cellIndex]
      if (!cell || !cell.imgs) return
      const imgInfo = cell.imgs[imgIndex]
      if (!imgInfo) return
      // 异步加载图片
      this.loadImg(imgInfo.src, imgInfo).then(async currImg => {
        if (typeof imgInfo.formatter === 'function') {
          currImg = await Promise.resolve(imgInfo.formatter.call(this, currImg))
        }
        this.ImageCache.set(imgInfo['src'], currImg)
        resolve()
      }).catch(err => {
        console.error(`${cellName}[${cellIndex}].imgs[${imgIndex}] ${err}`)
        reject()
      })
    })
  }

  /**
   * 绘制离屏canvas
   */
  protected drawOffscreenCanvas (): void {
    const { _defaultConfig, _defaultStyle } = this
    const { w, h } = this.drawBlocks()!
    // 计算单一奖品格子的宽度和高度
    const prizesLen = this.prizes.length
    const { cellWidth, cellHeight, widthAndSpacing, heightAndSpacing } = this.displacementWidthOrHeight()
    this.defaultOrder = new Array(prizesLen).fill(void 0).map((v, i) => i)
    let maxOrderLen = 0, maxOffWidth = 0, maxOffHeight = 0
    this.slots.forEach((slot, slotIndex) => {
      // 初始化 scroll 的值
      if (this.scroll[slotIndex] === void 0) this.scroll[slotIndex] = 0
      // 如果没有order属性, 就填充prizes
      const order = slot.order || this.defaultOrder
      // 计算最大值
      const currLen = order.length
      maxOrderLen = Math.max(maxOrderLen, currLen)
      maxOffWidth = Math.max(maxOffWidth, w + widthAndSpacing * currLen)
      maxOffHeight = Math.max(maxOffHeight, h + heightAndSpacing * currLen)
    })
    // 创建一个离屏Canvas来存储画布的内容
    const { _offscreenCanvas, _ctx } = this.getOffscreenCanvas(maxOffWidth, maxOffHeight)!
    this._offscreenCanvas = _offscreenCanvas
    // 绘制插槽
    this.slots.forEach((slot, slotIndex) => {
      const cellX = cellWidth * slotIndex
      const cellY = cellHeight * slotIndex
      let lengthOfCopy = 0
      // 绘制奖品
      const newPrizes = getSortedArrayByIndex(this.prizes, slot.order||this.defaultOrder)
      // 如果没有奖品则打断逻辑
      if (!newPrizes.length) return
      newPrizes.forEach((cell, cellIndex) => {
        if (!cell) return
        const prizesX = widthAndSpacing * cellIndex + _defaultConfig.colSpacing / 2
        const prizesY = heightAndSpacing * cellIndex + _defaultConfig.rowSpacing / 2
        const [_x, _y, spacing] = this.displacement(
          [cellX, prizesY, heightAndSpacing],
          [prizesX, cellY, widthAndSpacing]
        )
        lengthOfCopy += spacing
        // 绘制背景
        const background = cell.background || _defaultStyle.background
        if (hasBackground(background)) {
          const borderRadius = this.getLength(has(cell, 'borderRadius') ? cell.borderRadius : _defaultStyle.borderRadius)
          roundRectByArc(_ctx, _x, _y, cellWidth, cellWidth, borderRadius)
          _ctx.fillStyle = background
          _ctx.fill()
        }
        // 绘制图片
        cell.imgs && cell.imgs.forEach((imgInfo, imgIndex) => {
          const cellImg = this.ImageCache.get(imgInfo.src)
          if (!cellImg) return
          const [trueWidth, trueHeight] = this.computedWidthAndHeight(cellImg, imgInfo, cellWidth, cellHeight)
          const [xAxis, yAxis] = [
            _x + this.getOffsetX(trueWidth, cellWidth) + this.getLength(imgInfo.left, cellWidth),
            _y + this.getLength(imgInfo.top, cellHeight)
          ]
          this.drawImage(_ctx, cellImg, xAxis, yAxis, trueWidth, trueHeight)
        })
        // 绘制文字
        cell.fonts && cell.fonts.forEach(font => {
          // 字体样式
          const style = font.fontStyle || _defaultStyle.fontStyle
          // 字体加粗
          const fontWeight = font.fontWeight || _defaultStyle.fontWeight
          // 字体大小
          const size = this.getLength(font.fontSize || _defaultStyle.fontSize)
          // 字体行高
          const lineHeight = font.lineHeight || _defaultStyle.lineHeight || font.fontSize || _defaultStyle.fontSize
          const wordWrap = has(font, 'wordWrap') ? font.wordWrap : _defaultStyle.wordWrap
          const lengthLimit = font.lengthLimit || _defaultStyle.lengthLimit
          const lineClamp = font.lineClamp || _defaultStyle.lineClamp
          _ctx.font = `${fontWeight} ${size >> 0}px ${style}`
          _ctx.fillStyle = font.fontColor || _defaultStyle.fontColor
          let lines = [], text = String(font.text)
          // 计算文字换行
          if (wordWrap) {
            // 最大宽度
            let maxWidth = this.getLength(lengthLimit, cellWidth)
            lines = splitText(_ctx, removeEnter(text), () => maxWidth, lineClamp)
          } else {
            lines = text.split('\n')
          }
          lines.forEach((line, lineIndex) => {
            _ctx.fillText(
              line,
              _x + this.getOffsetX(_ctx.measureText(line).width, cellWidth) + this.getLength(font.left, cellWidth),
              _y + this.getLength(font.top, cellHeight) + (lineIndex + 1) * this.getLength(lineHeight)
            )
          })
        })
      })
      const [_x, _y, _w, _h] = this.displacement(
        [cellX, 0, cellWidth, lengthOfCopy],
        [0, cellY, lengthOfCopy, cellHeight]
      )
      let drawLen = lengthOfCopy
      while (drawLen < maxOffHeight + lengthOfCopy) {
        const [drawX, drawY] = this.displacement([_x, drawLen], [drawLen, _y])
        this.drawImage(
          _ctx, _offscreenCanvas,
          _x, _y, _w, _h,
          drawX, drawY, _w, _h
        )
        drawLen += lengthOfCopy
      }
    })
  }

  /**
   * 绘制背景区域
   */
  protected drawBlocks (): SlotMachine['prizeArea'] {
    const { config, ctx, _defaultConfig, _defaultStyle } = this
    // 绘制背景区域, 并计算奖品区域
    return this.prizeArea = this.blocks.reduce(({x, y, w, h}, block, blockIndex) => {
      const [paddingTop, paddingBottom, paddingLeft, paddingRight] = computePadding(block, this.getLength.bind(this))
      const r = block.borderRadius ? this.getLength(block.borderRadius) : 0
      // 绘制边框
      const background = block.background || _defaultStyle.background
      if (hasBackground(background)) {
        roundRectByArc(ctx, x, y, w, h, r)
        ctx.fillStyle = background
        ctx.fill()
      }
      // 绘制图片
      block.imgs && block.imgs.forEach((imgInfo, imgIndex) => {
        const blockImg = this.ImageCache.get(imgInfo.src)
        if (!blockImg) return
        // 绘制图片
        const [trueWidth, trueHeight] = this.computedWidthAndHeight(blockImg, imgInfo, w, h)
        const [xAxis, yAxis] = [this.getOffsetX(trueWidth, w) + this.getLength(imgInfo.left, w), this.getLength(imgInfo.top, h)]
        this.drawImage(ctx, blockImg, x + xAxis, y + yAxis, trueWidth, trueHeight)
      })
      return {
        x: x + paddingLeft,
        y: y + paddingTop,
        w: w - paddingLeft - paddingRight,
        h: h - paddingTop - paddingBottom
      }
    }, { x: 0, y: 0, w: this.boxWidth, h: this.boxHeight })
  }

  /**
   * 绘制老虎机抽奖
   */
  protected draw (): void {
    const { config, ctx, _defaultConfig, _defaultStyle } = this
    // 触发绘制前回调
    config.beforeDraw?.call(this, ctx)
    // 清空画布
    ctx.clearRect(0, 0, this.boxWidth, this.boxHeight)
    // 绘制背景
    const { x, y, w, h } = this.drawBlocks()!
    // 绘制插槽
    if (!this._offscreenCanvas) return
    const { cellWidth, cellHeight, cellAndSpacing, widthAndSpacing, heightAndSpacing } = this
    this.slots.forEach((slot, slotIndex) => {
      const order = slot.order || this.defaultOrder
      // 绘制临界点
      const _p = cellAndSpacing * order.length
      // 调整奖品垂直居中
      const start = this.displacement(-(h - heightAndSpacing) / 2, -(w - widthAndSpacing) / 2)
      let scroll = this.scroll[slotIndex] + start
      // scroll 会无限累加 1 / -1
      if (scroll < 0) {
        scroll = scroll % _p + _p
      }
      if (scroll > _p) {
        scroll = scroll % _p
      }
      const [sx, sy, sw, sh] = this.displacement(
        [cellWidth * slotIndex, scroll, cellWidth, h],
        [scroll, cellHeight * slotIndex, w, cellHeight]
      )
      const [dx, dy, dw, dh] = this.displacement(
        [x + widthAndSpacing * slotIndex, y, cellWidth, h],
        [x, y + heightAndSpacing * slotIndex, w, cellHeight]
      )
      this.drawImage(ctx, this._offscreenCanvas!, sx, sy, sw, sh, dx, dy, dw, dh)
    })
  }

  /**
   * 刻舟求剑
   */
  private carveOnGunwaleOfAMovingBoat (): void {
    const { _defaultConfig, prizeFlag, cellAndSpacing } = this
    // 记录开始停止的时间戳
    this.endTime = Date.now()
    this.slots.forEach((slot, slotIndex) => {
      const order = slot.order || this.defaultOrder
      if (!order.length) return
      const speed = slot.speed || _defaultConfig.speed
      const direction = slot.direction || _defaultConfig.direction
      const orderIndex = order.findIndex(prizeIndex => prizeIndex === prizeFlag![slotIndex])
      const _p = cellAndSpacing * order.length
      const stopScroll = this.stopScroll[slotIndex] = this.scroll[slotIndex]
      let i = 0
      while (++i) {
        const endScroll = cellAndSpacing * orderIndex + (_p * i * direction) - stopScroll
        const currSpeed = quad.easeOut(this.FPS, stopScroll, endScroll, _defaultConfig.decelerationTime) - stopScroll
        if (Math.abs(currSpeed) > speed) {
          this.endScroll[slotIndex] = endScroll
          break
        }
      }
    })
  }

  /**
   * 对外暴露: 开始抽奖方法
   */
   public play (): void {
    if (this.step !== 0) return
    // 记录开始游戏的时间
    this.startTime = Date.now()
    // 清空中奖索引
    this.prizeFlag = void 0
    // 开始加速
    this.step = 1
    // 触发回调
    this.config.afterStart?.()
    // 开始渲染
    this.run()
  }

  public stop (index: number | number[]): void {
    if (this.step === 0 || this.step === 3) return
    // 设置中奖索引
    if (typeof index === 'number') {
      this.prizeFlag = new Array(this.slots.length).fill(index)
    } else if (isExpectType(index, 'array')) {
      if (index.length === this.slots.length) {
        this.prizeFlag = index
      } else {
        this.stop(-1)
        return console.error(`stop([${index}]) 参数长度的不正确`)
      }
    } else {
      this.stop(-1)
      return console.error(`stop() 无法识别的参数类型 ${typeof index}`)
    }
    // 如果包含负数则停止游戏, 反之则继续游戏
    if (this.prizeFlag?.includes(-1)) {
      this.prizeFlag = []
      // 停止游戏
      this.step = 0
    } else {
      // 进入匀速
      this.step = 2
    }
  }

  /**
   * 让游戏动起来
   * @param num 记录帧动画执行多少次
   */
  private run (num: number = 0): void {
    const { rAF, step, prizeFlag, _defaultConfig, cellAndSpacing, slots } = this
    const { accelerationTime, decelerationTime } = _defaultConfig
    // 游戏结束
    if (this.step === 0 && prizeFlag?.length === slots.length) {
      let flag = prizeFlag[0]
      for (let i = 0; i < slots.length; i++) {
        const slot = slots[i], currFlag = prizeFlag[i]
        const order = slot.order || this.defaultOrder
        if (!order?.includes(currFlag) || flag !== currFlag) {
          flag = -1
          break
        }
      }
      this.endCallback?.(this.prizes.find((prize, index) => index === flag) || void 0)
      return
    }
    // 如果长度为 0 就直接停止游戏
    if (prizeFlag !== void 0 && !prizeFlag.length) return
    // 计算最终停止的位置
    if (this.step === 3 && !this.endScroll.length) this.carveOnGunwaleOfAMovingBoat()
    // 计算时间间隔
    const startInterval = Date.now() - this.startTime
    const endInterval = Date.now() - this.endTime
    // 分别计算对应插槽的加速度
    slots.forEach((slot, slotIndex) => {
      const order = slot.order || this.defaultOrder
      if (!order || !order.length) return
      const _p = cellAndSpacing * order.length
      const speed = Math.abs(slot.speed || _defaultConfig.speed)
      const direction = slot.direction || _defaultConfig.direction
      let scroll = 0, prevScroll = this.scroll[slotIndex]
      if (step === 1 || startInterval < accelerationTime) { // 加速阶段
        // 记录帧率
        this.FPS = startInterval / num
        const currSpeed = quad.easeIn(startInterval, 0, speed, accelerationTime)
        // 加速到最大速度后, 即可进入匀速阶段
        if (currSpeed === speed) {
          this.step = 2
        }
        scroll = (prevScroll + (currSpeed * direction)) % _p
      } else if (step === 2) { // 匀速阶段
        // 速度保持不变
        scroll = (prevScroll + (speed * direction)) % _p
        // 如果有 prizeFlag 有值, 则进入减速阶段
        if (prizeFlag?.length === slots.length) {
          this.step = 3
          // 清空上一轮的位置信息
          this.stopScroll = []
          this.endScroll = []
        }
      } else if (step === 3 && endInterval) { // 减速阶段
        // 开始缓慢停止
        const stopScroll = this.stopScroll[slotIndex]
        const endScroll = this.endScroll[slotIndex]
        scroll = quad.easeOut(endInterval, stopScroll, endScroll, decelerationTime)
        if (endInterval >= decelerationTime) {
          this.step = 0
        }
      }
      this.scroll[slotIndex] = scroll
    })
    this.draw()
    rAF(this.run.bind(this, num + 1))
  }

  // 根据mode置换数值
  private displacement<T> (a: T, b: T): T {
    return this._defaultConfig.mode === 'horizontal' ? b : a
  }

  // 根据mode计算宽高
  private displacementWidthOrHeight () {
    const mode = this._defaultConfig.mode
    const slotsLen = this.slots.length
    const { colSpacing, rowSpacing } = this._defaultConfig
    const { x, y, w, h } = this.prizeArea || this.drawBlocks()!
    let cellWidth = 0, cellHeight = 0, widthAndSpacing = 0, heightAndSpacing = 0
    if (mode === 'horizontal') {
      cellHeight = this.cellHeight = (h - rowSpacing * (slotsLen - 1)) / slotsLen
      cellWidth = this.cellWidth = cellHeight
    } else {
      cellWidth = this.cellWidth = (w - colSpacing * (slotsLen - 1)) / slotsLen
      cellHeight = this.cellHeight = cellWidth
    }
    widthAndSpacing = this.widthAndSpacing = this.cellWidth + colSpacing
    heightAndSpacing = this.heightAndSpacing = this.cellHeight + rowSpacing
    if (mode === 'horizontal') {
      this.cellAndSpacing = widthAndSpacing
    } else {
      this.cellAndSpacing = heightAndSpacing
    }
    return {
      cellWidth,
      cellHeight,
      widthAndSpacing,
      heightAndSpacing,
    }
  }
}


================================================
FILE: packages/core/src/lib/wheel.ts
================================================
import Lucky from './lucky'
import { UserConfigType, FontItemType, ImgType } from '../types/index'
import LuckyWheelConfig, {
  BlockType,
  PrizeType,
  ButtonType,
  DefaultConfigType,
  DefaultStyleType,
  StartCallbackType,
  EndCallbackType
} from '../types/wheel'
import {
  removeEnter,
  hasBackground,
  computeRange,
  splitText,
  has,
} from '../utils/index'
import { getAngle, fanShapedByArc } from '../utils/math'
import { quad } from '../utils/tween'

export default class LuckyWheel extends Lucky {
  private blocks: Array<BlockType> = []
  private prizes: Array<PrizeType> = []
  private buttons: Array<ButtonType> = []
  private defaultConfig: DefaultConfigType = {}
  private defaultStyle: DefaultStyleType = {}
  private _defaultConfig: Required<DefaultConfigType> = {} as Required<DefaultConfigType>
  private _defaultStyle: Required<DefaultStyleType> = {} as Required<DefaultStyleType>
  private startCallback?: StartCallbackType
  private endCallback?: EndCallbackType
  private Radius = 0                    // 大转盘半径
  private prizeRadius = 0               // 奖品区域半径
  private prizeDeg = 0                  // 奖品数学角度
  private prizeAng = 0               // 奖品运算角度
  private rotateDeg = 0                 // 转盘旋转角度
  private maxBtnRadius = 0              // 最大按钮半径
  private startTime = 0                 // 开始时间戳
  private endTime = 0                   // 停止时间戳
  private stopDeg = 0                   // 刻舟求剑
  private endDeg = 0                    // 停止角度
  private FPS = 16.6                    // 屏幕刷新率
  /**
   * 游戏当前的阶段
   * step = 0 时, 游戏尚未开始
   * step = 1 时, 此时处于加速阶段
   * step = 2 时, 此时处于匀速阶段
   * step = 3 时, 此时处于减速阶段
   */
  private step: 0 | 1 | 2 | 3 = 0
  /**
   * 中奖索引
   * prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
   * prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
   * prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
   */
  private prizeFlag: number | undefined
  private ImageCache = new Map()

  /**
   * 大转盘构造器
   * @param config 配置项
   * @param data 抽奖数据
   */
  constructor (config: UserConfigType, data: LuckyWheelConfig) {
    super(config, {
      width: data.width,
      height: data.height
    })
    this.initData(data)
    this.initWatch()
    this.initComputed()
    // 创建前回调函数
    config.beforeCreate?.call(this)
    // 首次初始化
    this.init()
  }

  protected resize(): void {
    super.resize()
    this.Radius = Math.min(this.boxWidth, this.boxHeight) / 2
    this.ctx.translate(this.Radius, this.Radius)
    this.draw()
    this.config.afterResize?.()
  }

  protected initLucky (): void {
    this.Radius = 0
    this.prizeRadius = 0
    this.prizeDeg = 0
    this.prizeAng = 0
    this.rotateDeg = 0
    this.maxBtnRadius = 0
    this.startTime = 0
    this.endTime = 0
    this.stopDeg = 0
    this.endDeg = 0
    this.FPS = 16.6
    this.prizeFlag = -1
    this.step = 0
    super.initLucky()
  }

  /**
   * 初始化数据
   * @param data
   */
  private initData (data: LuckyWheelConfig): void {
    this.$set(this, 'width', data.width)
    this.$set(this, 'height', data.height)
    this.$set(this, 'blocks', data.blocks || [])
    this.$set(this, 'prizes', data.prizes || [])
    this.$set(this, 'buttons', data.buttons || [])
    this.$set(this, 'defaultConfig', data.defaultConfig || {})
    this.$set(this, 'defaultStyle', data.defaultStyle || {})
    this.$set(this, 'startCallback', data.start)
    this.$set(this, 'endCallback', data.end)
  }

  /**
   * 初始化属性计算
   */
  private initComputed () {
    // 默认配置
    this.$computed(this, '_defaultConfig', () => {
      const config = {
        gutter: '0px',
        offsetDegree: 0,
        speed: 20,
        speedFunction: 'quad',
        accelerationTime: 2500,
        decelerationTime: 2500,
        stopRange: 0,
        ...this.defaultConfig
      }
      return config
    })
    // 默认样式
    this.$computed(this, '_defaultStyle', () => {
      const style = {
        fontSize: '18px',
        fontColor: '#000',
        fontStyle: 'sans-serif',
        fontWeight: '400',
        background: 'rgba(0,0,0,0)',
        wordWrap: true,
        lengthLimit: '90%',
        ...this.defaultStyle
      }
      return style
    })
  }

  /**
   * 初始化观察者
   */
  private initWatch () {
    // 重置宽度
    this.$watch('width', (newVal: string | number) => {
      this.data.width = newVal
      this.resize()
    })
    // 重置高度
    this.$watch('height', (newVal: string | number) => {
      this.data.height = newVal
      this.resize()
    })
    // 观察 blocks 变化收集图片
    this.$watch('blocks', (newData: Array<BlockType>) => {
      this.initImageCache()
    }, { deep: true })
    // 观察 prizes 变化收集图片
    this.$watch('prizes', (newData: Array<PrizeType>) => {
      this.initImageCache()
    }, { deep: true })
    // 观察 buttons 变化收集图片
    this.$watch('buttons', (newData: Array<ButtonType>) => {
      this.initImageCache()
    }, { deep: true })
    this.$watch('defaultConfig', () => this.draw(), { deep: true })
    this.$watch('defaultStyle', () => this.draw(), { deep: true })
    this.$watch('startCallback', () => this.init())
    this.$watch('endCallback', () => this.init())
  }

  /**
   * 初始化 canvas 抽奖
   */
  public async init (): Promise<void> {
    this.initLucky()
    const { config } = this
    // 初始化前回调函数
    config.beforeInit?.call(this)
    this.draw() // 先画一次, 防止闪烁
    this.draw() // 再画一次, 拿到正确的按钮轮廓
    // 异步加载图片
    await this.initImageCache()
    // 初始化后回调函数
    config.afterInit?.call(this)
  }

  private initImageCache (): Promise<void> {
    return new Promise((resolve) => {
      const willUpdateImgs = {
        blocks: this.blocks.map(block => block.imgs),
        prizes: this.prizes.map(prize => prize.imgs),
        buttons: this.buttons.map(btn => btn.imgs),
      }
      ;(<(keyof typeof willUpdateImgs)[]>Object.keys(willUpdateImgs)).forEach(imgName => {
        const willUpdate = willUpdateImgs[imgName]
        // 循环遍历所有图片
        const allPromise: Promise<void>[] = []
        willUpdate && willUpdate.forEach((imgs, cellIndex) => {
          imgs && imgs.forEach((imgInfo, imgIndex) => {
            allPromise.push(this.loadAndCacheImg(imgName, cellIndex, imgIndex))
          })
        })
        Promise.all(allPromise).then(() => {
          this.draw()
          resolve()
        })
      })
    })
  }

  /**
   * canvas点击事件
   * @param e 事件参数
   */
  protected handleClick (e: MouseEvent): void {
    const { ctx } = this
    ctx.beginPath()
    ctx.arc(0, 0, this.maxBtnRadius, 0, Math.PI * 2, false)
    if (!ctx.isPointInPath(e.offsetX, e.offsetY)) return
    if (this.step !== 0) return
    this.startCallback?.(e)
  }

  /**
   * 根据索引单独加载指定图片并缓存
   * @param cellName 模块名称
   * @param cellIndex 模块索引
   * @param imgName 模块对应的图片缓存
   * @param imgIndex 图片索引
   */
  private async loadAndCacheImg (
    cellName: 'blocks' | 'prizes' | 'buttons',
    cellIndex: number,
    imgIndex: number,
  ): Promise<void> {
    return new Promise((resolve, reject) => {
      // 获取图片信息
      const cell: BlockType | PrizeType | ButtonType = this[cellName][cellIndex]
      if (!cell || !cell.imgs) return
      const imgInfo = cell.imgs[imgIndex]
      if (!imgInfo) return
      // 异步加载图片
      this.loadImg(imgInfo.src, imgInfo).then(async currImg => {
        if (typeof imgInfo.formatter === 'function') {
          currImg = await Promise.resolve(imgInfo.formatter.call(this, currImg))
        }
        this.ImageCache.set(imgInfo['src'], currImg)
        resolve()
      }).catch(err => {
        console.error(`${cellName}[${cellIndex}].imgs[${imgIndex}] ${err}`)
        reject()
      })
    })
  }

  private drawBlock (radius: number, block: BlockType, blockIndex: number): void {
    const { ctx } = this
    if (hasBackground(block.background)) {
      ctx.beginPath()
      ctx.fillStyle = block.background!
      ctx.arc(0, 0, radius, 0, Math.PI * 2, false)
      ctx.fill()
    }
    block.imgs && block.imgs.forEach((imgInfo, imgIndex) => {
      const blockImg = this.ImageCache.get(imgInfo.src)
      if (!blockImg) return
      // 绘制图片
      const [trueWidth, trueHeight] = this.computedWidthAndHeight(blockImg, imgInfo, radius * 2, radius * 2)
      const [xAxis, yAxis] = [this.getOffsetX(trueWidth) + this.getLength(imgInfo.left, radius * 2), this.getLength(imgInfo.top, radius * 2) - radius]
      ctx.save()
      imgInfo.rotate && ctx.rotate(getAngle(this.rotateDeg))
      this.drawImage(ctx, blockImg, xAxis, yAxis, trueWidth, trueHeight)
      ctx.restore()
    })
  }

  /**
   * 开始绘制
   */
  protected draw (): void {
    const { config, ctx, _defaultConfig, _defaultStyle } = this
    // 触发绘制前回调
    config.beforeDraw?.call(this, ctx)
    // 清空画布
    ctx.clearRect(-this.Radius, -this.Radius, this.Radius * 2, this.Radius * 2)
    // 计算 padding 并绘制 blocks 边框
    this.prizeRadius = this.blocks.reduce((radius, block, blockIndex) => {
      this.drawBlock(radius, block, blockIndex)
      return radius - this.getLength(block.padding && block.padding.split(' ')[0])
    }, this.Radius)
    // 计算起始弧度
    this.prizeDeg = 360 / this.prizes.length
    this.prizeAng = getAngle(this.prizeDeg)
    const shortSide = this.prizeRadius * Math.sin(this.prizeAng / 2) * 2
    // 起始角度调整到正上方, 并且减去半个扇形角度
    let start = getAngle(this.rotateDeg - 90 + this.prizeDeg / 2 + _defaultConfig.offsetDegree)
    // 计算文字横坐标
    const getFontX = (font: FontItemType, line: string) => {
      return this.getOffsetX(ctx.measureText(line).width) + this.getLength(font.left, shortSide)
    }
    // 计算文字纵坐标
    const getFontY = (font: FontItemType, height: number, lineIndex: number) => {
      // 优先使用字体行高, 要么使用默认行高, 其次使用字体大小, 否则使用默认字体大小
      const lineHeight = font.lineHeight || _defaultStyle.lineHeight || font.fontSize || _defaultStyle.fontSize
      return this.getLength(font.top, height) + (lineIndex + 1) * this.getLength(lineHeight)
    }
    ctx.save()
    // 绘制prizes奖品区域
    this.prizes.forEach((prize, prizeIndex) => {
      // 计算当前奖品区域中间坐标点
      let currMiddleDeg = start + prizeIndex * this.prizeAng
      // 奖品区域可见高度
      let prizeHeight = this.prizeRadius - this.maxBtnRadius
      // 绘制背景
      const background = prize.background || _defaultStyle.background
      if (hasBackground(background)) {
        ctx.fillStyle = background
        fanShapedByArc(
          ctx, this.maxBtnRadius, this.prizeRadius,
          currMiddleDeg - this.prizeAng / 2,
          currMiddleDeg + this.prizeAng / 2,
          this.getLength(_defaultConfig.gutter),
        )
        ctx.fill()
      }
      // 计算临时坐标并旋转文字
      let x = Math.cos(currMiddleDeg) * this.prizeRadius
      let y = Math.sin(currMiddleDeg) * this.prizeRadius
      ctx.translate(x, y)
      ctx.rotate(currMiddleDeg + getAngle(90))
      // 绘制图片
      prize.imgs && prize.imgs.forEach((imgInfo, imgIndex) => {
        const prizeImg = this.ImageCache.get(imgInfo.src)
        if (!prizeImg) return
        const [trueWidth, trueHeight] = this.computedWidthAndHeight(
          prizeImg,
          imgInfo,
          this.prizeAng * this.prizeRadius,
          prizeHeight
        )
        const [xAxis, yAxis] = [
          this.getOffsetX(trueWidth) + this.getLength(imgInfo.left, shortSide),
          this.getLength(imgInfo.top, prizeHeight)
        ]
        this.drawImage(ctx, prizeImg, xAxis, yAxis, trueWidth, trueHeight)
      })
      // 逐行绘制文字
      prize.fonts && prize.fonts.forEach(font => {
        const fontColor = font.fontColor || _defaultStyle.fontColor
        const fontWeight = font.fontWeight || _defaultStyle.fontWeight
        const fontSize = this.getLength(font.fontSize || _defaultStyle.fontSize)
        const fontStyle = font.fontStyle || _defaultStyle.fontStyle
        const wordWrap = has(font, 'wordWrap') ? font.wordWrap : _defaultStyle.wordWrap
        const lengthLimit = font.lengthLimit || _defaultStyle.lengthLimit
        const lineClamp = font.lineClamp || _defaultStyle.lineClamp
        ctx.fillStyle = fontColor
        ctx.font = `${fontWeight} ${fontSize >> 0}px ${fontStyle}`
        let lines = [], text = String(font.text)
        if (wordWrap) {
          lines = splitText(ctx, removeEnter(text), (lines) => {
            // 三角形临边
            const adjacentSide = this.prizeRadius - getFontY(font, prizeHeight, lines.length)
            // 三角形短边
            const shortSide = adjacentSide * Math.tan(this.prizeAng / 2)
            // 最大宽度
            let maxWidth = shortSide * 2 - this.getLength(_defaultConfig.gutter)
            return this.getLength(lengthLimit, maxWidth)
          }, lineClamp)
        } else {
          lines = text.split('\n')
        }
        lines.filter(line => !!line).forEach((line, lineIndex) => {
          ctx.fillText(line, getFontX(font, line), getFontY(font, prizeHeight, lineIndex))
        })
      })
      // 修正旋转角度和原点坐标
      ctx.rotate(getAngle(360) - currMiddleDeg - getAngle(90))
      ctx.translate(-x, -y)
    })
    ctx.restore()
    // 绘制按钮
    this.buttons.forEach((btn, btnIndex) => {
      let radius = this.getLength(btn.radius, this.prizeRadius)
      // 绘制背景颜色
      this.maxBtnRadius = Math.max(this.maxBtnRadius, radius)
      if (hasBackground(btn.background)) {
        ctx.beginPath()
        ctx.fillStyle = btn.background as string
        ctx.arc(0, 0, radius, 0, Math.PI * 2, false)
        ctx.fill()
      }
      // 绘制指针
      if (btn.pointer && hasBackground(btn.background)) {
        ctx.beginPath()
        ctx.fillStyle = btn.background as string
        ctx.moveTo(-radius, 0)
        ctx.lineTo(radius, 0)
        ctx.lineTo(0, -radius * 2)
        ctx.closePath()
        ctx.fill()
      }
      // 绘制按钮图片
      btn.imgs && btn.imgs.forEach((imgInfo, imgIndex) => {
        const btnImg = this.ImageCache.get(imgInfo.src)
        if (!btnImg) return
        const [trueWidth, trueHeight] = this.computedWidthAndHeight(btnImg, imgInfo, radius * 2, radius * 2)
        const [xAxis, yAxis] = [this.getOffsetX(trueWidth) + this.getLength(imgInfo.left, radius), this.getLength(imgInfo.top, radius)]
        this.drawImage(ctx, btnImg, xAxis, yAxis, trueWidth, trueHeight)
      })
      // 绘制按钮文字
      btn.fonts && btn.fonts.forEach(font => {
        let fontColor = font.fontColor || _defaultStyle.fontColor
        let fontWeight = font.fontWeight || _defaultStyle.fontWeight
        let fontSize = this.getLength(font.fontSize || _defaultStyle.fontSize)
        let fontStyle = font.fontStyle || _defaultStyle.fontStyle
        ctx.fillStyle = fontColor
        ctx.font = `${fontWeight} ${fontSize >> 0}px ${fontStyle}`
        String(font.text).split('\n').forEach((line, lineIndex) => {
          ctx.fillText(line, getFontX(font, line), getFontY(font, radius, lineIndex))
        })
      })
    })
    // 触发绘制后回调
    config.afterDraw?.call(this, ctx)
  }

  /**
   * 刻舟求剑
   */
  private carveOnGunwaleOfAMovingBoat (): void {
    const { _defaultConfig, prizeFlag, prizeDeg, rotateDeg } = this
    this.endTime = Date.now()
    const stopDeg = this.stopDeg = rotateDeg
    const speed = _defaultConfig.speed
    const stopRange = (Math.random() * prizeDeg - prizeDeg / 2) * this.getLength(_defaultConfig.stopRange)
    let i = 0, prevSpeed = 0, prevDeg = 0
    while (++i) {
      const endDeg = 360 * i - prizeFlag! * prizeDeg - rotateDeg - _defaultConfig.offsetDegree + stopRange - prizeDeg / 2
      let currSpeed = quad.easeOut(this.FPS, stopDeg, endDeg, _defaultConfig.decelerationTime) - stopDeg
      if (currSpeed > speed) {
        this.endDeg = (speed - prevSpeed > currSpeed - speed) ? endDeg : prevDeg
        break
      }
      prevDeg = endDeg
      prevSpeed = currSpeed
    }
  }

  /**
   * 对外暴露: 开始抽奖方法
   */
  public play (): void {
    if (this.step !== 0) return
    // 记录游戏开始时间
    this.startTime = Date.now()
    // 重置中奖索引
    this.prizeFlag = void 0
    // 加速阶段
    this.step = 1
    // 触发回调
    this.config.afterStart?.()
    // 开始游戏
    this.run()
  }

  /**
   * 对外暴露: 缓慢停止方法
   * @param index 中奖索引
   */
  public stop (index?: number): void {
    if (this.step === 0 || this.step === 3) return
    // 如果没有传递中奖索引, 则通过range属性计算一个
    if (!index && index !== 0) {
      const rangeArr = this.prizes.map(item => item.range)
      index = computeRange(rangeArr)
    }
    // 如果index是负数则停止游戏, 反之则传递中奖索引
    if (index < 0) {
      this.step = 0
      this.prizeFlag = -1
    } else {
      this.step = 2
      this.prizeFlag = index % this.prizes.length
    }
  }

  /**
   * 实际开始执行方法
   * @param num 记录帧动画执行多少次
   */
  private run (num: number = 0): void {
    const { rAF, step, prizeFlag, _defaultConfig } = this
    const { accelerationTime, decelerationTime, speed } = _defaultConfig
    // 游戏结束
    if (step === 0) {
      this.endCallback?.(this.prizes.find((prize, index) => index === prizeFlag) || {})
      return
    }
    // 如果等于 -1 就直接停止游戏
    if (prizeFlag === -1) return
    // 计算结束位置
    if (step === 3 && !this.endDeg) this.carveOnGunwaleOfAMovingBoat()
    // 计算时间间隔
    const startInterval = Date.now() - this.startTime
    const endInterval = Date.now() - this.endTime
    let rotateDeg = this.rotateDeg
    // 
    if (step === 1 || startInterval < accelerationTime) { // 加速阶段
      // 记录帧率
      this.FPS = startInterval / num
      const currSpeed = quad.easeIn(startInterval, 0, speed, accelerationTime)
      // 加速到峰值后, 进入匀速阶段
      if (currSpeed === speed) {
        this.step = 2
      }
      rotateDeg = rotateDeg + currSpeed % 360
    } else if (step === 2) { // 匀速阶段
      // 速度保持不变
      rotateDeg = rotateDeg + speed % 360
      // 如果 prizeFlag 有值, 则进入减速阶段
      if (prizeFlag !== void 0 && prizeFlag >= 0) {
        this.step = 3
        // 清空上一次的位置信息
        this.stopDeg = 0
        this.endDeg = 0
      }
    } else if (step === 3) { // 减速阶段
      // 开始缓慢停止
      rotateDeg = quad.easeOut(endInterval, this.stopDeg, this.endDeg, decelerationTime)
      if (endInterval >= decelerationTime) {
        this.step = 0
      }
    } else {
      // 出现异常
      this.stop(-1)
    }
    this.rotateDeg = rotateDeg
    this.draw()
    rAF(this.run.bind(this, num + 1))
  }

  /**
   * 换算渲染坐标
   * @param x
   * @param y
   */
  protected conversionAxis (x: number, y: number): [number, number] {
    const { config } = this
    return [x / config.dpr - this.Radius, y / config.dpr - this.Radius]
  }
}


================================================
FILE: packages/core/src/observer/array.ts
================================================
/**
 * 重写数组的原型方法
 */
const oldArrayProto = Array.prototype
const newArrayProto = Object.create(oldArrayProto)
const methods = ['push', 'pop', 'shift', 'unshift', 'sort', 'splice', 'reverse']
methods.forEach(method => {
  newArrayProto[method] = function (...args: any[]) {
    const res = oldArrayProto[method].apply(this, args)
    const luckyOb = this['__luckyOb__']
    if (['push', 'unshift', 'splice'].includes(method)) luckyOb.walk(this)
    luckyOb.dep.notify()
    return res
  }
})

export { newArrayProto }


================================================
FILE: packages/core/src/observer/dep.ts
================================================
import Watcher from './watcher'

export default class Dep {
  static target: Watcher | null
  private subs: Array<Watcher>

  /**
   * 订阅中心构造器
   */
  constructor () {
    this.subs = []
  }

  /**
   * 收集依赖
   * @param {*} sub 
   */
  public addSub (sub: Watcher) {
    // 此处临时使用includes防重复添加
    if (!this.subs.includes(sub)) {
      this.subs.push(sub)
    }
  }

  /**
   * 派发更新
   */
  public notify () {
    this.subs.forEach(sub => {
      sub.update()
    })
  }
}


================================================
FILE: packages/core/src/observer/index.ts
================================================
import Dep from './dep'
import { hasProto, def } from './utils'
import { newArrayProto } from './array'

export default class Observer {
  value: any
  dep: Dep

  /**
   * 观察者构造器
   * @param value 
   */
  constructor (value: any) {
    // this.value = value
    this.dep = new Dep()
    // 将响应式对象代理到当前value上面, 并且将当前的enumerable设置为false
    def(value, '__luckyOb__', this)
    if (Array.isArray(value)) { // 如果是数组, 则重写原型方法
      if (hasProto) {
        value['__proto__'] = newArrayProto
      } else {
        Object.getOwnPropertyNames(newArrayProto).forEach(key => {
          def(value, key, newArrayProto[key])
        })
      }
    }
    this.walk(value)
  }

  walk (data: object | any[]) {
    Object.keys(data).forEach(key => {
      defineReactive(data, key, data[key])
    })
  }
}

/**
 * 处理响应式
 * @param { Object | Array } data
 */
export function observe (data: any): Observer | void {
  if (!data || typeof data !== 'object') return
  let luckyOb: Observer | void
  if ('__luckyOb__' in data) {
    luckyOb = data['__luckyOb__']
  } else {
    luckyOb = new Observer(data)
  }
  return luckyOb
}

/**
 * 重写 setter / getter
 * @param {*} data 
 * @param {*} key 
 * @param {*} val 
 */
export function defineReactive (data: any, key: string | number, val: any) {
  const dep = new Dep()
  const property = Object.getOwnPropertyDescriptor(data, key)
  if (property && property.configurable === false) {
    return
  }
  const getter = property && property.get
  const setter = property && property.set
  if ((!getter || setter) && arguments.length === 2) {
    val = data[key]
  }
  let childOb = observe(val)
  Object.defineProperty(data, key, {
    get: () => {
      const value = getter ? getter.call(data) : val
      if (Dep.target) {
        dep.addSub(Dep.target)
        if (childOb) {
          childOb.dep.addSub(Dep.target)
        }
      }
      return value
    },
    set: (newVal) => {
      if (newVal === val) return
      val = newVal
      if (getter && !setter) return
      if (setter) {
        setter.call(data, newVal)
      } else {
        val = newVal
      }
      childOb = observe(newVal)
      dep.notify()
    }
  })
}


================================================
FILE: packages/core/src/observer/utils.ts
================================================

import { isExpectType } from '../utils'

export const hasProto = '__proto__' in {}

export function def (obj: object, key: string | number, val: any, enumerable?: boolean) {
  Object.defineProperty(obj, key, {
    value: val,
    enumerable: !!enumerable,
    writable: true,
    configurable: true
  })
}

export function parsePath (path: string) {
  path += '.'
  let segments: string[] = [], segment = ''
  for (let i = 0; i < path.length; i++) {
    let curr = path[i]
    if (/\[|\./.test(curr)) {
      segments.push(segment)
      segment = ''
    } else if (/\W/.test(curr)) {
      continue
    } else {
      segment += curr
    }
  }
  return function (data: object | any[]) {
    return segments.reduce((data, key) => {
      return data[key]
    }, data)
  }
}

export function traverse (value: any) {
  // const seenObjects = new Set()
  const dfs = (data: any) => {
    if (!isExpectType(data, 'array', 'object')) return
    Object.keys(data).forEach(key => {
      const value = data[key]
      dfs(value)
    })
  }
  dfs(value)
  // seenObjects.clear()
}

================================================
FILE: packages/core/src/observer/watcher.ts
================================================
import Lucky from '../lib/lucky'
import Dep from './dep'
import { parsePath, traverse } from './utils'

export interface WatchOptType {
  handler?: () => Function
  immediate?: boolean
  deep?: boolean
}

let uid = 0
export default class Watcher {
  id: number
  $lucky: Lucky
  expr: string | Function
  cb: Function
  deep: boolean
  getter: Function
  value: any

  /**
   * 观察者构造器
   * @param {*} $lucky 
   * @param {*} expr 
   * @param {*} cb 
   */
  constructor ($lucky: Lucky, expr: string | Function, cb: Function, options: WatchOptType = {}) {
    this.id = uid++
    this.$lucky = $lucky
    this.expr = expr
    this.deep = !!options.deep
    if (typeof expr === 'function') {
      this.getter = expr
    } else {
      this.getter = parsePath(expr)
    }
    this.cb = cb
    this.value = this.get()
  }

  /**
   * 根据表达式获取新值
   */
  get () {
    Dep.target = this
    const value = this.getter.call(this.$lucky, this.$lucky)
    // 处理深度监听
    if (this.deep) {
      traverse(value)
    }
    Dep.target = null
    return value
  }

  /**
   * 触发 watcher 更新
   */
  update () {
    // get获取新值
    const newVal = this.get()
    // 读取之前存储的旧值
    const oldVal = this.value
    this.value = newVal
    // 触发 watch 回调
    this.cb.call(this.$lucky, newVal, oldVal)
  }
}


================================================
FILE: packages/core/src/types/grid.ts
================================================
import {
  FontItemType,
  ImgItemType,
  BorderRadiusType,
  BackgroundType,
  ShadowType,
  FontExtendType
} from './index'

export type PrizeFontType = FontItemType & FontExtendType

export type ButtonFontType = FontItemType & FontExtendType

export type CellFontType = PrizeFontType | ButtonFontType

export type BlockImgType = ImgItemType & {}

export type PrizeImgType = ImgItemType & {
  activeSrc?: string
}

export type ButtonImgType = ImgItemType & {}

export type CellImgType = PrizeImgType | ButtonImgType

export type BlockType = {
  borderRadius?: BorderRadiusType
  background?: BackgroundType
  padding?: string
  paddingTop?: string | number
  paddingRight?: string | number
  paddingBottom?: string | number
  paddingLeft?: string | number
  imgs?: Array<BlockImgType>
}

export type CellType<T, U> = {
  x: number
  y: number
  col?: number
  row?: number
  borderRadius?: BorderRadiusType
  background?: BackgroundType
  shadow?: ShadowType
  fonts?: Array<T>
  imgs?: Array<U>
}

export type PrizeType = CellType<PrizeFontType, PrizeImgType> & {
  range?: number
  disabled?: boolean
}

export type ButtonType = CellType<ButtonFontType, ButtonImgType> & {
  callback?: Function
}

export type DefaultConfigType = {
  gutter?: number
  speed?: number
  accelerationTime?: number
  decelerationTime?: number
}

export type DefaultStyleType = {
  borderRadius?: BorderRadiusType
  background?: BackgroundType
  shadow?: ShadowType
  fontColor?: PrizeFontType['fontColor']
  fontSize?: PrizeFontType['fontSize']
  fontStyle?: PrizeFontType['fontStyle']
  fontWeight?: PrizeFontType['fontWeight']
  lineHeight?: PrizeFontType['lineHeight']
  wordWrap?: PrizeFontType['wordWrap']
  lengthLimit?: PrizeFontType['lengthLimit']
  lineClamp?: PrizeFontType['lineClamp']
}

export type ActiveStyleType = {
  background?: BackgroundType
  shadow?: ShadowType
  fontColor?: PrizeFontType['fontColor']
  fontSize?: PrizeFontType['fontSize']
  fontStyle?: PrizeFontType['fontStyle']
  fontWeight?: PrizeFontType['fontWeight']
  lineHeight?: PrizeFontType['lineHeight']
}

export type RowsType = number
export type ColsType = number
export type StartCallbackType = (e: MouseEvent, button?: ButtonType) => void
export type EndCallbackType = (prize: object) => void

export default interface LuckyGridConfig {
  width: string | number
  height: string | number
  rows?: RowsType
  cols?: ColsType
  blocks?: Array<BlockType>
  prizes?: Array<PrizeType>
  buttons?: Array<ButtonType>
  button?: ButtonType
  defaultConfig?: DefaultConfigType
  defaultStyle?: DefaultStyleType
  activeStyle?: ActiveStyleType
  start?: StartCallbackType
  end?: EndCallbackType
}


================================================
FILE: packages/core/src/types/index.ts
================================================
// 字体类型
export type FontItemType = {
  text: string
  top?: string | number
  left?: string | number
  fontColor?: string
  fontSize?: string
  fontStyle?: string
  fontWeight?: string
  lineHeight?: string
}

export type FontExtendType = {
  wordWrap?: boolean
  lengthLimit?: string | number
  lineClamp?: number
}

export type ImgType = HTMLImageElement | HTMLCanvasElement

// 图片类型
export type ImgItemType = {
  src: string
  top?: string | number
  left?: string | number
  width?: string
  height?: string
  formatter?: (img: ImgType) => ImgType
  $resolve?: Function
  $reject?: Function
}

export type BorderRadiusType = string | number
export type BackgroundType = string
export type ShadowType = string

export type ConfigType = {
  // 临时处理元素类型, 当版本升到4.x之后就可以删掉了
  nodeType?: number
  // 配置
  flag: 'WEB' | 'MP-WX' | 'UNI-H5' | 'UNI-MP' | 'TARO-H5' | 'TARO-MP'
  el?: string
  divElement?: HTMLDivElement
  canvasElement?: HTMLCanvasElement
  ctx: CanvasRenderingContext2D
  dpr: number
  handleCssUnit?: (num: number, unit: string) => number
  // 覆盖方法
  rAF?: Function
  setTimeout: Function
  setInterval: Function
  clearTimeout: Function
  clearInterval: Function
  // 组件生命周期
  beforeCreate?: Function
  beforeResize?: Function
  afterResize?: Function
  beforeInit?: Function
  afterInit?: Function
  beforeDraw?: Function
  afterDraw?: Function
  afterStart?: Function
}

export type UserConfigType = Partial<ConfigType>

export type UniImageType = {
  path: string
  width: number
  height: number
}

export type Tuple<T, Len extends number, Res extends T[] = []> = Res['length'] extends Len ? Res : Tuple<T, Len, [...Res, T]>


================================================
FILE: packages/core/src/types/slot.ts
================================================
import {
  FontItemType,
  ImgItemType,
  BorderRadiusType,
  BackgroundType,
  FontExtendType
} from './index'

export type PrizeFontType = FontItemType & FontExtendType

export type BlockImgType = ImgItemType & {}

export type PrizeImgType = ImgItemType

export type BlockType = {
  borderRadius?: BorderRadiusType
  background?: BackgroundType
  padding?: string
  paddingTop?: string | number
  paddingRight?: string | number
  paddingBottom?: string | number
  paddingLeft?: string | number
  imgs?: Array<BlockImgType>
}

export type PrizeType = {
  borderRadius?: BorderRadiusType
  background?: BackgroundType
  fonts?: Array<PrizeFontType>
  imgs?: Array<PrizeImgType>
}

export type SlotType = {
  order?: number[]
  speed?: number
  direction?: 1 | -1
}

export type DefaultConfigType = {
  /**
   * vertical 为纵向旋转
   * horizontal 为横向旋转
   */
  mode?: 'vertical' | 'horizontal'
  /**
   * 当排列方向 = `vertical`时
   *    1 bottom to top
   *   -1 top to bottom
   * 当排列方向 = `horizontal`时
   *    1 right to left
   *   -1 left to right
   */
  direction?: 1 | -1
  // 行间距
  rowSpacing?: number
  // 列间距
  colSpacing?: number
  // 速度
  speed?: number
  accelerationTime?: number
  decelerationTime?: number
}

export type DefaultStyleType = {
  borderRadius?: BorderRadiusType
  background?: BackgroundType
  fontColor?: PrizeFontType['fontColor']
  fontSize?: PrizeFontType['fontSize']
  fontStyle?: PrizeFontType['fontStyle']
  fontWeight?: PrizeFontType['fontWeight']
  lineHeight?: PrizeFontType['lineHeight']
  wordWrap?: PrizeFontType['wordWrap']
  lengthLimit?: PrizeFontType['lengthLimit']
  lineClamp?: PrizeFontType['lineClamp']
}

export type EndCallbackType = (prize: PrizeType | undefined) => void

export default interface SlotMachineConfig {
  width: string | number
  height: string | number
  blocks?: Array<BlockType>
  prizes?: Array<PrizeType>
  slots?: Array<SlotType>
  defaultConfig?: DefaultConfigType
  defaultStyle?: DefaultStyleType
  end?: EndCallbackType
}


================================================
FILE: packages/core/src/types/wheel.ts
================================================
import {
  FontItemType,
  ImgItemType,
  BackgroundType,
  FontExtendType
} from './index'

export type PrizeFontType = FontItemType & FontExtendType

export type ButtonFontType = FontItemType & {}

export type BlockImgType = ImgItemType & {
  rotate?: boolean
}

export type PrizeImgType = ImgItemType & {}

export type ButtonImgType = ImgItemType & {}

export type BlockType = {
  padding?: string
  background?: BackgroundType
  imgs?: Array<BlockImgType>
}

export type PrizeType = {
  range?: number
  background?: BackgroundType
  fonts?: Array<PrizeFontType>
  imgs?: Array<PrizeImgType>
}

export type ButtonType = {
  radius?: string
  pointer?: boolean
  background?: BackgroundType
  fonts?: Array<ButtonFontType>
  imgs?: Array<ButtonImgType>
}

export type DefaultConfigType = {
  gutter?: string | number
  offsetDegree?: number
  speed?: number
  speedFunction?: string
  accelerationTime?: number
  decelerationTime?: number
  stopRange?: number
}

export type DefaultStyleType = {
  background?: BackgroundType
  fontColor?: PrizeFontType['fontColor']
  fontSize?: PrizeFontType['fontSize']
  fontStyle?: PrizeFontType['fontStyle']
  fontWeight?: PrizeFontType['fontWeight']
  lineHeight?: PrizeFontType['lineHeight']
  wordWrap?: PrizeFontType['wordWrap']
  lengthLimit?: PrizeFontType['lengthLimit']
  lineClamp?: PrizeFontType['lineClamp']
}

export type StartCallbackType = (e: MouseEvent) => void
export type EndCallbackType = (prize: object) => void

export default interface LuckyWheelConfig {
  width: string | number
  height: string | number
  blocks?: Array<BlockType>
  prizes?: Array<PrizeType>
  buttons?: Array<ButtonType>
  defaultConfig?: DefaultConfigType
  defaultStyle?: DefaultStyleType
  start?: StartCallbackType
  end?: EndCallbackType
}


================================================
FILE: packages/core/src/utils/image.ts
================================================
import { ImgType } from '../types/index'
import { roundRectByArc } from './math'

/**
 * 根据路径获取图片对象
 * @param { string } src 图片路径
 * @returns { Promise<HTMLImageElement> } 图片标签
 */
export const getImage = (src: string): Promise<ImgType> => {
  return new Promise((resolve, reject) => {
    const img = new Image()
    img.onload = () => resolve(img)
    img.onerror = err => reject(err)
    img.src = src
  })
}

/**
 * 切割圆角
 * @param img 将要裁剪的图片对象
 * @param radius 裁剪的圆角半径
 * @returns 返回一个离屏 canvas 用于渲染
 */
export const cutRound = (img: ImgType, radius: number): ImgType => {
  const canvas = document.createElement('canvas')
  const ctx = canvas.getContext('2d')!
  const { width, height } = img
  canvas.width = width
  canvas.height = height
  roundRectByArc(ctx, 0, 0, width, height, radius)
  ctx.clip()
  ctx.drawImage(img, 0, 0, width, height)
  return canvas
}

/**
 * 透明度
 * @param img 将要处理的图片对象
 * @param opacity 透明度
 * @returns 返回一个离屏 canvas 用于渲染
 */
export const opacity = (
  img: ImgType,
  opacity: number
): ImgType => {
  const canvas = document.createElement('canvas')
  const ctx = canvas.getContext('2d')!
  const { width, height } = img
  canvas.width = width
  canvas.height = height
  // 绘制图片, 部分浏览器不支持 filter 属性, 需要处理兼容
  if (typeof ctx.filter === 'string') {
    ctx.filter = `opacity(${opacity * 100}%)`
    ctx.drawImage(img, 0, 0, width, height)
  } else {
    ctx.drawImage(img, 0, 0, width, height)
    const imageData = ctx.getImageData(0, 0, width, height)
    const { data } = imageData
    const len = data.length
    for (let i = 0; i < len; i += 4) {
      const alpha = data[i + 3]
      if (alpha !== 0) data[i + 3] = alpha * opacity
    }
    ctx.putImageData(imageData, 0, 0)
  }
  return canvas
}

/**
 * 权重矩阵
 * @param radius 模糊半径
 * @param sigma 
 * @returns 返回一个权重和为1的矩阵
 */
const getMatrix = (radius: number, sigma?: number): number[] => {
  sigma = sigma || radius / 3
  const r = Math.ceil(radius)
  const sigma_2 = sigma * sigma
  const sigma2_2 = 2 * sigma_2
  const denominator = 1 / (2 * Math.PI * sigma_2)
  const matrix = []
  let total = 0
  // 计算权重矩阵
  for (let x = -r; x <= r; x++) {
    for (let y = -r; y <= r; y++) {
      // 套用二维高斯函数得到每个点的权重
      const res = denominator * Math.exp(-(x * x + y * y) / sigma2_2)
      matrix.push(res)
      total += res
    }
  }
  // 让矩阵中所有权重的和等于1
  for (let i = 0; i < matrix.length; i++) {
    matrix[i] /= total
  }
  return matrix
}

/**
 * 高斯模糊
 * @param img 将要处理的图片对象
 * @param radius 模糊半径
 * @returns 返回一个离屏 canvas 用于渲染
 */
export const blur = (
  img: ImgType,
  radius: number
): ImgType => {
  const canvas = document.createElement('canvas')
  const ctx = canvas.getContext('2d')!
  const { width, height } = img
  // 设置图片宽高
  canvas.width = width
  canvas.height = height
  ctx.drawImage(img, 0, 0, width, height)
  const ImageData = ctx.getImageData(0, 0, width, height)
  const { data } = ImageData
  const matrix = getMatrix(radius)
  const r = Math.ceil(radius)
  const w = width * 4
  const cols = r * 2 + 1
  const len = data.length, matrixLen = matrix.length
  for (let i = 0; i < len; i += 4) {
    // 处理
  }
  console.log(ImageData)
  ctx.putImageData(ImageData, 0, 0)
  return canvas
}

export const getBase64Image = () => {

}


================================================
FILE: packages/core/src/utils/index.ts
================================================
/**
 * 判断是否是期望的类型
 * @param { unknown } param 将要判断的变量
 * @param { ...string } types 期望的类型
 * @return { boolean } 返回期望是否正确
 */
export const isExpectType = (param: unknown, ...types: string[]): boolean => {
  return types.some(type => Object.prototype.toString.call(param).slice(8, -1).toLowerCase() === type)
}

export const get = (data: object, strKeys: string) => {
  const keys = strKeys.split('.')
  for (let key of keys) {
    const res = data[key]
    if (!isExpectType(res, 'object', 'array')) return res
    data = res
  }
  return data
}

export const has = (data: object, key: string | number): boolean => {
  return Object.prototype.hasOwnProperty.call(data, key)
}

/**
 * 移除\n
 * @param { string } str 将要处理的字符串
 * @return { string } 返回新的字符串
 */
export const removeEnter = (str: string): string => {
  return [].filter.call(str, s => s !== '\n').join('')
}

/**
 * 把任何数据类型转成数字
 * @param num 
 */
export const getNumber = (num: unknown): number => {
  if (num === null) return 0
  if (typeof num === 'object') return NaN
  if (typeof num === 'number') return num
  if (typeof num === 'string') {
    if (num[num.length - 1] === '%') {
      return Number(num.slice(0, -1)) / 100
    }
    return Number(num)
  }
  return NaN
}

/**
 * 判断颜色是否有效 (透明色 === 无效)
 * @param color 颜色
 */
export const hasBackground = (color: string | undefined | null): boolean => {
  if (typeof color !== 'string') return false
  color = color.toLocaleLowerCase().trim()
  if (color === 'transparent') return false
  if (/^rgba/.test(color)) {
    const alpha = /([^\s,]+)\)$/.exec(color)
    if (getNumber(alpha) === 0) return false
  }
  return true
}

/**
 * 通过padding计算
 * @return { object } block 边框信息
 */
export const computePadding = (
  block: { padding?: string },
  getLength: Function
): [number, number, number, number] => {
  let padding = block.padding?.split(' ').map(n => getLength(n)) || [0],
    paddingTop = 0,
    paddingBottom = 0,
    paddingLeft = 0,
    paddingRight = 0
  switch (padding.length) {
    case 1:
      paddingTop = paddingBottom = paddingLeft = paddingRight = padding[0]
      break
    case 2:
      paddingTop = paddingBottom = padding[0]
      paddingLeft = paddingRight = padding[1]
      break
    case 3:
      paddingTop = padding[0]
      paddingLeft = paddingRight = padding[1]
      paddingBottom = padding[2]
      break
    default:
      paddingTop = padding[0]
      paddingBottom = padding[1]
      paddingLeft = padding[2]
      paddingRight = padding[3]
  }
  // 检查是否单独传入值, 并且不是0
  const res = { paddingTop, paddingBottom, paddingLeft, paddingRight }
  for (let key in res) {
    // 是否含有这个属性, 并且是数字或字符串
    res[key] = has(block, key) && isExpectType(block[key], 'string', 'number')
      ? getLength(block[key])
      : res[key]
  }
  return [paddingTop, paddingBottom, paddingLeft, paddingRight]
}

/**
 * 节流函数
 * @param fn 将要处理的函数
 * @param wait 时间, 单位为毫秒
 * @returns 包装好的节流函数
 */
export const throttle = (fn: Function, wait = 300) => {
  let timeId = null as any
  return function (this: any, ...args: any[]) {
    if (timeId) return
    timeId = setTimeout(() => {
      fn.apply(this, args)
      clearTimeout(timeId)
      timeId = null
    }, wait)
  }
}

/**
 * 通过概率计算出一个奖品索引
 * @param { Array<number | undefined> } rangeArr 概率
 * @returns { number } 中奖索引
 */
export const computeRange = (rangeArr: Array<number | undefined>): number => {
  const ascendingArr: number[] = []
  // 额外增加 map 来优化 ts 的类型推断
  const sum = rangeArr.map(num => Number(num)).reduce((prev, curr) => {
    if (curr > 0) { // 大于0
      const res = prev + curr
      ascendingArr.push(res)
      return res
    } else { // 小于等于0或NaN
      ascendingArr.push(NaN)
      return prev
    }
  }, 0)
  const random = Math.random() * sum
  return ascendingArr.findIndex(num => random <= num)
}

/**
 * 根据宽度分割字符串, 来达到换行的效果
 * @param text 
 * @param maxWidth 
 * @returns 
 */
export const splitText = (
  ctx: CanvasRenderingContext2D,
  text: string,
  getWidth: (lines: string[]) => number,
  lineClamp: number = Infinity
): string[] => {
  // 如果 lineClamp 设置不正确, 则忽略该属性
  if (lineClamp <= 0) lineClamp = Infinity
  let str = ''
  const lines = []
  const EndWidth = ctx.measureText('...').width
  for (let i = 0; i < text.length; i++) {
    str += text[i]
    let currWidth = ctx.measureText(str).width
    const maxWidth = getWidth(lines)
    // 如果正在计算最后一行, 则加上三个小点的宽度
    if (lineClamp === lines.length + 1) currWidth += EndWidth
    // 如果已经没有宽度了, 就没有必要再计算了
    if (maxWidth < 0) return lines
    // 如果当前一行的宽度不够了, 则处理下一行
    if (currWidth > maxWidth) {
      lines.push(str.slice(0, -1))
      str = text[i]
    }
    // 如果现在是最后一行, 则加上三个小点并跳出
    if (lineClamp === lines.length) {
      lines[lines.length - 1] += '...'
      return lines
    }
  }
  if (str) lines.push(str)
  if (!lines.length) lines.push(text)
  return lines
}

// 获取一个重新排序的数组
export const getSortedArrayByIndex = <T>(arr: T[], order: number[]): T[] => {
  const map: { [key: number]: T } = {}, res = []
  for (let i = 0; i < arr.length; i++) {
    map[i] = arr[i]
  }
  for (let i = 0; i < order.length; i++) {
    const curr = map[order[i]]
    if (curr) (res[i] = curr)
  }
  return res
}


================================================
FILE: packages/core/src/utils/math.ts
================================================
/**
 * 转换为运算角度
 * @param { number } deg 数学角度
 * @return { number } 运算角度
 */
export const getAngle = (deg: number): number => {
  return Math.PI / 180 * deg
}

/**
 * 根据角度计算圆上的点
 * @param { number } deg 运算角度
 * @param { number } r 半径
 * @return { Array<number> } 坐标[x, y]
 */
export const getArcPointerByDeg = (deg: number, r: number): [number, number] => {
  return [+(Math.cos(deg) * r).toFixed(8), +(Math.sin(deg) * r).toFixed(8)]
}

/**
 * 根据点计算切线方程
 * @param { number } x 横坐标
 * @param { number } y 纵坐标
 * @return { Array<number> } [斜率, 常数]
 */
export const getTangentByPointer = (x: number, y: number): Array<number> => {
  let k = - x / y
  let b = -k * x + y
  return [k, b]
}

// 使用 arc 绘制扇形
export const fanShapedByArc = (
  ctx: CanvasRenderingContext2D,
  minRadius: number,
  maxRadius: number,
  start: number,
  end: number,
  gutter: number,
): void => {
  ctx.beginPath()
  let maxGutter = getAngle(90 / Math.PI / maxRadius * gutter)
  let minGutter = getAngle(90 / Math.PI / minRadius * gutter)
  let maxStart = start + maxGutter
  let maxEnd = end - maxGutter
  let minStart = start + minGutter
  let minEnd = end - minGutter
  ctx.arc(0, 0, maxRadius, maxStart, maxEnd, false)
  // 如果 getter 比按钮短就绘制圆弧, 反之计算新的坐标点
  // if (minEnd > minStart) {
  //   ctx.arc(0, 0, minRadius, minEnd, minStart, true)
  // } else {
    ctx.lineTo(
      ...getArcPointerByDeg(
        (start + end) / 2,
        gutter / 2 / Math.abs(Math.sin((start - end) / 2))
      )
    )
  // }
  ctx.closePath()
}

// 使用 arc 绘制圆角矩形
export const roundRectByArc = (
  ctx: CanvasRenderingContext2D,
  ...[x, y, w, h, r]: number[]
) => {
  const min = Math.min(w, h), PI = Math.PI
  if (r > min / 2) r = min / 2
  ctx.beginPath()
  ctx.moveTo(x + r, y)
  ctx.lineTo(x + r, y)
  ctx.lineTo(x + w - r, y)
  ctx.arc(x + w - r, y + r, r, -PI / 2, 0)
  ctx.lineTo(x + w, y + h - r)
  ctx.arc(x + w - r, y + h - r, r, 0, PI / 2)
  ctx.lineTo(x + r, y + h)
  ctx.arc(x + r, y + h - r, r, PI / 2, PI)
  ctx.lineTo(x, y + r)
  ctx.arc(x + r, y + r, r, PI, -PI / 2)
  ctx.closePath()
}

/**
 * 创建线性渐变色
 */
export const getLinearGradient = (
  ctx: CanvasRenderingContext2D,
  x: number,
  y: number,
  w: number,
  h: number,
  background: string
) => {
  const context = (/linear-gradient\((.+)\)/.exec(background) as Array<any>)[1]
    .split(',') // 根据逗号分割
    .map((text: string) => text.trim()) // 去除两边空格
  let deg = context.shift(), direction: [number, number, number, number] = [0, 0, 0, 0]
  // 通过起始点和角度计算渐变终点的坐标点, 这里感谢泽宇大神提醒我使用勾股定理....
  if (deg.includes('deg')) {
    deg = deg.slice(0, -3) % 360
    // 根据4个象限定义起点坐标, 根据45度划分8个区域计算终点坐标
    const getLenOfTanDeg = (deg: number) => Math.tan(deg / 180 * Math.PI)
    if (deg >= 0 && deg < 45) direction = [x, y + h, x + w, y + h - w * getLenOfTanDeg(deg - 0)]
    else if (deg >= 45 && deg < 90) direction = [x, y + h, (x + w) - h * getLenOfTanDeg(deg - 45), y]
    else if (deg >= 90 && deg < 135) direction = [x + w, y + h, (x + w) - h * getLenOfTanDeg(deg - 90), y]
    else if (deg >= 135 && deg < 180) direction = [x + w, y + h, x, y + w * getLenOfTanDeg(deg - 135)]
    else if (deg >= 180 && deg < 225) direction = [x + w, y, x, y + w * getLenOfTanDeg(deg - 180)]
    else if (deg >= 225 && deg < 270) direction = [x + w, y, x + h * getLenOfTanDeg(deg - 225), y + h]
    else if (deg >= 270 && deg < 315) direction = [x, y, x + h * getLenOfTanDeg(deg - 270), y + h]
    else if (deg >= 315 && deg < 360) direction = [x, y, x + w, y + h - w * getLenOfTanDeg(deg - 315)]
  }
  // 创建四个简单的方向坐标
  else if (deg.includes('top')) direction = [x, y + h, x, y]
  else if (deg.includes('bottom')) direction = [x, y, x, y + h]
  else if (deg.includes('left')) direction = [x + w, y, x, y]
  else if (deg.includes('right')) direction = [x, y, x + w, y]
  // 创建线性渐变必须使用整数坐标
  const gradient = ctx.createLinearGradient(...(direction.map(n => n >> 0) as typeof direction))
  // 这里后期重构, 先用any代替
  return context.reduce((gradient: any, item: any, index: any) => {
    const info = item.split(' ')
    if (info.length === 1) gradient.addColorStop(index, info[0])
    else if (info.length === 2) gradient.addColorStop(...info)
    return gradient
  }, gradient)
}

// // 根据三点画圆弧
// export const drawRadian = (
//   ctx: CanvasRenderingContext2D,
//   r: number,
//   start: number,
//   end: number,
//   direction: boolean = true
// ) => {
//   // 如果角度大于等于180度, 则分两次绘制, 因为 arcTo 无法绘制180度的圆弧
//   if (Math.abs(end - start).toFixed(8) >= getAngle(180).toFixed(8)) {
//     let middle = (end + start) / 2
//     if (direction) {
//       drawRadian(ctx, r, start, middle, direction)
//       drawRadian(ctx, r, middle, end, direction)
//     } else {
//       drawRadian(ctx, r, middle, end, direction)
//       drawRadian(ctx, r, start, middle, direction)
//     }
//     return false
//   }
//   // 如果方法相反, 则交换起点和终点
//   if (!direction) [start, end] = [end, start]
//   const [x1, y1] = getArcPointerByDeg(start, r)
//   const [x2, y2] = getArcPointerByDeg(end, r)
//   const [k1, b1] = getTangentByPointer(x1, y1)
//   const [k2, b2] = getTangentByPointer(x2, y2)
//   // 计算两条切线的交点
//   let x0 = (b2 - b1) / (k1 - k2)
//   let y0 = (k2 * b1 - k1 * b2) / (k2 - k1)
//   // 如果有任何一条切线垂直于x轴, 则斜率不存在
//   if (isNaN(x0)) {
//     Math.abs(x1) === +r.toFixed(8) && (x0 = x1)
//     Math.abs(x2) === +r.toFixed(8) && (x0 = x2)
//   }
//   if (k1 === Infinity || k1 === -Infinity) {
//     y0 = k2 * x0 + b2
//   }
//   else if (k2 === Infinity || k2 === -Infinity) {
//     y0 = k1 * x0 + b1
//   }
//   ctx.lineTo(x1, y1)
//   // 微信小程序下 arcTo 在安卓真机下绘制有 bug
//   ctx.arcTo(x0, y0, x2, y2, r)
// }

// // 使用 arcTo 绘制扇形 (弃用)
// export const drawSectorByArcTo = (
//   ctx: CanvasRenderingContext2D,
//   minRadius: number,
//   maxRadius: number,
//   start: number,
//   end: number,
//   gutter: number,
// ) => {
//   if (!minRadius) minRadius = gutter
//   // 内外圆弧分别进行等边缩放
//   let maxGutter = getAngle(90 / Math.PI / maxRadius * gutter)
//   let minGutter = getAngle(90 / Math.PI / minRadius * gutter)
//   let maxStart = start + maxGutter
//   let maxEnd = end - maxGutter
//   let minStart = start + minGutter
//   let minEnd = end - minGutter
//   ctx.beginPath()
//   ctx.moveTo(...getArcPointerByDeg(maxStart, maxRadius))
//   drawRadian(ctx, maxRadius, maxStart, maxEnd, true)
//   // 如果 getter 比按钮短就绘制圆弧, 反之计算新的坐标点
//   if (minEnd > minStart) {
//     drawRadian(ctx, minRadius, minStart, minEnd, false)
//   } else {
//     ctx.lineTo(
//       ...getArcPointerByDeg(
//         (start + end) / 2,
//         gutter / 2 / Math.abs(Math.sin((start - end) / 2))
//       )
//     )
//   }
//   ctx.closePath()
// }

// // 使用 arcTo 绘制圆角矩形 (弃用)
// export const roundRectByArcTo = (
//   ctx: CanvasRenderingContext2D,
//   ...[x, y, w, h, r]: number[]
// ) => {
//   let min = Math.min(w, h)
//   if (r > min / 2) r = min / 2
//   ctx.beginPath()
//   ctx.moveTo(x + r, y)
//   ctx.lineTo(x + r, y)
//   ctx.lineTo(x + w - r, y)
//   ctx.arcTo(x + w, y, x + w, y + r, r)
//   ctx.lineTo(x + w, y + h - r)
//   ctx.arcTo(x + w, y + h, x + w - r, y + h, r)
//   ctx.lineTo(x + r, y + h)
//   ctx.arcTo(x, y + h, x, y + h - r, r)
//   ctx.lineTo(x, y + r)
//   ctx.arcTo(x, y, x + r, y, r)
// }


================================================
FILE: packages/core/src/utils/polyfill.js
================================================
/**
 * 由于部分低版本下的某些 app 可能会缺少某些原型方法, 这里增加兼容
 */

// ie11 不兼容 includes 方法
if (!Array.prototype.includes) {
  Object.defineProperty(Array.prototype, 'includes', {
    value: function(valueToFind, fromIndex) {

      if (this == null) {
        throw new TypeError('"this" is null or not defined');
      }

      // 1. Let O be ? ToObject(this value).
      var o = Object(this);

      // 2. Let len be ? ToLength(? Get(O, "length")).
      var len = o.length >>> 0;

      // 3. If len is 0, return false.
      if (len === 0) {
        return false;
      }

      // 4. Let n be ? ToInteger(fromIndex).
      //    (If fromIndex is undefined, this step produces the value 0.)
      var n = fromIndex | 0;

      // 5. If n ≥ 0, then
      //  a. Let k be n.
      // 6. Else n < 0,
      //  a. Let k be len + n.
      //  b. If k < 0, let k be 0.
      var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);

      function sameValueZero(x, y) {
        return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y));
      }

      // 7. Repeat, while k < len
      while (k < len) {
        // a. Let elementK be the result of ? Get(O, ! ToString(k)).
        // b. If SameValueZero(valueToFind, elementK) is true, return true.
        if (sameValueZero(o[k], valueToFind)) {
          return true;
        }
        // c. Increase k by 1.
        k++;
      }

      // 8. Return false
      return false;
    }
  });
}

// vivo x7 下网易云游戏 app 缺少 includes 方法
if (!String.prototype.includes) {
  String.prototype.includes = function(search, start) {
    'use strict';
    if (typeof start !== 'number') {
      start = 0;
    }
    if (start + search.length > this.length) {
      return false;
    } else {
      return this.indexOf(search, start) !== -1;
    }
  };
}

// vivo x7 下网易云游戏 app 缺少 find 方法
if (!Array.prototype.find) {
  Object.defineProperty(Array.prototype, 'find', {
    value: function(predicate) {
     // 1. Let O be ? ToObject(this value).
      if (this == null) {
        throw new TypeError('"this" is null or not defined');
      }
      var o = Object(this);
      // 2. Let len be ? ToLength(? Get(O, "length")).
      var len = o.length >>> 0;
      // 3. If IsCallable(predicate) is false, throw a TypeError exception.
      if (typeof predicate !== 'function') {
        throw new TypeError('predicate must be a function');
      }
      // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
      var thisArg = arguments[1];
      // 5. Let k be 0.
      var k = 0;
      // 6. Repeat, while k < len
      while (k < len) {
        // a. Let Pk be ! ToString(k).
        // b. Let kValue be ? Get(O, Pk).
        // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
        // d. If testResult is true, return kValue.
        var kValue = o[k];
        if (predicate.call(thisArg, kValue, k, o)) {
          return kValue;
        }
        // e. Increase k by 1.
        k++;
      }
      // 7. Return undefined.
      return void 0;
    }
  });
}


================================================
FILE: packages/core/src/utils/tween.ts
================================================
/**
 * 缓动函数
 * t: current time(当前时间)
 * b: beginning value(初始值)
 * c: change in value(变化量)
 * d: duration(持续时间)
 * 
 * 感谢张鑫旭大佬 https://github.com/zhangxinxu/Tween
 */

interface SpeedType {
  easeIn: (...arr: number[]) => number
  easeOut: (...arr: number[]) => number
}

// 二次方的缓动
export const quad: SpeedType = {
  easeIn: function (t, b, c, d) {
    if (t >= d) t = d
    return c * (t /= d) * t + b
  },
  easeOut: function (t, b, c, d) {
    if (t >= d) t = d
    return -c * (t /= d) * (t - 2) + b
  }
}

// 三次方的缓动
export const cubic: SpeedType = {
  easeIn: function (t, b, c, d) {
    if (t >= d) t = d
    return c * (t /= d) * t * t + b
  },
  easeOut: function (t, b, c, d) {
    if (t >= d) t = d
    return c * ((t = t / d - 1) * t * t + 1) + b
  }
}

// 四次方的缓动
export const quart: SpeedType = {
  easeIn: function (t, b, c, d) {
    if (t >= d) t = d
    return c * (t /= d) * t * t * t + b
  },
  easeOut: function (t, b, c, d) {
    if (t >= d) t = d
    return -c * ((t = t / d - 1) * t * t * t - 1) + b
  }
}

// 五次方的缓动
export const quint: SpeedType = {
  easeIn: function (t, b, c, d) {
    if (t >= d) t = d
    return c * (t /= d) * t * t * t * t + b
  },
  easeOut: function (t, b, c, d) {
    if (t >= d) t = d
    return c * ((t = t / d - 1) * t * t * t * t + 1) + b
  }
}

// 正弦曲线的缓动
export const sine: SpeedType = {
  easeIn: function (t, b, c, d) {
    if (t >= d) t = d
    return -c * Math.cos(t / d * (Math.PI / 2)) + c + b
  },
  easeOut: function (t, b, c, d) {
    if (t >= d) t = d
    return c * Math.sin(t / d * (Math.PI / 2)) + b
  }
}

// 指数曲线的缓动
export const expo: SpeedType = {
  easeIn: function (t, b, c, d) {
    if (t >= d) t = d
    return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b
  },
  easeOut: function (t, b, c, d) {
    if (t >= d) t = d
    return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b
  }
}

// 圆形曲线的缓动
export const circ: SpeedType = {
  easeIn: function (t, b, c, d) {
    if (t >= d) t = d
    return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b
  },
  easeOut: function (t, b, c, d) {
    if (t >= d) t = d
    return c * Math.sqrt(1 - (t = t / d - 1) * t) + b
  }
}


================================================
FILE: packages/core/tsconfig.json
================================================
{
  "compilerOptions": {
    "target": "es5", // 编译后的es版本
    "module": "esnext", // 前端模块化规范
    "allowJs": true, // 允许引入js文件
    "strict": true, // 开启严格模式
    "importHelpers": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "suppressImplicitAnyIndexErrors": true,
    "resolveJsonModule": true,
    "sourceMap": true,
    "declaration": true
  },
  "exclude": [
    "node_modules/**"
  ],
  "include": [
    "src/**/*"
  ]
}


================================================
FILE: packages/core/types/index.d.ts
================================================
declare type FontItemType = {
    text: string;
    top?: string | number;
    left?: string | number;
    fontColor?: string;
    fontSize?: string;
    fontStyle?: string;
    fontWeight?: string;
    lineHeight?: string;
};
declare type FontExtendType = {
    wordWrap?: boolean;
    lengthLimit?: string | number;
    lineClamp?: number;
};
declare type ImgType = HTMLImageElement | HTMLCanvasElement;
declare type ImgItemType = {
    src: string;
    top?: string | number;
    left?: string | number;
    width?: string;
    height?: string;
    formatter?: (img: ImgType) => ImgType;
    $resolve?: Function;
    $reject?: Function;
};
declare type BorderRadiusType = string | number;
declare type BackgroundType = string;
declare type ShadowType = string;
declare type ConfigType = {
    nodeType?: number;
    flag: 'WEB' | 'MP-WX' | 'UNI-H5' | 'UNI-MP' | 'TARO-H5' | 'TARO-MP';
    el?: string;
    divElement?: HTMLDivElement;
    canvasElement?: HTMLCanvasElement;
    ctx: CanvasRenderingContext2D;
    dpr: number;
    handleCssUnit?: (num: number, unit: string) => number;
    rAF?: Function;
    setTimeout: Function;
    setInterval: Function;
    clearTimeout: Function;
    clearInterval: Function;
    beforeCreate?: Function;
    beforeResize?: Function;
    afterResize?: Function;
    beforeInit?: Function;
    afterInit?: Function;
    beforeDraw?: Function;
    afterDraw?: Function;
    afterStart?: Function;
};
declare type UserConfigType = Partial<ConfigType>;
declare type Tuple<T, Len extends number, Res extends T[] = []> = Res['length'] extends Len ? Res : Tuple<T, Len, [...Res, T]>;

interface WatchOptType {
    handler?: () => Function;
    immediate?: boolean;
    deep?: boolean;
}

declare class Lucky {
    static version: string;
    protected readonly version: string;
    protected readonly config: ConfigType;
    protected readonly ctx: CanvasRenderingContext2D;
    protected htmlFontSize: number;
    protected rAF: Function;
    protected boxWidth: number;
    protected boxHeight: number;
    protected data: {
        width: string | number;
        height: string | number;
    };
    /**
     * 公共构造器
     * @param config
     */
    constructor(config: string | HTMLDivElement | UserConfigType, data: {
        width: string | number;
        height: string | number;
    });
    /**
     * 初始化组件大小/单位
     */
    protected resize(): void;
    /**
     * 初始化方法
     */
    protected initLucky(): void;
    /**
     * 鼠标点击事件
     * @param e 事件参数
     */
    protected handleClick(e: MouseEvent): void;
    /**
     * 根标签的字体大小
     */
    protected setHTMLFontSize(): void;
    clearCanvas(): void;
    /**
     * 设备像素比
     * window 环境下自动获取, 其余环境手动传入
     */
    protected setDpr(): void;
    /**
     * 重置盒子和canvas的宽高
     */
    private resetWidthAndHeight;
    /**
     * 根据 dpr 缩放 canvas 并处理位移
     */
    protected zoomCanvas(): void;
    /**
     * 从 window 对象上获取一些方法
     */
    private initWindowFunction;
    isWeb(): boolean;
    /**
     * 异步加载图片并返回图片的几何信息
     * @param src 图片路径
     * @param info 图片信息
     */
    protected loadImg(src: string, info: ImgItemType, resolveName?: string): Promise<ImgType>;
    /**
     * 公共绘制图片的方法
     * @param imgObj 图片对象
     * @param rectInfo: [x轴位置, y轴位置, 渲染宽度, 渲染高度]
     */
    protected drawImage(ctx: CanvasRenderingContext2D, imgObj: ImgType, ...rectInfo: [...Tuple<number, 4>, ...Partial<Tuple<number, 4>>]): void;
    /**
     * 计算图片的渲染宽高
     * @param imgObj 图片标签元素
     * @param imgInfo 图片信息
     * @param maxWidth 最大宽度
     * @param maxHeight 最大高度
     * @return [渲染宽度, 渲染高度]
     */
    protected computedWidthAndHeight(imgObj: ImgType, imgInfo: ImgItemType, maxWidth: number, maxHeight: number): [number, number];
    /**
     * 转换单位
     * @param { string } value 将要转换的值
     * @param { number } denominator 分子
     * @return { number } 返回新的字符串
     */
    protected changeUnits(value: string, denominator?: number): number;
    /**
     * 获取长度
     * @param length 将要转换的长度
     * @param maxLength 最大长度
     * @return 返回长度
     */
    protected getLength(length: string | number | undefined, maxLength?: number): number;
    /**
     * 获取相对(居中)X坐标
     * @param width
     * @param col
     */
    protected getOffsetX(width: number, maxWidth?: number): number;
    protected getOffscreenCanvas(width: number, height: number): {
        _offscreenCanvas: HTMLCanvasElement;
        _ctx: CanvasRenderingContext2D;
    } | void;
    /**
     * 添加一个新的响应式数据 (临时)
     * @param data 数据
     * @param key 属性
     * @param value 新值
     */
    $set(data: object, key: string | number, value: any): void;
    /**
     * 添加一个属性计算 (临时)
     * @param data 源数据
     * @param key 属性名
     * @param callback 回调函数
     */
    protected $computed(data: object, key: string, callback: Function): void;
    /**
     * 添加一个观察者 create user watcher
     * @param expr 表达式
     * @param handler 回调函数
     * @param watchOpt 配置参数
     * @return 卸载当前观察者的函数 (暂未返回)
     */
    protected $watch(expr: string | Function, handler: Function | WatchOptType, watchOpt?: WatchOptType): Function;
}

declare type PrizeFontType$2 = FontItemType & FontExtendType;
declare type ButtonFontType$1 = FontItemType & {};
declare type BlockImgType$2 = ImgItemType & {
    rotate?: boolean;
};
declare type PrizeImgType$2 = ImgItemType & {};
declare type ButtonImgType$1 = ImgItemType & {};
declare type BlockType$2 = {
    padding?: string;
    background?: BackgroundType;
    imgs?: Array<BlockImgType$2>;
};
declare type PrizeType$2 = {
    range?: number;
    background?: BackgroundType;
    fonts?: Array<PrizeFontType$2>;
    imgs?: Array<PrizeImgType$2>;
};
declare type ButtonType$1 = {
    radius?: string;
    pointer?: boolean;
    background?: BackgroundType;
    fonts?: Array<ButtonFontType$1>;
    imgs?: Array<ButtonImgType$1>;
};
declare type DefaultConfigType$2 = {
    gutter?: string | number;
    offsetDegree?: number;
    speed?: number;
    speedFunction?: string;
    accelerationTime?: number;
    decelerationTime?: number;
    stopRange?: number;
};
declare type DefaultStyleType$2 = {
    background?: BackgroundType;
    fontColor?: PrizeFontType$2['fontColor'];
    fontSize?: PrizeFontType$2['fontSize'];
    fontStyle?: PrizeFontType$2['fontStyle'];
    fontWeight?: PrizeFontType$2['fontWeight'];
    lineHeight?: PrizeFontType$2['lineHeight'];
    wordWrap?: PrizeFontType$2['wordWrap'];
    lengthLimit?: PrizeFontType$2['lengthLimit'];
    lineClamp?: PrizeFontType$2['lineClamp'];
};
declare type StartCallbackType$1 = (e: MouseEvent) => void;
declare type EndCallbackType$2 = (prize: object) => void;
interface LuckyWheelConfig {
    width: string | number;
    height: string | number;
    blocks?: Array<BlockType$2>;
    prizes?: Array<PrizeType$2>;
    buttons?: Array<ButtonType$1>;
    defaultConfig?: DefaultConfigType$2;
    defaultStyle?: DefaultStyleType$2;
    start?: StartCallbackType$1;
    end?: EndCallbackType$2;
}

declare class LuckyWheel extends Lucky {
    private blocks;
    private prizes;
    private buttons;
    private defaultConfig;
    private defaultStyle;
    private _defaultConfig;
    private _defaultStyle;
    private startCallback?;
    private endCallback?;
    private Radius;
    private prizeRadius;
    private prizeDeg;
    private prizeAng;
    private rotateDeg;
    private maxBtnRadius;
    private startTime;
    private endTime;
    private stopDeg;
    private endDeg;
    private FPS;
    /**
     * 游戏当前的阶段
     * step = 0 时, 游戏尚未开始
     * step = 1 时, 此时处于加速阶段
     * step = 2 时, 此时处于匀速阶段
     * step = 3 时, 此时处于减速阶段
     */
    private step;
    /**
     * 中奖索引
     * prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
     * prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
     * prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
     */
    private prizeFlag;
    private ImageCache;
    /**
     * 大转盘构造器
     * @param config 配置项
     * @param data 抽奖数据
     */
    constructor(config: UserConfigType, data: LuckyWheelConfig);
    protected resize(): void;
    protected initLucky(): void;
    /**
     * 初始化数据
     * @param data
     */
    private initData;
    /**
     * 初始化属性计算
     */
    private initComputed;
    /**
     * 初始化观察者
     */
    private initWatch;
    /**
     * 初始化 canvas 抽奖
     */
    init(): Promise<void>;
    private initImageCache;
    /**
     * canvas点击事件
     * @param e 事件参数
     */
    protected handleClick(e: MouseEvent): void;
    /**
     * 根据索引单独加载指定图片并缓存
     * @param cellName 模块名称
     * @param cellIndex 模块索引
     * @param imgName 模块对应的图片缓存
     * @param imgIndex 图片索引
     */
    private loadAndCacheImg;
    private drawBlock;
    /**
     * 开始绘制
     */
    protected draw(): void;
    /**
     * 刻舟求剑
     */
    private carveOnGunwaleOfAMovingBoat;
    /**
     * 对外暴露: 开始抽奖方法
     */
    play(): void;
    /**
     * 对外暴露: 缓慢停止方法
     * @param index 中奖索引
     */
    stop(index?: number): void;
    /**
     * 实际开始执行方法
     * @param num 记录帧动画执行多少次
     */
    private run;
    /**
     * 换算渲染坐标
     * @param x
     * @param y
     */
    protected conversionAxis(x: number, y: number): [number, number];
}

declare type PrizeFontType$1 = FontItemType & FontExtendType;
declare type ButtonFontType = FontItemType & FontExtendType;
declare type BlockImgType$1 = ImgItemType & {};
declare type PrizeImgType$1 = ImgItemType & {
    activeSrc?: string;
};
declare type ButtonImgType = ImgItemType & {};
declare type BlockType$1 = {
    borderRadius?: BorderRadiusType;
    background?: BackgroundType;
    padding?: string;
    paddingTop?: string | number;
    paddingRight?: string | number;
    paddingBottom?: string | number;
    paddingLeft?: string | number;
    imgs?: Array<BlockImgType$1>;
};
declare type CellType<T, U> = {
    x: number;
    y: number;
    col?: number;
    row?: number;
    borderRadius?: BorderRadiusType;
    background?: BackgroundType;
    shadow?: ShadowType;
    fonts?: Array<T>;
    imgs?: Array<U>;
};
declare type PrizeType$1 = CellType<PrizeFontType$1, PrizeImgType$1> & {
    range?: number;
    disabled?: boolean;
};
declare type ButtonType = CellType<ButtonFontType, ButtonImgType> & {
    callback?: Function;
};
declare type DefaultConfigType$1 = {
    gutter?: number;
    speed?: number;
    accelerationTime?: number;
    decelerationTime?: number;
};
declare type DefaultStyleType$1 = {
    borderRadius?: BorderRadiusType;
    background?: BackgroundType;
    shadow?: ShadowType;
    fontColor?: PrizeFontType$1['fontColor'];
    fontSize?: PrizeFontType$1['fontSize'];
    fontStyle?: PrizeFontType$1['fontStyle'];
    fontWeight?: PrizeFontType$1['fontWeight'];
    lineHeight?: PrizeFontType$1['lineHeight'];
    wordWrap?: PrizeFontType$1['wordWrap'];
    lengthLimit?: PrizeFontType$1['lengthLimit'];
    lineClamp?: PrizeFontType$1['lineClamp'];
};
declare type ActiveStyleType = {
    background?: BackgroundType;
    shadow?: ShadowType;
    fontColor?: PrizeFontType$1['fontColor'];
    fontSize?: PrizeFontType$1['fontSize'];
    fontStyle?: PrizeFontType$1['fontStyle'];
    fontWeight?: PrizeFontType$1['fontWeight'];
    lineHeight?: PrizeFontType$1['lineHeight'];
};
declare type RowsType = number;
declare type ColsType = number;
declare type StartCallbackType = (e: MouseEvent, button?: ButtonType) => void;
declare type EndCallbackType$1 = (prize: object) => void;
interface LuckyGridConfig {
    width: string | number;
    height: string | number;
    rows?: RowsType;
    cols?: ColsType;
    blocks?: Array<BlockType$1>;
    prizes?: Array<PrizeType$1>;
    buttons?: Array<ButtonType>;
    button?: ButtonType;
    defaultConfig?: DefaultConfigType$1;
    defaultStyle?: DefaultStyleType$1;
    activeStyle?: ActiveStyleType;
    start?: StartCallbackType;
    end?: EndCallbackType$1;
}

declare class LuckyGrid extends Lucky {
    private rows;
    private cols;
    private blocks;
    private prizes;
    private buttons;
    private button?;
    private defaultConfig;
    private defaultStyle;
    private activeStyle;
    private _defaultConfig;
    private _defaultStyle;
    private _activeStyle;
    private startCallback?;
    private endCallback?;
    private cellWidth;
    private cellHeight;
    private startTime;
    private endTime;
    private currIndex;
    private stopIndex;
    private endIndex;
    private demo;
    private timer;
    private FPS;
    /**
     * 游戏当前的阶段
     * step = 0 时, 游戏尚未开始
     * step = 1 时, 此时处于加速阶段
     * step = 2 时, 此时处于匀速阶段
     * step = 3 时, 此时处于减速阶段
     */
    private step;
    /**
     * 中奖索引
     * prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
     * prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
     * prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
     */
    private prizeFlag;
    private cells;
    private prizeArea;
    private ImageCache;
    /**
     * 九宫格构造器
     * @param config 配置项
     * @param data 抽奖数据
     */
    constructor(config: UserConfigType, data: LuckyGridConfig);
    protected resize(): void;
    protected initLucky(): void;
    /**
     * 初始化数据
     * @param data
     */
    private initData;
    /**
     * 初始化属性计算
     */
    private initComputed;
    /**
     * 初始化观察者
     */
    private initWatch;
    /**
     * 初始化 canvas 抽奖
     */
    init(): Promise<void>;
    private initImageCache;
    /**
     * canvas点击事件
     * @param e 事件参数
     */
    protected handleClick(e: MouseEvent): void;
    /**
     * 根据索引单独加载指定图片并缓存
     * @param cellName 模块名称
     * @param cellIndex 模块索引
     * @param imgName 模块对应的图片缓存
     * @param imgIndex 图片索引
     */
    private loadAndCacheImg;
    /**
     * 绘制九宫格抽奖
     */
    protected draw(): void;
    /**
     * 处理背景色
     * @param x
     * @param y
     * @param width
     * @param height
     * @param background
     * @param isActive
     */
    private handleBackground;
    /**
     * 刻舟求剑
     */
    private carveOnGunwaleOfAMovingBoat;
    /**
     * 对外暴露: 开始抽奖方法
     */
    play(): void;
    /**
     * 对外暴露: 缓慢停止方法
     * @param index 中奖索引
     */
    stop(index?: number): void;
    /**
     * 实际开始执行方法
     * @param num 记录帧动画执行多少次
     */
    private run;
    /**
     * 计算奖品格子的几何属性
     * @param { array } [...矩阵坐标, col, row]
     * @return { array } [...真实坐标, width, height]
     */
    private getGeometricProperty;
    /**
     * 换算渲染坐标
     * @param x
     * @param y
     */
    protected conversionAxis(x: number, y: number): [number, number];
}

declare type PrizeFontType = FontItemType & FontExtendType;
declare type BlockImgType = ImgItemType & {};
declare type PrizeImgType = ImgItemType;
declare type BlockType = {
    borderRadius?: BorderRadiusType;
    background?: BackgroundType;
    padding?: string;
    paddingTop?: string | number;
    paddingRight?: string | number;
    paddingBottom?: string | number;
    paddingLeft?: string | number;
    imgs?: Array<BlockImgType>;
};
declare type PrizeType = {
    borderRadius?: BorderRadiusType;
    background?: BackgroundType;
    fonts?: Array<PrizeFontType>;
    imgs?: Array<PrizeImgType>;
};
declare type SlotType = {
    order?: number[];
    speed?: number;
    direction?: 1 | -1;
};
declare type DefaultConfigType = {
    /**
     * vertical 为纵向旋转
     * horizontal 为横向旋转
     */
    mode?: 'vertical' | 'horizontal';
    /**
     * 当排列方向 = `vertical`时
     *    1 bottom to top
     *   -1 top to bottom
     * 当排列方向 = `horizontal`时
     *    1 right to left
     *   -1 left to right
     */
    direction?: 1 | -1;
    rowSpacing?: number;
    colSpacing?: number;
    speed?: number;
    accelerationTime?: number;
    decelerationTime?: number;
};
declare type DefaultStyleType = {
    borderRadius?: BorderRadiusType;
    background?: BackgroundType;
    fontColor?: PrizeFontType['fontColor'];
    fontSize?: PrizeFontType['fontSize'];
    fontStyle?: PrizeFontType['fontStyle'];
    fontWeight?: PrizeFontType['fontWeight'];
    lineHeight?: PrizeFontType['lineHeight'];
    wordWrap?: PrizeFontType['wordWrap'];
    lengthLimit?: PrizeFontType['lengthLimit'];
    lineClamp?: PrizeFontType['lineClamp'];
};
declare type EndCallbackType = (prize: PrizeType | undefined) => void;
interface SlotMachineConfig {
    width: string | number;
    height: string | number;
    blocks?: Array<BlockType>;
    prizes?: Array<PrizeType>;
    slots?: Array<SlotType>;
    defaultConfig?: DefaultConfigType;
    defaultStyle?: DefaultStyleType;
    end?: EndCallbackType;
}

declare class SlotMachine extends Lucky {
    private blocks;
    private prizes;
    private slots;
    private defaultConfig;
    private _defaultConfig;
    private defaultStyle;
    private _defaultStyle;
    private endCallback;
    private _offscreenCanvas?;
    private cellWidth;
    private cellHeight;
    private cellAndSpacing;
    private widthAndSpacing;
    private heightAndSpacing;
    private FPS;
    private scroll;
    private stopScroll;
    private endScroll;
    private startTime;
    private endTime;
    /**
     * 游戏当前的阶段
     * step = 0 时, 游戏尚未开始
     * step = 1 时, 此时处于加速阶段
     * step = 2 时, 此时处于匀速阶段
     * step = 3 时, 此时处于减速阶段
     */
    private step;
    /**
     * 中奖索引
     * prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
     * prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
     * prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
     */
    private prizeFlag;
    private prizeArea?;
    private ImageCache;
    /**
     * 老虎机构造器
     * @param config 配置项
     * @param data 抽奖数据
     */
    constructor(config: UserConfigType, data: SlotMachineConfig);
    protected resize(): void;
    protected initLucky(): void;
    /**
     * 初始化数据
     * @param data
     */
    private initData;
    /**
     * 初始化属性计算
     */
    private initComputed;
    /**
     * 初始化观察者
     */
    private initWatch;
    /**
     * 初始化 canvas 抽奖
     */
    init(): Promise<void>;
    private initImageCache;
    /**
     * 根据索引单独加载指定图片并缓存
     * @param cellName 模块名称
     * @param cellIndex 模块索引
     * @param imgName 模块对应的图片缓存
     * @param imgIndex 图片索引
     */
    private loadAndCacheImg;
    /**
     * 绘制离屏canvas
     */
    protected drawOffscreenCanvas(): void;
    /**
     * 绘制背景区域
     */
    protected drawBlocks(): SlotMachine['prizeArea'];
    /**
     * 绘制老虎机抽奖
     */
    protected draw(): void;
    /**
     * 刻舟求剑
     */
    private carveOnGunwaleOfAMovingBoat;
    /**
     * 对外暴露: 开始抽奖方法
     */
    play(): void;
    stop(index: number | number[]): void;
    /**
     * 让游戏动起来
     * @param num 记录帧动画执行多少次
     */
    private run;
    private displacement;
    private displacementWidthOrHeight;
}

/**
 * 切割圆角
 * @param img 将要裁剪的图片对象
 * @param radius 裁剪的圆角半径
 * @returns 返回一个离屏 canvas 用于渲染
 */
declare const cutRound: (img: ImgType, radius: number) => ImgType;
/**
 * 透明度
 * @param img 将要处理的图片对象
 * @param opacity 透明度
 * @returns 返回一个离屏 canvas 用于渲染
 */
declare const opacity: (img: ImgType, opacity: number) => ImgType;

export { LuckyGrid, LuckyWheel, SlotMachine, cutRound, opacity };


================================================
FILE: packages/mini/.babelrc
================================================
{
    "plugins": [
        ["module-resolver", {
            "root": ["./src"],
            "alias": {}
        }]
    ],
    "presets": [
        ["env", {"loose": true, "modules": "commonjs"}]
    ]
}

================================================
FILE: packages/mini/.eslintrc.js
================================================
module.exports = {
  'extends': [
    'airbnb-base',
    'plugin:promise/recommended'
  ],
  'parser': '@typescript-eslint/parser',
  'plugins': ['@typescript-eslint'],
  'parserOptions': {
    'ecmaVersion': 9,
    'ecmaFeatures': {
      'jsx': false
    },
    'sourceType': 'module'
  },
  'env': {
    'es6': true,
    'node': true,
    'jest': true
  },
  'plugins': [
    'import',
    'node',
    'promise'
  ],
  'rules': {
    "no-console": "off",
    'arrow-parens': 'off',
    'comma-dangle': [
      'error',
      'only-multiline'
    ],
    'complexity': ['error', 20],
    'func-names': 'off',
    'global-require': 'off',
    'handle-callback-err': [
      'error',
      '^(err|error)$'
    ],
    'import/no-unresolved': [
      'error',
      {
        'caseSensitive': true,
        'commonjs': true,
        'ignore': ['^[^.]']
      }
    ],
    'import/prefer-default-export': 'off',
    'linebreak-style': 'off',
    'no-catch-shadow': 'error',
    'no-continue': 'off',
    'no-div-regex': 'warn',
    'no-else-return': 'off',
    'no-param-reassign': 'off',
    'no-plusplus': 'off',
    'no-shadow': 'off',
    'no-multi-assign': 'off',
    'no-underscore-dangle': 'off',
    'node/no-deprecated-api': 'error',
    'node/process-exit-as-throw': 'error',
    'operator-linebreak': [
      'error',
      'after',
      {
        'overrides': {
          ':': 'before',
          '?': 'before'
        }
      }
    ],
    'prefer-arrow-callback': 'off',
    'prefer-destructuring': 'off',
    'prefer-template': 'off',
    'quote-props': [
      1,
      'as-needed',
      {
        'unnecessary': true
      }
    ],
    'semi': [
      'error',
      'never'
    ],
    'no-await-in-loop': 'off',
    'no-restricted-syntax': 'off',
    'promise/always-return': 'off',
  },
  'globals': {
    'window': true,
    'document': true,
    'App': true,
    'Page': true,
    'Component': true,
    'Behavior': true,
    'wx': true,
    'getCurrentPages': true,
  }
}


================================================
FILE: packages/mini/.gitignore
================================================
.idea
.DS_Store
dist

logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

dev
node_modules
coverage

================================================
FILE: packages/mini/.npmignore
================================================
*

================================================
FILE: packages/mini/LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [2021] [Li Dong Qi]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: packages/mini/README.md
================================================

<div align="center">
  <img src="https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.jpg" width="210" alt="logo" />
  <h1>微信小程序 抽奖组件</h1>
  <p>一个基于微信小程序的 ( 大转盘 / 九宫格 / 老虎机 ) 抽奖插件</p>
  <p>
    <a href="https://github.com/buuing/lucky-canvas/stargazers" target="_black">
      <img src="https://img.shields.io/github/stars/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="stars" />
    </a>
    <a href="https://github.com/buuing/lucky-canvas/network/members" target="_black">
      <img src="https://img.shields.io/github/forks/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="forks" />
    </a>
    <a href="https://github.com/buuing" target="_black">
      <img src="https://img.shields.io/badge/Author-%20buuing%20-7289da.svg?&logo=github&style=flat-square" alt="author" />
    </a>
    <a href="https://github.com/buuing/lucky-canvas/blob/master/LICENSE" target="_black">
      <img src="https://img.shields.io/github/license/buuing/lucky-canvas?color=%232dce89&logo=github&style=flat-square" alt="license" />
    </a>
  </p>
</div>

<br />

## 文档 - Document

- **中文**:[https://100px.net](https://100px.net)

<br />

## 使用 - Usage

- [**在 微信小程序 中使用**](https://100px.net/usage/wx.html)

<br />

## 🙏🙏🙏 点个Star

**如果您觉得这个项目还不错, 可以在 [Github](https://github.com/buuing/lucky-canvas) 上面帮我点个`star`, 支持一下作者 ☜(゚ヮ゚☜)**

<br />


================================================
FILE: packages/mini/gulpfile.js
================================================
const gulp = require('gulp')
const clean = require('gulp-clean')

const config = require('./tools/config')
const BuildTask = require('./tools/build')
const id = require('./package.json').name || 'miniprogram-custom-component'

// 构建任务实例
// eslint-disable-next-line no-new
new BuildTask(id, config.entry)

// 清空生成目录和文件
gulp.task('clean', gulp.series(() => gulp.src(config.distPath, {read: false, allowEmpty: true}).pipe(clean()), done => {
  if (config.isDev) {
    return gulp.src(config.demoDist, {read: false, allowEmpty: true})
      .pipe(clean())
  }

  return done()
}))
// 监听文件变化并进行开发模式构建
gulp.task('watch', gulp.series(`${id}-watch`))
// 开发模式构建
gulp.task('dev', gulp.series(`${id}-dev`))
// 生产模式构建
gulp.task('default', gulp.series(`${id}-default`))


================================================
FILE: packages/mini/package.json
================================================
{
  "name": "@lucky-canvas/mini",
  "version": "0.0.8",
  "description": "",
  "main": "dist/index.js",
  "scripts": {
    "dev": "gulp dev --develop --watch",
    "build": "gulp",
    "dist": "npm run build",
    "clean-dev": "gulp clean --develop",
    "clean": "gulp clean",
    "test": "jest --bail",
    "test-debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --bail",
    "coverage": "jest ./test/* --coverage --bail",
    "lint": "eslint \"src/**/*.js\" --fix",
    "lint-tools": "eslint \"tools/**/*.js\" --rule \"import/no-extraneous-dependencies: false\" --fix"
  },
  "files": [
    "dist"
  ],
  "miniprogram": "dist",
  "jest": {
    "testEnvironment": "jsdom",
    "testURL": "https://jest.test",
    "collectCoverageFrom": [
      "dist/**/*.js"
    ],
    "moduleDirectories": [
      "node_modules",
      "dist"
    ]
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "ldq",
  "license": "Apache-2.0",
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.28.0",
    "@typescript-eslint/parser": "^2.28.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-plugin-module-resolver": "^3.2.0",
    "babel-preset-env": "^1.7.0",
    "colors": "^1.3.1",
    "eslint": "^5.14.1",
    "eslint-config-airbnb-base": "13.1.0",
    "eslint-loader": "^2.1.2",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-node": "^7.0.1",
    "eslint-plugin-promise": "^3.8.0",
    "gulp": "^4.0.0",
    "gulp-clean": "^0.4.0",
    "gulp-if": "^2.0.2",
    "gulp-install": "^1.1.0",
    "gulp-less": "^4.0.1",
    "gulp-rename": "^1.4.0",
    "gulp-sourcemaps": "^2.6.5",
    "jest": "^23.5.0",
    "miniprogram-api-typings": "^2.10.3-1",
    "miniprogram-simulate": "^1.2.5",
    "thread-loader": "^2.1.3",
    "through2": "^2.0.3",
    "ts-loader": "^7.0.0",
    "typescript": "^3.8.3",
    "vinyl": "^2.2.0",
    "webpack": "^4.29.5",
    "webpack-node-externals": "^1.7.2"
  },
  "dependencies": {
    "lucky-canvas": "~1.7.24"
  }
}


================================================
FILE: packages/mini/src/lucky-grid/index.js
================================================
import { LuckyGrid } from 'lucky-canvas'
import { changeUnits, resolveImage, getImage } from '../utils'

Component({
  properties: {
    width: { type: String, value: '600rpx' },
    height: { type: String, value: '600rpx' },
    rows: { type: String, optionalTypes: [Number], value: '3' },
    cols: { type: String, optionalTypes: [Number], value: '3' },
    blocks: { type: Array, value: [] },
    prizes: { type: Array, value: [] },
    buttons: { type: Array, value: [] },
    defaultConfig: { type: Object, value: 
Download .txt
gitextract_o394m47x/

├── .github/
│   └── ISSUE_TEMPLATE.md
├── .gitignore
├── LICENSE
├── README.md
├── lerna.json
├── package.json
└── packages/
    ├── core/
    │   ├── .babelrc
    │   ├── .eslintrc.js
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── examples/
    │   │   ├── grid.html
    │   │   ├── index.html
    │   │   ├── slot.html
    │   │   └── wheel.html
    │   ├── index.js
    │   ├── package.json
    │   ├── postinstall.js
    │   ├── rollup.config.build.js
    │   ├── rollup.config.dev.js
    │   ├── src/
    │   │   ├── index.ts
    │   │   ├── lib/
    │   │   │   ├── grid.ts
    │   │   │   ├── lucky.ts
    │   │   │   ├── slot.ts
    │   │   │   └── wheel.ts
    │   │   ├── observer/
    │   │   │   ├── array.ts
    │   │   │   ├── dep.ts
    │   │   │   ├── index.ts
    │   │   │   ├── utils.ts
    │   │   │   └── watcher.ts
    │   │   ├── types/
    │   │   │   ├── grid.ts
    │   │   │   ├── index.ts
    │   │   │   ├── slot.ts
    │   │   │   └── wheel.ts
    │   │   └── utils/
    │   │       ├── image.ts
    │   │       ├── index.ts
    │   │       ├── math.ts
    │   │       ├── polyfill.js
    │   │       └── tween.ts
    │   ├── tsconfig.json
    │   └── types/
    │       └── index.d.ts
    ├── mini/
    │   ├── .babelrc
    │   ├── .eslintrc.js
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── gulpfile.js
    │   ├── package.json
    │   ├── src/
    │   │   ├── lucky-grid/
    │   │   │   ├── index.js
    │   │   │   ├── index.json
    │   │   │   ├── index.wxml
    │   │   │   └── index.wxss
    │   │   ├── lucky-wheel/
    │   │   │   ├── index.js
    │   │   │   ├── index.json
    │   │   │   ├── index.wxml
    │   │   │   └── index.wxss
    │   │   ├── slot-machine/
    │   │   │   ├── index.js
    │   │   │   ├── index.json
    │   │   │   ├── index.wxml
    │   │   │   └── index.wxss
    │   │   └── utils.js
    │   ├── test/
    │   │   ├── index.test.js
    │   │   ├── utils.js
    │   │   └── wx.test.js
    │   ├── tools/
    │   │   ├── build.js
    │   │   ├── checkcomponents.js
    │   │   ├── checkwxss.js
    │   │   ├── config.js
    │   │   ├── demo/
    │   │   │   ├── app.js
    │   │   │   ├── app.json
    │   │   │   ├── app.wxss
    │   │   │   ├── package.json
    │   │   │   ├── pages/
    │   │   │   │   ├── cjl/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── index/
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── jd/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── slot/
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── xc/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── xdf/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── ymc/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── yx/
    │   │   │   │   │   ├── img.js
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   ├── yyjk/
    │   │   │   │   │   ├── index.js
    │   │   │   │   │   ├── index.json
    │   │   │   │   │   ├── index.wxml
    │   │   │   │   │   └── index.wxss
    │   │   │   │   └── yyx/
    │   │   │   │       ├── img.js
    │   │   │   │       ├── index.js
    │   │   │   │       ├── index.json
    │   │   │   │       ├── index.wxml
    │   │   │   │       └── index.wxss
    │   │   │   └── project.config.json
    │   │   └── utils.js
    │   └── tsconfig.json
    ├── react/
    │   ├── .babelrc
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── example/
    │   │   ├── react16.8.html
    │   │   └── react18.0.html
    │   ├── package.json
    │   ├── rollup.config.build.js
    │   ├── rollup.config.dev.js
    │   └── src/
    │       ├── app.js
    │       ├── components/
    │       │   ├── LuckyGrid.js
    │       │   ├── LuckyWheel.js
    │       │   └── SlotMachine.js
    │       ├── demo/
    │       │   ├── LuckyGrid.js
    │       │   ├── LuckyWheel.js
    │       │   └── SlotMachine.js
    │       └── index.js
    ├── taro/
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── package.json
    │   ├── react/
    │   │   ├── LuckyGrid.js
    │   │   ├── LuckyWheel.js
    │   │   ├── SlotMachine.js
    │   │   └── index.js
    │   ├── utils/
    │   │   ├── index.css
    │   │   └── index.js
    │   └── vue/
    │       ├── LuckyGrid.vue
    │       ├── LuckyWheel.vue
    │       ├── SlotMachine.vue
    │       └── index.js
    ├── uni/
    │   ├── .gitignore
    │   ├── .npmignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── lucky-grid.vue
    │   ├── lucky-wheel.vue
    │   ├── package.json
    │   ├── slot-machine.vue
    │   └── utils.js
    └── vue/
        ├── .gitignore
        ├── .npmignore
        ├── LICENSE
        ├── README.md
        ├── composition-api.js
        ├── index.js
        ├── package.json
        ├── rollup.config.build.js
        ├── rollup.config.dev.js
        ├── shims-vue.d.ts
        ├── src/
        │   ├── components/
        │   │   ├── LuckyGrid.ts
        │   │   ├── LuckyWheel.ts
        │   │   └── SlotMachine.ts
        │   ├── index.ts
        │   └── utils/
        │       └── h-demi.ts
        ├── tsconfig.json
        ├── types/
        │   └── index.d.ts
        ├── vue-demi.js
        ├── vue2.html
        └── vue3.html
Download .txt
SYMBOL INDEX (477 symbols across 50 files)

FILE: packages/core/src/lib/grid.ts
  class LuckyGrid (line 30) | class LuckyGrid extends Lucky {
    method constructor (line 82) | constructor (config: UserConfigType, data: LuckyGridConfig) {
    method resize (line 96) | protected resize(): void {
    method initLucky (line 102) | protected initLucky (): void {
    method initData (line 122) | private initData (data: LuckyGridConfig): void {
    method initComputed (line 142) | private initComputed (): void {
    method initWatch (line 184) | private initWatch (): void {
    method init (line 219) | public async init (): Promise<void> {
    method initImageCache (line 232) | private initImageCache (): Promise<void> {
    method handleClick (line 262) | protected handleClick (e: MouseEvent): void {
    method loadAndCacheImg (line 290) | private async loadAndCacheImg (
    method draw (line 331) | protected draw (): void {
    method handleBackground (line 494) | private handleBackground (
    method carveOnGunwaleOfAMovingBoat (line 512) | private carveOnGunwaleOfAMovingBoat (): void {
    method play (line 533) | public play (): void {
    method stop (line 551) | public stop (index?: number): void {
    method run (line 572) | private run (num: number = 0): void {
    method getGeometricProperty (line 628) | private getGeometricProperty ([x, y, col = 1, row = 1]: number[]) {
    method conversionAxis (line 647) | protected conversionAxis (x: number, y: number): [number, number] {

FILE: packages/core/src/lib/lucky.ts
  class Lucky (line 8) | class Lucky {
    method constructor (line 26) | constructor (
    method resize (line 78) | protected resize(): void {
    method initLucky (line 93) | protected initLucky () {
    method handleClick (line 104) | protected handleClick (e: MouseEvent): void {}
    method setHTMLFontSize (line 109) | protected setHTMLFontSize (): void {
    method clearCanvas (line 115) | public clearCanvas (): void {
    method setDpr (line 124) | protected setDpr (): void {
    method resetWidthAndHeight (line 138) | private resetWidthAndHeight (): void {
    method zoomCanvas (line 160) | protected zoomCanvas (): void {
    method initWindowFunction (line 177) | private initWindowFunction (): void {
    method isWeb (line 205) | public isWeb () {
    method loadImg (line 214) | protected loadImg (
    method drawImage (line 241) | protected drawImage(
    method computedWidthAndHeight (line 290) | protected computedWidthAndHeight (
    method changeUnits (line 324) | protected changeUnits (value: string, denominator = 1): number {
    method getLength (line 346) | protected getLength (length: string | number | undefined, maxLength?: ...
    method getOffsetX (line 357) | protected getOffsetX (width: number, maxWidth: number = 0): number {
    method getOffscreenCanvas (line 361) | protected getOffscreenCanvas (width: number, height: number): {
    method $set (line 390) | public $set (data: object, key: string | number, value: any) {
    method $computed (line 401) | protected $computed (data: object, key: string, callback: Function) {
    method $watch (line 416) | protected $watch (

FILE: packages/core/src/lib/slot.ts
  class SlotMachine (line 24) | class SlotMachine extends Lucky {
    method constructor (line 78) | constructor (config: UserConfigType, data: SlotMachineConfig) {
    method resize (line 92) | protected resize(): void {
    method initLucky (line 98) | protected initLucky (): void {
    method initData (line 119) | private initData (data: SlotMachineConfig): void {
    method initComputed (line 133) | private initComputed (): void {
    method initWatch (line 169) | private initWatch (): void {
    method init (line 201) | public async init (): Promise<void> {
    method initImageCache (line 215) | private initImageCache (): Promise<void> {
    method loadAndCacheImg (line 246) | private async loadAndCacheImg (
    method drawOffscreenCanvas (line 273) | protected drawOffscreenCanvas (): void {
    method drawBlocks (line 385) | protected drawBlocks (): SlotMachine['prizeArea'] {
    method draw (line 419) | protected draw (): void {
    method carveOnGunwaleOfAMovingBoat (line 459) | private carveOnGunwaleOfAMovingBoat (): void {
    method play (line 486) | public play (): void {
    method stop (line 500) | public stop (index: number | number[]): void {
    method run (line 531) | private run (num: number = 0): void {
    method displacement (line 598) | private displacement<T> (a: T, b: T): T {
    method displacementWidthOrHeight (line 603) | private displacementWidthOrHeight () {

FILE: packages/core/src/lib/wheel.ts
  class LuckyWheel (line 22) | class LuckyWheel extends Lucky {
    method constructor (line 65) | constructor (config: UserConfigType, data: LuckyWheelConfig) {
    method resize (line 79) | protected resize(): void {
    method initLucky (line 87) | protected initLucky (): void {
    method initData (line 108) | private initData (data: LuckyWheelConfig): void {
    method initComputed (line 123) | private initComputed () {
    method initWatch (line 157) | private initWatch () {
    method init (line 189) | public async init (): Promise<void> {
    method initImageCache (line 202) | private initImageCache (): Promise<void> {
    method handleClick (line 230) | protected handleClick (e: MouseEvent): void {
    method loadAndCacheImg (line 246) | private async loadAndCacheImg (
    method drawBlock (line 271) | private drawBlock (radius: number, block: BlockType, blockIndex: numbe...
    method draw (line 295) | protected draw (): void {
    method carveOnGunwaleOfAMovingBoat (line 445) | private carveOnGunwaleOfAMovingBoat (): void {
    method play (line 467) | public play (): void {
    method stop (line 485) | public stop (index?: number): void {
    method run (line 506) | private run (num: number = 0): void {
    method conversionAxis (line 562) | protected conversionAxis (x: number, y: number): [number, number] {

FILE: packages/core/src/observer/dep.ts
  class Dep (line 3) | class Dep {
    method constructor (line 10) | constructor () {
    method addSub (line 18) | public addSub (sub: Watcher) {
    method notify (line 28) | public notify () {

FILE: packages/core/src/observer/index.ts
  class Observer (line 5) | class Observer {
    method constructor (line 13) | constructor (value: any) {
    method walk (line 30) | walk (data: object | any[]) {
  function observe (line 41) | function observe (data: any): Observer | void {
  function defineReactive (line 58) | function defineReactive (data: any, key: string | number, val: any) {

FILE: packages/core/src/observer/utils.ts
  function def (line 6) | function def (obj: object, key: string | number, val: any, enumerable?: ...
  function parsePath (line 15) | function parsePath (path: string) {
  function traverse (line 36) | function traverse (value: any) {

FILE: packages/core/src/observer/watcher.ts
  type WatchOptType (line 5) | interface WatchOptType {
  class Watcher (line 12) | class Watcher {
    method constructor (line 27) | constructor ($lucky: Lucky, expr: string | Function, cb: Function, opt...
    method get (line 44) | get () {
    method update (line 58) | update () {

FILE: packages/core/src/types/grid.ts
  type PrizeFontType (line 10) | type PrizeFontType = FontItemType & FontExtendType
  type ButtonFontType (line 12) | type ButtonFontType = FontItemType & FontExtendType
  type CellFontType (line 14) | type CellFontType = PrizeFontType | ButtonFontType
  type BlockImgType (line 16) | type BlockImgType = ImgItemType & {}
  type PrizeImgType (line 18) | type PrizeImgType = ImgItemType & {
  type ButtonImgType (line 22) | type ButtonImgType = ImgItemType & {}
  type CellImgType (line 24) | type CellImgType = PrizeImgType | ButtonImgType
  type BlockType (line 26) | type BlockType = {
  type CellType (line 37) | type CellType<T, U> = {
  type PrizeType (line 49) | type PrizeType = CellType<PrizeFontType, PrizeImgType> & {
  type ButtonType (line 54) | type ButtonType = CellType<ButtonFontType, ButtonImgType> & {
  type DefaultConfigType (line 58) | type DefaultConfigType = {
  type DefaultStyleType (line 65) | type DefaultStyleType = {
  type ActiveStyleType (line 79) | type ActiveStyleType = {
  type RowsType (line 89) | type RowsType = number
  type ColsType (line 90) | type ColsType = number
  type StartCallbackType (line 91) | type StartCallbackType = (e: MouseEvent, button?: ButtonType) => void
  type EndCallbackType (line 92) | type EndCallbackType = (prize: object) => void
  type LuckyGridConfig (line 94) | interface LuckyGridConfig {

FILE: packages/core/src/types/index.ts
  type FontItemType (line 2) | type FontItemType = {
  type FontExtendType (line 13) | type FontExtendType = {
  type ImgType (line 19) | type ImgType = HTMLImageElement | HTMLCanvasElement
  type ImgItemType (line 22) | type ImgItemType = {
  type BorderRadiusType (line 33) | type BorderRadiusType = string | number
  type BackgroundType (line 34) | type BackgroundType = string
  type ShadowType (line 35) | type ShadowType = string
  type ConfigType (line 37) | type ConfigType = {
  type UserConfigType (line 65) | type UserConfigType = Partial<ConfigType>
  type UniImageType (line 67) | type UniImageType = {
  type Tuple (line 73) | type Tuple<T, Len extends number, Res extends T[] = []> = Res['length'] ...

FILE: packages/core/src/types/slot.ts
  type PrizeFontType (line 9) | type PrizeFontType = FontItemType & FontExtendType
  type BlockImgType (line 11) | type BlockImgType = ImgItemType & {}
  type PrizeImgType (line 13) | type PrizeImgType = ImgItemType
  type BlockType (line 15) | type BlockType = {
  type PrizeType (line 26) | type PrizeType = {
  type SlotType (line 33) | type SlotType = {
  type DefaultConfigType (line 39) | type DefaultConfigType = {
  type DefaultStyleType (line 64) | type DefaultStyleType = {
  type EndCallbackType (line 77) | type EndCallbackType = (prize: PrizeType | undefined) => void
  type SlotMachineConfig (line 79) | interface SlotMachineConfig {

FILE: packages/core/src/types/wheel.ts
  type PrizeFontType (line 8) | type PrizeFontType = FontItemType & FontExtendType
  type ButtonFontType (line 10) | type ButtonFontType = FontItemType & {}
  type BlockImgType (line 12) | type BlockImgType = ImgItemType & {
  type PrizeImgType (line 16) | type PrizeImgType = ImgItemType & {}
  type ButtonImgType (line 18) | type ButtonImgType = ImgItemType & {}
  type BlockType (line 20) | type BlockType = {
  type PrizeType (line 26) | type PrizeType = {
  type ButtonType (line 33) | type ButtonType = {
  type DefaultConfigType (line 41) | type DefaultConfigType = {
  type DefaultStyleType (line 51) | type DefaultStyleType = {
  type StartCallbackType (line 63) | type StartCallbackType = (e: MouseEvent) => void
  type EndCallbackType (line 64) | type EndCallbackType = (prize: object) => void
  type LuckyWheelConfig (line 66) | interface LuckyWheelConfig {

FILE: packages/core/src/utils/polyfill.js
  function sameValueZero (line 36) | function sameValueZero(x, y) {

FILE: packages/core/src/utils/tween.ts
  type SpeedType (line 11) | interface SpeedType {

FILE: packages/core/types/index.d.ts
  type FontItemType (line 1) | type FontItemType = {
  type FontExtendType (line 11) | type FontExtendType = {
  type ImgType (line 16) | type ImgType = HTMLImageElement | HTMLCanvasElement;
  type ImgItemType (line 17) | type ImgItemType = {
  type BorderRadiusType (line 27) | type BorderRadiusType = string | number;
  type BackgroundType (line 28) | type BackgroundType = string;
  type ShadowType (line 29) | type ShadowType = string;
  type ConfigType (line 30) | type ConfigType = {
  type UserConfigType (line 53) | type UserConfigType = Partial<ConfigType>;
  type Tuple (line 54) | type Tuple<T, Len extends number, Res extends T[] = []> = Res['length'] ...
  type WatchOptType (line 56) | interface WatchOptType {
  class Lucky (line 62) | class Lucky {
  type PrizeFontType$2 (line 188) | type PrizeFontType$2 = FontItemType & FontExtendType;
  type ButtonFontType$1 (line 189) | type ButtonFontType$1 = FontItemType & {};
  type BlockImgType$2 (line 190) | type BlockImgType$2 = ImgItemType & {
  type PrizeImgType$2 (line 193) | type PrizeImgType$2 = ImgItemType & {};
  type ButtonImgType$1 (line 194) | type ButtonImgType$1 = ImgItemType & {};
  type BlockType$2 (line 195) | type BlockType$2 = {
  type PrizeType$2 (line 200) | type PrizeType$2 = {
  type ButtonType$1 (line 206) | type ButtonType$1 = {
  type DefaultConfigType$2 (line 213) | type DefaultConfigType$2 = {
  type DefaultStyleType$2 (line 222) | type DefaultStyleType$2 = {
  type StartCallbackType$1 (line 233) | type StartCallbackType$1 = (e: MouseEvent) => void;
  type EndCallbackType$2 (line 234) | type EndCallbackType$2 = (prize: object) => void;
  type LuckyWheelConfig (line 235) | interface LuckyWheelConfig {
  class LuckyWheel (line 247) | class LuckyWheel extends Lucky {
  type PrizeFontType$1 (line 354) | type PrizeFontType$1 = FontItemType & FontExtendType;
  type ButtonFontType (line 355) | type ButtonFontType = FontItemType & FontExtendType;
  type BlockImgType$1 (line 356) | type BlockImgType$1 = ImgItemType & {};
  type PrizeImgType$1 (line 357) | type PrizeImgType$1 = ImgItemType & {
  type ButtonImgType (line 360) | type ButtonImgType = ImgItemType & {};
  type BlockType$1 (line 361) | type BlockType$1 = {
  type CellType (line 371) | type CellType<T, U> = {
  type PrizeType$1 (line 382) | type PrizeType$1 = CellType<PrizeFontType$1, PrizeImgType$1> & {
  type ButtonType (line 386) | type ButtonType = CellType<ButtonFontType, ButtonImgType> & {
  type DefaultConfigType$1 (line 389) | type DefaultConfigType$1 = {
  type DefaultStyleType$1 (line 395) | type DefaultStyleType$1 = {
  type ActiveStyleType (line 408) | type ActiveStyleType = {
  type RowsType (line 417) | type RowsType = number;
  type ColsType (line 418) | type ColsType = number;
  type StartCallbackType (line 419) | type StartCallbackType = (e: MouseEvent, button?: ButtonType) => void;
  type EndCallbackType$1 (line 420) | type EndCallbackType$1 = (prize: object) => void;
  type LuckyGridConfig (line 421) | interface LuckyGridConfig {
  class LuckyGrid (line 437) | class LuckyGrid extends Lucky {
  type PrizeFontType (line 565) | type PrizeFontType = FontItemType & FontExtendType;
  type BlockImgType (line 566) | type BlockImgType = ImgItemType & {};
  type PrizeImgType (line 567) | type PrizeImgType = ImgItemType;
  type BlockType (line 568) | type BlockType = {
  type PrizeType (line 578) | type PrizeType = {
  type SlotType (line 584) | type SlotType = {
  type DefaultConfigType (line 589) | type DefaultConfigType = {
  type DefaultStyleType (line 610) | type DefaultStyleType = {
  type EndCallbackType (line 622) | type EndCallbackType = (prize: PrizeType | undefined) => void;
  type SlotMachineConfig (line 623) | interface SlotMachineConfig {
  class SlotMachine (line 634) | class SlotMachine extends Lucky {

FILE: packages/mini/src/lucky-grid/index.js
  method ready (line 33) | ready() {
  method imgBindload (line 92) | imgBindload(e) {
  method imgBindloadActive (line 97) | imgBindloadActive(e) {
  method luckyImgLoad (line 102) | luckyImgLoad() {
  method handleClickOfImg (line 106) | handleClickOfImg(e) {
  method handleClickOfCanvas (line 115) | handleClickOfCanvas(e) {
  method toPlay (line 119) | toPlay(x, y) {
  method init (line 135) | init (...rest) {
  method play (line 138) | play(...rest) {
  method stop (line 141) | stop(...rest) {

FILE: packages/mini/src/lucky-wheel/index.js
  method ready (line 33) | ready() {
  method imgBindload (line 97) | imgBindload(e) {
  method luckyImgLoad (line 102) | luckyImgLoad() {
  method handleClickOfImg (line 106) | handleClickOfImg(e) {
  method handleClickOfCanvas (line 115) | handleClickOfCanvas(e) {
  method toPlay (line 119) | toPlay(x, y) {
  method init (line 127) | init (...rest) {
  method play (line 130) | play(...rest) {
  method stop (line 133) | stop(...rest) {

FILE: packages/mini/src/slot-machine/index.js
  method ready (line 32) | ready() {
  method imgBindload (line 85) | imgBindload(e) {
  method luckyImgLoad (line 90) | luckyImgLoad() {
  method init (line 94) | init (...rest) {
  method play (line 97) | play(...rest) {
  method stop (line 100) | stop(...rest) {

FILE: packages/mini/src/utils.js
  function getImage (line 34) | function getImage() {

FILE: packages/mini/test/wx.test.js
  method success (line 5) | success(res) {
  method complete (line 8) | complete(res) {

FILE: packages/mini/tools/build.js
  function wxss (line 26) | function wxss(wxssFileList) {
  function js (line 43) | function js(jsFileMap, scope) {
  function copy (line 85) | function copy(copyFileList) {
  function install (line 96) | function install() {
  class BuildTask (line 113) | class BuildTask {
    method constructor (line 114) | constructor(id, entry) {
    method init (line 126) | init() {

FILE: packages/mini/tools/checkcomponents.js
  function getJsonPathInfo (line 12) | function getJsonPathInfo(jsonPath) {
  function checkIncludedComponents (line 27) | async function checkIncludedComponents(jsonPath, componentListMap) {

FILE: packages/mini/tools/checkwxss.js
  function getImportList (line 10) | function getImportList(wxss, filePath) {
  function getContent (line 29) | async function getContent(wxss, filePath, cwd) {
  method start (line 60) | start() {
  method end (line 86) | end() {

FILE: packages/mini/tools/demo/pages/cjl/index.js
  method onReady (line 23) | onReady () {
  method getPrizesList (line 26) | getPrizesList () {
  method wheelStart (line 50) | wheelStart () {
  method wheelEnd (line 63) | wheelEnd (event) {

FILE: packages/mini/tools/demo/pages/index/index.js
  method onReady (line 42) | onReady () {
  method wheelStart (line 63) | wheelStart () {
  method wheelEnd (line 76) | wheelEnd (event) {
  method gridStart (line 80) | gridStart () {
  method gridEnd (line 93) | gridEnd (event) {

FILE: packages/mini/tools/demo/pages/jd/index.js
  method onReady (line 21) | onReady () {
  method getPrizesList (line 24) | getPrizesList () {
  method wheelStart (line 48) | wheelStart () {
  method wheelEnd (line 61) | wheelEnd (event) {

FILE: packages/mini/tools/demo/pages/slot/index.js
  method onReady (line 15) | onReady () {
  method handleStart (line 59) | handleStart () {
  method handleEnd (line 72) | handleEnd (event) {
  method maskHidden (line 81) | maskHidden () {

FILE: packages/mini/tools/demo/pages/xc/index.js
  method onReady (line 24) | onReady () {
  method wheelStart (line 26) | wheelStart () {
  method wheelEnd (line 39) | wheelEnd (event) {

FILE: packages/mini/tools/demo/pages/xdf/index.js
  method onReady (line 70) | onReady () {
  method gridStart (line 72) | gridStart () {
  method gridEnd (line 85) | gridEnd (event) {

FILE: packages/mini/tools/demo/pages/ymc/index.js
  method onReady (line 24) | onReady () {
  method wheelStart (line 69) | wheelStart () {
  method wheelEnd (line 82) | wheelEnd (event) {
  method maskHidden (line 91) | maskHidden () {

FILE: packages/mini/tools/demo/pages/yx/index.js
  method onReady (line 29) | onReady () {
  method getPrizesList (line 33) | getPrizesList () {
  method gridStart (line 51) | gridStart () {
  method gridEnd (line 64) | gridEnd (event) {

FILE: packages/mini/tools/demo/pages/yyjk/index.js
  method onReady (line 35) | onReady () {
  method gridStart (line 62) | gridStart () {
  method gridEnd (line 75) | gridEnd (event) {
  method maskHidden (line 84) | maskHidden () {

FILE: packages/mini/tools/demo/pages/yyx/index.js
  method onReady (line 29) | onReady () {
  method getPrizesList (line 33) | getPrizesList () {
  method gridStart (line 68) | gridStart () {
  method gridEnd (line 81) | gridEnd (event) {

FILE: packages/mini/tools/utils.js
  function wrap (line 11) | function wrap(func, scope) {
  function transformPath (line 41) | function transformPath(filePath, sep = '/') {
  function checkFileExists (line 48) | async function checkFileExists(filePath) {
  function recursiveMkdir (line 60) | async function recursiveMkdir(dirPath) {
  function readJson (line 87) | function readJson(filePath) {
  function readFile (line 101) | async function readFile(filePath) {
  function writeFile (line 113) | async function writeFile(filePath, data) {
  function format (line 126) | function format(time, reg) {
  function logger (line 148) | function logger(action = 'copy') {
  function compareArray (line 163) | function compareArray(arr1, arr2) {
  function merge (line 177) | function merge(obj1, obj2) {
  function getId (line 195) | function getId() {

FILE: packages/react/src/components/LuckyGrid.js
  class LuckyGrid (line 5) | class LuckyGrid extends React.Component {
    method constructor (line 6) | constructor (props) {
    method componentDidMount (line 11) | componentDidMount () {
    method componentDidUpdate (line 26) | componentDidUpdate (prevProps) {
    method initLucky (line 50) | initLucky () {
    method init (line 64) | init (...rest) {
    method play (line 67) | play (...rest) {
    method stop (line 70) | stop (...rest) {
    method render (line 73) | render () {

FILE: packages/react/src/components/LuckyWheel.js
  class LuckyWheel (line 5) | class LuckyWheel extends React.Component {
    method constructor (line 6) | constructor (props) {
    method componentDidMount (line 11) | componentDidMount () {
    method componentDidUpdate (line 26) | componentDidUpdate (prevProps) {
    method initLucky (line 44) | initLucky () {
    method init (line 58) | init (...rest) {
    method play (line 61) | play (...rest) {
    method stop (line 64) | stop (...rest) {
    method render (line 67) | render () {

FILE: packages/react/src/components/SlotMachine.js
  class SlotMachine (line 5) | class SlotMachine extends React.Component {
    method constructor (line 6) | constructor (props) {
    method componentDidMount (line 11) | componentDidMount () {
    method componentDidUpdate (line 26) | componentDidUpdate (prevProps) {
    method initLucky (line 44) | initLucky () {
    method init (line 58) | init (...rest) {
    method play (line 61) | play (...rest) {
    method stop (line 64) | stop (...rest) {
    method render (line 67) | render () {

FILE: packages/react/src/demo/LuckyGrid.js
  class GridDemo (line 4) | class GridDemo extends React.Component {
    method constructor (line 5) | constructor () {
    method render (line 64) | render () {

FILE: packages/react/src/demo/LuckyWheel.js
  class Wheel (line 4) | class Wheel extends React.Component {
    method constructor (line 5) | constructor () {
    method render (line 28) | render () {

FILE: packages/react/src/demo/SlotMachine.js
  class SlotDemo (line 4) | class SlotDemo extends React.Component {
    method constructor (line 5) | constructor () {
    method render (line 52) | render () {

FILE: packages/taro/react/LuckyGrid.js
  class LuckyGrid (line 8) | class LuckyGrid extends React.Component {
    method constructor (line 21) | constructor (props) {
    method componentDidMount (line 25) | componentDidMount () {
    method componentDidUpdate (line 29) | componentDidUpdate (prevProps) {
    method imgBindload (line 49) | async imgBindload (res, name, index, i) {
    method imgBindloadActive (line 54) | async imgBindloadActive (res, name, index, i) {
    method getImage (line 59) | getImage () {
    method showCanvas (line 64) | showCanvas () {
    method hideCanvas (line 70) | hideCanvas () {
    method initLucky (line 82) | initLucky () {
    method getConfig (line 95) | getConfig () {
    method drawLucky (line 133) | drawLucky (config) {
    method init (line 176) | init (...rest) {
    method play (line 180) | play (...rest) {
    method stop (line 184) | stop (...rest) {
    method toPlay (line 188) | toPlay (btn) {
    method render (line 192) | render () {

FILE: packages/taro/react/LuckyWheel.js
  class LuckyWheel (line 8) | class LuckyWheel extends React.Component {
    method constructor (line 21) | constructor (props) {
    method componentDidMount (line 25) | componentDidMount () {
    method componentDidUpdate (line 29) | componentDidUpdate (prevProps) {
    method imgBindload (line 43) | async imgBindload (res, name, index, i) {
    method getImage (line 48) | getImage () {
    method showCanvas (line 53) | showCanvas () {
    method hideCanvas (line 57) | hideCanvas () {
    method initLucky (line 69) | initLucky () {
    method getConfig (line 82) | getConfig () {
    method drawLucky (line 120) | drawLucky (config) {
    method init (line 164) | init (...rest) {
    method play (line 168) | play (...rest) {
    method stop (line 172) | stop (...rest) {
    method toPlay (line 176) | toPlay () {
    method render (line 180) | render () {

FILE: packages/taro/react/SlotMachine.js
  class SlotMachine (line 8) | class SlotMachine extends React.Component {
    method constructor (line 19) | constructor (props) {
    method componentDidMount (line 23) | componentDidMount () {
    method componentDidUpdate (line 27) | componentDidUpdate (prevProps) {
    method imgBindload (line 41) | async imgBindload (res, name, index, i) {
    method getImage (line 46) | getImage () {
    method showCanvas (line 51) | showCanvas () {
    method hideCanvas (line 55) | hideCanvas () {
    method initLucky (line 67) | initLucky () {
    method getConfig (line 80) | getConfig () {
    method drawLucky (line 119) | drawLucky (config) {
    method init (line 144) | init (...rest) {
    method play (line 148) | play (...rest) {
    method stop (line 152) | stop (...rest) {
    method render (line 156) | render () {

FILE: packages/taro/utils/index.js
  function getImage (line 82) | function getImage (canvasId, canvas) {

FILE: packages/uni/utils.js
  function getImage (line 68) | function getImage(canvasId, canvas) {

FILE: packages/vue/composition-api.js
  function e (line 3) | function e(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}
  function o (line 3) | function o(n){return"function"==typeof n&&/native code/.test(n.toString())}
  function f (line 3) | function f(n,t,e){var r=e.get,o=e.set;Object.defineProperty(n,t,{enumera...
  function a (line 3) | function a(n,t,e,r){Object.defineProperty(n,t,{value:e,enumerable:!!r,wr...
  function c (line 3) | function c(n,t){return Object.hasOwnProperty.call(n,t)}
  function l (line 3) | function l(n){return Array.isArray(n)}
  function d (line 3) | function d(n){var t=parseFloat(String(n));return t>=0&&Math.floor(t)===t...
  function p (line 3) | function p(n){return null!==n&&"object"==typeof n}
  function _ (line 3) | function _(n){return"[object Object]"===function(n){return Object.protot...
  function y (line 3) | function y(n){return"function"==typeof n}
  function h (line 3) | function h(n,t){r.default.util.warn(n,t)}
  function w (line 4) | function w(n){var t="function"==typeof Symbol&&Symbol.iterator,e=t&&n[t]...
  function $ (line 4) | function $(n,t){var e="function"==typeof Symbol&&n[Symbol.iterator];if(!...
  function j (line 4) | function j(n,t){for(var e=0,r=t.length,o=n.length;e<r;e++,o++)n[o]=t[e];...
  function n (line 4) | function n(n){this.active=!0,this.effects=[],this.cleanups=[],this.vm=n}
  function t (line 4) | function t(t){void 0===t&&(t=!1);var e,r=void 0;return function(n){var t...
  function e (line 4) | function e(){this.constructor=n}
  function k (line 4) | function k(){return g}
  function E (line 4) | function E(){var n,t;return(null===(n=k())||void 0===n?void 0:n.vm)||(nu...
  function A (line 4) | function A(n){return n&&y(n)&&"Vue"===n.name}
  function T (line 4) | function T(){return M}
  function V (line 4) | function V(n){if(D){var t=P;null==t||t.scope.off(),null==(P=n)||P.scope....
  function B (line 4) | function B(){return P}
  function F (line 4) | function F(n){if(z.has(n))return z.get(n);var t={proxy:n,update:n.$force...
  function I (line 4) | function I(n,t){return t=t||B()}
  function K (line 4) | function K(n,t){void 0===t&&(t={});var e=n.config.silent;n.config.silent...
  function q (line 4) | function q(n,t){return function(){for(var e=[],r=0;r<arguments.length;r+...
  function Q (line 4) | function Q(n){return i?Symbol.for(n):n}
  function Z (line 4) | function Z(n,t){void 0===t&&(t=!1);var e=new Y(n),r=Object.seal(e);retur...
  function nn (line 4) | function nn(n){var t;if(tn(n))return n;var e=pn(((t={})[J]=n,t));return ...
  function tn (line 4) | function tn(n){return n instanceof Y}
  function en (line 4) | function en(n){return tn(n)?n.value:n}
  function rn (line 4) | function rn(n){if(!_(n))return n;var t={};for(var e in n)t[e]=on(n,e);re...
  function on (line 4) | function on(n,t){var e=n[t];return tn(e)?e:Z({get:function(){return n[t]...
  function un (line 4) | function un(n){var t;return Boolean(n&&c(n,"__ob__")&&"object"==typeof n...
  function fn (line 4) | function fn(n){var t;return Boolean(n&&c(n,"__ob__")&&"object"==typeof n...
  function an (line 4) | function an(n){if(!(!_(n)||un(n)||l(n)||tn(n)||function(n){var t=T();ret...
  function cn (line 4) | function cn(n,t,e){if("__ob__"!==t&&!un(n[t])){var r,o,i=Object.getOwnPr...
  function ln (line 4) | function ln(n){var t,e=M||R;e.observable?t=e.observable(n):t=K(e,{data:{...
  function sn (line 4) | function sn(n,t){var e,r;if(void 0===t&&(t=new Set),!t.has(n)){a(n,"__ob...
  function vn (line 4) | function vn(){return ln({}).__ob__}
  function dn (line 4) | function dn(n){var t,e;if(!p(n))return n;if(!_(n)&&!l(n)||un(n)||!Object...
  function pn (line 4) | function pn(n){if(!p(n))return n;if(!_(n)&&!l(n)||un(n)||!Object.isExten...
  function _n (line 4) | function _n(n){return function(t,e){var r,o=I(((r=n)[0].toUpperCase(),r....
  function kn (line 4) | function kn(){Cn(this,G)}
  function En (line 4) | function En(){Cn(this,H)}
  function Rn (line 4) | function Rn(){var n=E();return n?function(n){return void 0!==n[G]}(n)||f...
  function Cn (line 4) | function Cn(n,t){for(var e=n[t],r=0;r<e.length;r++)e[r]();e.length=0}
  function Mn (line 4) | function Mn(n,t,e){var r=function(){n.$nextTick((function(){n[G].length&...
  function Pn (line 4) | function Pn(n,t){var e=n.teardown;n.teardown=function(){for(var r=[],o=0...
  function Dn (line 4) | function Dn(n,t,e,r){var o,i,f=r.flush,a="sync"===f,c=function(n){i=func...
  function Un (line 4) | function Un(n,t){var e=function(n){return m({flush:"pre"},n)}(t);return ...
  function An (line 4) | function An(n,t){if(void 0===t&&(t=new Set),!p(n)||t.has(n))return n;if(...
  function Fn (line 4) | function Fn(){return B().setupContext}
  function Kn (line 4) | function Kn(n){var t=In.get(n,"rawBindings")||{};if(t&&Object.keys(t).le...
  function qn (line 4) | function qn(n,t){var e=n.$options._parentVnode;if(e){for(var r=In.get(n,...
  function Qn (line 4) | function Qn(n,t,e){var r=B();V(n);try{return t(n)}catch(n){if(!e)throw n...
  function Gn (line 4) | function Gn(n){function t(n,e){if(void 0===e&&(e=new Set),!e.has(n)&&_(n...
  function Hn (line 4) | function Hn(n,t){if(!n)return t;if(!t)return n;for(var e,r,o,u=i?Reflect...
  function Jn (line 4) | function Jn(n){(function(n){return c(n,U)})(n)||(n.config.optionMergeStr...

FILE: packages/vue/src/components/LuckyGrid.ts
  method cols (line 60) | cols (newData, oldData) {
  method rows (line 63) | rows (newData, oldData) {
  method blocks (line 66) | blocks (newData, oldData) {
  method prizes (line 69) | prizes (newData, oldData) {
  method buttons (line 72) | buttons (newData, oldData) {
  method button (line 75) | button (newData, oldData) {
  method data (line 79) | data() {
  method mounted (line 84) | mounted () {
  method initLucky (line 101) | initLucky () {
  method init (line 122) | init () {
  method play (line 128) | play () {
  method stop (line 135) | stop (index?: number) {
  method render (line 139) | render() {

FILE: packages/vue/src/components/LuckyWheel.ts
  method blocks (line 45) | blocks (newData, oldData) {
  method prizes (line 48) | prizes (newData, oldData) {
  method buttons (line 51) | buttons (newData, oldData) {
  method data (line 55) | data() {
  method mounted (line 60) | mounted () {
  method initLucky (line 77) | initLucky () {
  method init (line 98) | init () {
  method play (line 104) | play () {
  method stop (line 111) | stop (index?: number) {
  method render (line 115) | render() {

FILE: packages/vue/src/components/SlotMachine.ts
  method blocks (line 38) | blocks (newData, oldData) {
  method slots (line 41) | slots (newData, oldData) {
  method prizes (line 44) | prizes (newData, oldData) {
  method data (line 48) | data() {
  method mounted (line 53) | mounted () {
  method initLucky (line 70) | initLucky () {
  method init (line 91) | init () {
  method play (line 97) | play () {
  method stop (line 104) | stop (index: number) {
  method render (line 108) | render() {

FILE: packages/vue/src/utils/h-demi.ts
  type Options (line 4) | interface Options {
Condensed preview — 186 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,238K chars).
[
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "chars": 608,
    "preview": "\n<!-- \n\n提问前必看! 提问前必看! 提问前必看!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nhttps://github.com/buuing/lucky-canvas/issues/177\n\n-->\n\n<!-"
  },
  {
    "path": ".gitignore",
    "chars": 323,
    "preview": ".DS_Store\nnode_modules\nyarn.lock\npackage-lock.json\n\n# local env files\n.env.local\n.env.*.local\n\n# Log files\nnpm-debug.log"
  },
  {
    "path": "LICENSE",
    "chars": 11344,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 9414,
    "preview": "\n<div align=\"center\">\n  <img src=\"https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.png\" width=\"128\" alt=\"logo\" />\n  <h1>"
  },
  {
    "path": "lerna.json",
    "chars": 109,
    "preview": "{\n  \"packages\": [\n    \"packages/*\"\n  ],\n  \"version\": \"0.0.4\",\n  \"npmClient\": \"npm\",\n  \"useWorkspaces\": true\n}"
  },
  {
    "path": "package.json",
    "chars": 777,
    "preview": "{\n  \"name\": \"lucky-canvas\",\n  \"devDependencies\": {\n    \"lerna\": \"^4.0.0\"\n  },\n  \"scripts\": {\n    \"install\": \"lerna boots"
  },
  {
    "path": "packages/core/.babelrc",
    "chars": 96,
    "preview": "{\n  \"presets\": [\n    [\n      \"@babel/preset-env\", {\n        \"modules\": false\n      }\n    ]\n  ]\n}"
  },
  {
    "path": "packages/core/.eslintrc.js",
    "chars": 488,
    "preview": "// module.exports = {\n//   \"env\": {\n//     \"browser\": true,\n//     \"es6\": true,\n//     \"node\": true\n//   },\n//   \"parser"
  },
  {
    "path": "packages/core/.gitignore",
    "chars": 241,
    "preview": ".DS_Store\nnode_modules\nyarn.lock\npackage-lock.json\ndist\n\n# local env files\n.env.local\n.env.*.local\n\n# Log files\nnpm-debu"
  },
  {
    "path": "packages/core/.npmignore",
    "chars": 1,
    "preview": "*"
  },
  {
    "path": "packages/core/LICENSE",
    "chars": 11344,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "packages/core/README.md",
    "chars": 1499,
    "preview": "\n\n<div align=\"center\">\n  <img src=\"https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.png\" width=\"128\" alt=\"logo\" />\n  <h1"
  },
  {
    "path": "packages/core/examples/grid.html",
    "chars": 1362,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, in"
  },
  {
    "path": "packages/core/examples/index.html",
    "chars": 453,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, in"
  },
  {
    "path": "packages/core/examples/slot.html",
    "chars": 2084,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, in"
  },
  {
    "path": "packages/core/examples/wheel.html",
    "chars": 2110,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, in"
  },
  {
    "path": "packages/core/index.js",
    "chars": 48,
    "preview": "module.exports = require('./dist/index.umd.js')\n"
  },
  {
    "path": "packages/core/package.json",
    "chars": 1868,
    "preview": "{\n  \"name\": \"lucky-canvas\",\n  \"version\": \"1.7.26\",\n  \"description\": \"一个基于原生 js 的(大转盘 / 九宫格 / 老虎机)抽奖插件\",\n  \"main\": \"dist/"
  },
  {
    "path": "packages/core/postinstall.js",
    "chars": 919,
    "preview": "console.log(`  \\u001B[93m╭────────────────────────────────────────────────────╮\\u001b[0m\n  \\u001B[93m│\\u001b[0m         "
  },
  {
    "path": "packages/core/rollup.config.build.js",
    "chars": 1345,
    "preview": "import path from 'path'\nimport ts from 'rollup-plugin-typescript2'\nimport dts from 'rollup-plugin-dts'\nimport json from "
  },
  {
    "path": "packages/core/rollup.config.dev.js",
    "chars": 1210,
    "preview": "import path from 'path'\nimport ts from 'rollup-plugin-typescript2'\nimport json from '@rollup/plugin-json'\nimport resolve"
  },
  {
    "path": "packages/core/src/index.ts",
    "chars": 407,
    "preview": "export { default as LuckyWheel } from './lib/wheel'\nexport { default as LuckyGrid } from './lib/grid'\nexport { default a"
  },
  {
    "path": "packages/core/src/lib/grid.ts",
    "chars": 20302,
    "preview": "import Lucky from './lucky'\nimport { UserConfigType, ImgType } from '../types/index'\nimport LuckyGridConfig, {\n  BlockTy"
  },
  {
    "path": "packages/core/src/lib/lucky.ts",
    "chars": 12945,
    "preview": "import '../utils/polyfill'\nimport { has, isExpectType, throttle } from '../utils/index'\nimport { name, version } from '."
  },
  {
    "path": "packages/core/src/lib/slot.ts",
    "chars": 20765,
    "preview": "import Lucky from './lucky'\nimport { UserConfigType, ImgType, ImgItemType, Tuple } from '../types/index'\nimport SlotMach"
  },
  {
    "path": "packages/core/src/lib/wheel.ts",
    "chars": 18232,
    "preview": "import Lucky from './lucky'\nimport { UserConfigType, FontItemType, ImgType } from '../types/index'\nimport LuckyWheelConf"
  },
  {
    "path": "packages/core/src/observer/array.ts",
    "chars": 517,
    "preview": "/**\n * 重写数组的原型方法\n */\nconst oldArrayProto = Array.prototype\nconst newArrayProto = Object.create(oldArrayProto)\nconst meth"
  },
  {
    "path": "packages/core/src/observer/dep.ts",
    "chars": 474,
    "preview": "import Watcher from './watcher'\n\nexport default class Dep {\n  static target: Watcher | null\n  private subs: Array<Watche"
  },
  {
    "path": "packages/core/src/observer/index.ts",
    "chars": 2167,
    "preview": "import Dep from './dep'\nimport { hasProto, def } from './utils'\nimport { newArrayProto } from './array'\n\nexport default "
  },
  {
    "path": "packages/core/src/observer/utils.ts",
    "chars": 1073,
    "preview": "\nimport { isExpectType } from '../utils'\n\nexport const hasProto = '__proto__' in {}\n\nexport function def (obj: object, k"
  },
  {
    "path": "packages/core/src/observer/watcher.ts",
    "chars": 1281,
    "preview": "import Lucky from '../lib/lucky'\nimport Dep from './dep'\nimport { parsePath, traverse } from './utils'\n\nexport interface"
  },
  {
    "path": "packages/core/src/types/grid.ts",
    "chars": 2664,
    "preview": "import {\n  FontItemType,\n  ImgItemType,\n  BorderRadiusType,\n  BackgroundType,\n  ShadowType,\n  FontExtendType\n} from './i"
  },
  {
    "path": "packages/core/src/types/index.ts",
    "chars": 1644,
    "preview": "// 字体类型\nexport type FontItemType = {\n  text: string\n  top?: string | number\n  left?: string | number\n  fontColor?: strin"
  },
  {
    "path": "packages/core/src/types/slot.ts",
    "chars": 1992,
    "preview": "import {\n  FontItemType,\n  ImgItemType,\n  BorderRadiusType,\n  BackgroundType,\n  FontExtendType\n} from './index'\n\nexport "
  },
  {
    "path": "packages/core/src/types/wheel.ts",
    "chars": 1780,
    "preview": "import {\n  FontItemType,\n  ImgItemType,\n  BackgroundType,\n  FontExtendType\n} from './index'\n\nexport type PrizeFontType ="
  },
  {
    "path": "packages/core/src/utils/image.ts",
    "chars": 3246,
    "preview": "import { ImgType } from '../types/index'\nimport { roundRectByArc } from './math'\n\n/**\n * 根据路径获取图片对象\n * @param { string }"
  },
  {
    "path": "packages/core/src/utils/index.ts",
    "chars": 5179,
    "preview": "/**\n * 判断是否是期望的类型\n * @param { unknown } param 将要判断的变量\n * @param { ...string } types 期望的类型\n * @return { boolean } 返回期望是否正"
  },
  {
    "path": "packages/core/src/utils/math.ts",
    "chars": 7213,
    "preview": "/**\n * 转换为运算角度\n * @param { number } deg 数学角度\n * @return { number } 运算角度\n */\nexport const getAngle = (deg: number): numbe"
  },
  {
    "path": "packages/core/src/utils/polyfill.js",
    "chars": 3052,
    "preview": "/**\n * 由于部分低版本下的某些 app 可能会缺少某些原型方法, 这里增加兼容\n */\n\n// ie11 不兼容 includes 方法\nif (!Array.prototype.includes) {\n  Object.define"
  },
  {
    "path": "packages/core/src/utils/tween.ts",
    "chars": 2153,
    "preview": "/**\n * 缓动函数\n * t: current time(当前时间)\n * b: beginning value(初始值)\n * c: change in value(变化量)\n * d: duration(持续时间)\n * \n * 感"
  },
  {
    "path": "packages/core/tsconfig.json",
    "chars": 517,
    "preview": "{\n  \"compilerOptions\": {\n    \"target\": \"es5\", // 编译后的es版本\n    \"module\": \"esnext\", // 前端模块化规范\n    \"allowJs\": true, // 允许引"
  },
  {
    "path": "packages/core/types/index.d.ts",
    "chars": 19614,
    "preview": "declare type FontItemType = {\r\n    text: string;\r\n    top?: string | number;\r\n    left?: string | number;\r\n    fontColor"
  },
  {
    "path": "packages/mini/.babelrc",
    "chars": 202,
    "preview": "{\n    \"plugins\": [\n        [\"module-resolver\", {\n            \"root\": [\"./src\"],\n            \"alias\": {}\n        }]\n    ]"
  },
  {
    "path": "packages/mini/.eslintrc.js",
    "chars": 1991,
    "preview": "module.exports = {\n  'extends': [\n    'airbnb-base',\n    'plugin:promise/recommended'\n  ],\n  'parser': '@typescript-esli"
  },
  {
    "path": "packages/mini/.gitignore",
    "chars": 106,
    "preview": ".idea\n.DS_Store\ndist\n\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\ndev\nnode_modules\ncoverage"
  },
  {
    "path": "packages/mini/.npmignore",
    "chars": 1,
    "preview": "*"
  },
  {
    "path": "packages/mini/LICENSE",
    "chars": 11344,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "packages/mini/README.md",
    "chars": 1365,
    "preview": "\n<div align=\"center\">\n  <img src=\"https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.jpg\" width=\"210\" alt=\"logo\" />\n  <h1>"
  },
  {
    "path": "packages/mini/gulpfile.js",
    "chars": 757,
    "preview": "const gulp = require('gulp')\nconst clean = require('gulp-clean')\n\nconst config = require('./tools/config')\nconst BuildTa"
  },
  {
    "path": "packages/mini/package.json",
    "chars": 2019,
    "preview": "{\n  \"name\": \"@lucky-canvas/mini\",\n  \"version\": \"0.0.8\",\n  \"description\": \"\",\n  \"main\": \"dist/index.js\",\n  \"scripts\": {\n "
  },
  {
    "path": "packages/mini/src/lucky-grid/index.js",
    "chars": 4249,
    "preview": "import { LuckyGrid } from 'lucky-canvas'\nimport { changeUnits, resolveImage, getImage } from '../utils'\n\nComponent({\n  p"
  },
  {
    "path": "packages/mini/src/lucky-grid/index.json",
    "chars": 48,
    "preview": "{\n  \"component\": true,\n  \"usingComponents\": {}\n}"
  },
  {
    "path": "packages/mini/src/lucky-grid/index.wxml",
    "chars": 1871,
    "preview": "<view class=\"lucky-box\" style=\"width: {{width}}; height: {{height}}\">\n  <canvas\n    type=\"2d\"\n    class=\"lucky-canvas\"\n "
  },
  {
    "path": "packages/mini/src/lucky-grid/index.wxss",
    "chars": 295,
    "preview": "/* @lucky-canvas/mini/lucky-wheel/index.wxss */\n.lucky-box {\n  position: relative;\n  overflow: hidden;\n  margin: 0 auto;"
  },
  {
    "path": "packages/mini/src/lucky-wheel/index.js",
    "chars": 3987,
    "preview": "import { LuckyWheel } from 'lucky-canvas'\nimport { changeUnits, resolveImage, getImage } from '../utils'\n\nComponent({\n  "
  },
  {
    "path": "packages/mini/src/lucky-wheel/index.json",
    "chars": 48,
    "preview": "{\n  \"component\": true,\n  \"usingComponents\": {}\n}"
  },
  {
    "path": "packages/mini/src/lucky-wheel/index.wxml",
    "chars": 1745,
    "preview": "<view class=\"lucky-box\" style=\"width: {{width}}; height: {{height}}\">\n  <canvas\n    type=\"2d\"\n    class=\"lucky-canvas\"\n "
  },
  {
    "path": "packages/mini/src/lucky-wheel/index.wxss",
    "chars": 295,
    "preview": "/* @lucky-canvas/mini/lucky-wheel/index.wxss */\n.lucky-box {\n  position: relative;\n  overflow: hidden;\n  margin: 0 auto;"
  },
  {
    "path": "packages/mini/src/slot-machine/index.js",
    "chars": 3011,
    "preview": "import { SlotMachine } from 'lucky-canvas'\nimport { changeUnits, resolveImage, getImage } from '../utils'\n\nComponent({\n "
  },
  {
    "path": "packages/mini/src/slot-machine/index.json",
    "chars": 48,
    "preview": "{\n  \"component\": true,\n  \"usingComponents\": {}\n}"
  },
  {
    "path": "packages/mini/src/slot-machine/index.wxml",
    "chars": 1308,
    "preview": "<view class=\"lucky-box\" style=\"width: {{width}}; height: {{height}}\">\n  <canvas\n    type=\"2d\"\n    class=\"lucky-canvas\"\n "
  },
  {
    "path": "packages/mini/src/slot-machine/index.wxss",
    "chars": 296,
    "preview": "/* @lucky-canvas/mini/slot-machine/index.wxss */\n.lucky-box {\n  position: relative;\n  overflow: hidden;\n  margin: 0 auto"
  },
  {
    "path": "packages/mini/src/utils.js",
    "chars": 986,
    "preview": "const windowWidth = wx.getSystemInfoSync().windowWidth\n\nexport const rpx2px = (value) => {\n  if (typeof value === 'strin"
  },
  {
    "path": "packages/mini/test/index.test.js",
    "chars": 725,
    "preview": "const _ = require('./utils')\n\ntest('render', async () => {\n  const componentId = _.load('index', 'comp')\n  const compone"
  },
  {
    "path": "packages/mini/test/utils.js",
    "chars": 832,
    "preview": "const fs = require('fs')\nconst path = require('path')\nconst simulate = require('miniprogram-simulate')\nconst config = re"
  },
  {
    "path": "packages/mini/test/wx.test.js",
    "chars": 413,
    "preview": "const _ = require('./utils')\n\ntest('wx.getSystemInfo', async () => {\n  wx.getSystemInfo({\n    success(res) {\n      expec"
  },
  {
    "path": "packages/mini/tools/build.js",
    "chars": 10592,
    "preview": "const path = require('path')\nconst fs = require('fs')\n\nconst gulp = require('gulp')\nconst clean = require('gulp-clean')\n"
  },
  {
    "path": "packages/mini/tools/checkcomponents.js",
    "chars": 2948,
    "preview": "const path = require('path')\n\nconst _ = require('./utils')\nconst config = require('./config')\n\nconst srcPath = config.sr"
  },
  {
    "path": "packages/mini/tools/checkwxss.js",
    "chars": 2569,
    "preview": "const path = require('path')\nconst through = require('through2')\nconst Vinyl = require('vinyl')\n\nconst _ = require('./ut"
  },
  {
    "path": "packages/mini/tools/config.js",
    "chars": 2222,
    "preview": "const path = require('path')\n\nconst webpack = require('webpack')\nconst nodeExternals = require('webpack-node-externals')"
  },
  {
    "path": "packages/mini/tools/demo/app.js",
    "chars": 8,
    "preview": "App({})\n"
  },
  {
    "path": "packages/mini/tools/demo/app.json",
    "chars": 600,
    "preview": "{\n  \"pages\":[\n    \"pages/index/index\",\n    \"pages/yyjk/index\",\n    \"pages/ymc/index\",\n    \"pages/cjl/index\",\n    \"pages/"
  },
  {
    "path": "packages/mini/tools/demo/app.wxss",
    "chars": 573,
    "preview": ".box {\n  width: 100%;\n  min-height: 100vh;\n  position: relative;\n  background-color: #dc415f;\n  background-image: url(\"d"
  },
  {
    "path": "packages/mini/tools/demo/package.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/cjl/img.js",
    "chars": 260843,
    "preview": "export default {\n  '0.png': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAgAElEQVR4Xu19CZQb1Znud"
  },
  {
    "path": "packages/mini/tools/demo/pages/cjl/index.js",
    "chars": 1885,
    "preview": "import imgs from './img'\nPage({\n  data: {\n    prizes: [],\n    buttons: [{\n      radius: '40px',\n      imgs: [{ src: imgs"
  },
  {
    "path": "packages/mini/tools/demo/pages/cjl/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/cjl/index.wxml",
    "chars": 326,
    "preview": "<view class=\"box\">\n  <lucky-wheel\n    class=\"my-lucky\"\n    id=\"lucky-wheel\"\n    width=\"600rpx\"\n    height=\"600rpx\"\n    b"
  },
  {
    "path": "packages/mini/tools/demo/pages/cjl/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/pages/index/index.js",
    "chars": 4030,
    "preview": "Page({\n  data: {\n    prizes: [],\n    wheel: {\n      defaultStyle: {\n        fontColor: '#ff625b',\n        fontSize: '16p"
  },
  {
    "path": "packages/mini/tools/demo/pages/index/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/index/index.wxml",
    "chars": 1106,
    "preview": "<view class=\"box\">\n  <view class=\"center\" style=\"padding: 20px 0\">\n    该小程序为示例 demo | 官网: 100px.net\n  </view>\n  <view cl"
  },
  {
    "path": "packages/mini/tools/demo/pages/index/index.wxss",
    "chars": 714,
    "preview": ".box {\n  background-color: #dc415f;\n  background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg"
  },
  {
    "path": "packages/mini/tools/demo/pages/jd/img.js",
    "chars": 105295,
    "preview": "export default {\n  '0.png': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAAEH5aXCAAAAAXNSR0IArs4c6QAAPPtJR"
  },
  {
    "path": "packages/mini/tools/demo/pages/jd/index.js",
    "chars": 1862,
    "preview": "import imgs from './img'\nPage({\n  data: {\n    blocks: [\n      { padding: '30px', imgs: [{ src: imgs['bg.png'], width: '1"
  },
  {
    "path": "packages/mini/tools/demo/pages/jd/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/jd/index.wxml",
    "chars": 352,
    "preview": "<view class=\"box\">\n  <lucky-wheel\n    class=\"my-lucky\"\n    style=\"width: 650rpx\"\n    id=\"lucky-wheel\"\n    width=\"650rpx\""
  },
  {
    "path": "packages/mini/tools/demo/pages/jd/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/pages/slot/index.js",
    "chars": 2042,
    "preview": "Page({\n  data: {\n    maskShow: false,\n    prizes: [],\n    slots: [],\n    defaultStyle: {\n      fontColor: '#ff625b',\n   "
  },
  {
    "path": "packages/mini/tools/demo/pages/slot/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/slot/index.wxml",
    "chars": 395,
    "preview": "<view class=\"box\">\n  <view>\n    <slot-machine\n      class=\"my-lucky\"\n      id=\"slot-machine\"\n      width=\"600rpx\"\n      "
  },
  {
    "path": "packages/mini/tools/demo/pages/slot/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/pages/xc/img.js",
    "chars": 509867,
    "preview": "export default {\n  'btn.png': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANcAAAEHCAYAAAA9NNMuAACAAElEQVR42uydd3wUR7L"
  },
  {
    "path": "packages/mini/tools/demo/pages/xc/index.js",
    "chars": 1029,
    "preview": "import imgs from './img'\nPage({\n  data: {\n    prizes: [\n      { name: '免费住酒店' },\n      { name: '房型升级' },\n      { name: '"
  },
  {
    "path": "packages/mini/tools/demo/pages/xc/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/xc/index.wxml",
    "chars": 326,
    "preview": "<view class=\"box\">\n  <lucky-wheel\n    class=\"my-lucky\"\n    id=\"lucky-wheel\"\n    width=\"600rpx\"\n    height=\"600rpx\"\n    b"
  },
  {
    "path": "packages/mini/tools/demo/pages/xc/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/pages/xdf/img.js",
    "chars": 31402,
    "preview": "export default {\n  '0.png': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcCAYAAADj79JYAAAACXBIWXMAAAsTAAALEwEAm"
  },
  {
    "path": "packages/mini/tools/demo/pages/xdf/index.js",
    "chars": 2402,
    "preview": "import imgs from './img'\nPage({\n  data: {\n    blocks: [\n      { padding: '3px', background: '#92c53a', borderRadius: '8p"
  },
  {
    "path": "packages/mini/tools/demo/pages/xdf/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/xdf/index.wxml",
    "chars": 356,
    "preview": "<view class=\"box\">\n  <lucky-grid\n    class=\"my-lucky\"\n    id=\"lucky-grid\"\n    width=\"600rpx\"\n    height=\"600rpx\"\n    blo"
  },
  {
    "path": "packages/mini/tools/demo/pages/xdf/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/pages/ymc/img.js",
    "chars": 450039,
    "preview": "export default {\n  '0.png': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC8CAYAAADRnoRfAAAgAElEQVR4Xuy9WbBd13km9"
  },
  {
    "path": "packages/mini/tools/demo/pages/ymc/index.js",
    "chars": 2786,
    "preview": "import imgs from './img'\nPage({\n  data: {\n    maskShow: false,\n    prizes: [],\n    defaultStyle: {\n      fontColor: '#ff"
  },
  {
    "path": "packages/mini/tools/demo/pages/ymc/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/ymc/index.wxml",
    "chars": 411,
    "preview": "<view class=\"box\">\n  <view>\n    <lucky-wheel\n      class=\"my-lucky\"\n      id=\"lucky-wheel\"\n      width=\"600rpx\"\n      he"
  },
  {
    "path": "packages/mini/tools/demo/pages/ymc/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/pages/yx/img.js",
    "chars": 292745,
    "preview": "export default {\n  'default-0.png': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANwAAADcCAYAAAAbWs+BAAAgAElEQVR4nO2dC"
  },
  {
    "path": "packages/mini/tools/demo/pages/yx/index.js",
    "chars": 1846,
    "preview": "import imgs from './img'\nPage({\n  data: {\n    prizes: [],\n    blocks: [\n      { padding: '1px', background: '#e2cea3', b"
  },
  {
    "path": "packages/mini/tools/demo/pages/yx/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/yx/index.wxml",
    "chars": 318,
    "preview": "<view class=\"box\">\n  <lucky-grid\n    class=\"my-lucky\"\n    id=\"lucky-grid\"\n    width=\"600rpx\"\n    height=\"600rpx\"\n    blo"
  },
  {
    "path": "packages/mini/tools/demo/pages/yx/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/pages/yyjk/index.js",
    "chars": 2260,
    "preview": "import imgs from '../ymc/img'\nPage({\n  data: {\n    maskShow: false,\n    prizes: [],\n    blocks: [\n      { padding: '15px"
  },
  {
    "path": "packages/mini/tools/demo/pages/yyjk/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/yyjk/index.wxml",
    "chars": 482,
    "preview": "<view class=\"box\">\n  <view>\n    <lucky-grid\n      class=\"my-lucky\"\n      id=\"lucky-grid\"\n      width=\"600rpx\"\n      heig"
  },
  {
    "path": "packages/mini/tools/demo/pages/yyjk/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/pages/yyx/img.js",
    "chars": 96072,
    "preview": "export default {\n  '1.png': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAMAAAAL34HQAAADAFBMVEUAAAAbVUcOUTwbV"
  },
  {
    "path": "packages/mini/tools/demo/pages/yyx/index.js",
    "chars": 2377,
    "preview": "import imgs from './img'\nPage({\n  data: {\n    prizes: [],\n    blocks: [\n      { padding: '1px', background: '#192b2c', b"
  },
  {
    "path": "packages/mini/tools/demo/pages/yyx/index.json",
    "chars": 2,
    "preview": "{}"
  },
  {
    "path": "packages/mini/tools/demo/pages/yyx/index.wxml",
    "chars": 318,
    "preview": "<view class=\"box\">\n  <lucky-grid\n    class=\"my-lucky\"\n    id=\"lucky-grid\"\n    width=\"600rpx\"\n    height=\"600rpx\"\n    blo"
  },
  {
    "path": "packages/mini/tools/demo/pages/yyx/index.wxss",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "packages/mini/tools/demo/project.config.json",
    "chars": 566,
    "preview": "{\n\t\"description\": \"项目配置文件。\",\n\t\"packOptions\": {\n\t\t\"ignore\": []\n\t},\n\t\"setting\": {\n\t\t\"urlCheck\": true,\n\t\t\"es6\": true,\n\t\t\"po"
  },
  {
    "path": "packages/mini/tools/utils.js",
    "chars": 4275,
    "preview": "const fs = require('fs')\nconst path = require('path')\n\n// eslint-disable-next-line no-unused-vars\nconst colors = require"
  },
  {
    "path": "packages/mini/tsconfig.json",
    "chars": 542,
    "preview": "{\n  \"compilerOptions\": {\n    \"module\": \"esnext\",\n    \"target\": \"es2015\",\n    \"lib\": [\"es2015\", \"es2017\", \"dom\"],\n    \"no"
  },
  {
    "path": "packages/react/.babelrc",
    "chars": 73,
    "preview": "{\n  \"presets\": [\n    \"@babel/preset-env\",\n    \"@babel/preset-react\"\n  ]\n}"
  },
  {
    "path": "packages/react/.gitignore",
    "chars": 241,
    "preview": ".DS_Store\nnode_modules\nyarn.lock\npackage-lock.json\ndist\n\n# local env files\n.env.local\n.env.*.local\n\n# Log files\nnpm-debu"
  },
  {
    "path": "packages/react/.npmignore",
    "chars": 1,
    "preview": "*"
  },
  {
    "path": "packages/react/LICENSE",
    "chars": 11344,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "packages/react/README.md",
    "chars": 1371,
    "preview": "\n<div align=\"center\">\n  <img src=\"https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.png\" width=\"128\" alt=\"logo\" />\n  <h1>"
  },
  {
    "path": "packages/react/example/react16.8.html",
    "chars": 2336,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=e"
  },
  {
    "path": "packages/react/example/react18.0.html",
    "chars": 2353,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=e"
  },
  {
    "path": "packages/react/package.json",
    "chars": 1290,
    "preview": "{\n  \"name\": \"@lucky-canvas/react\",\n  \"version\": \"0.1.13\",\n  \"description\": \"react ( 大转盘 / 九宫格 / 老虎机 ) 抽奖插件\",\n  \"main\": \""
  },
  {
    "path": "packages/react/rollup.config.build.js",
    "chars": 770,
    "preview": "import pkg from './package.json'\nimport json from '@rollup/plugin-json'\nimport resolve from '@rollup/plugin-node-resolve"
  },
  {
    "path": "packages/react/rollup.config.dev.js",
    "chars": 901,
    "preview": "import pkg from './package.json'\nimport json from '@rollup/plugin-json'\nimport resolve from '@rollup/plugin-node-resolve"
  },
  {
    "path": "packages/react/src/app.js",
    "chars": 349,
    "preview": "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport LuckyWheel from './demo/LuckyWheel';\nimport LuckyGri"
  },
  {
    "path": "packages/react/src/components/LuckyGrid.js",
    "chars": 2224,
    "preview": "import React from 'react'\nimport { LuckyGrid as Grid } from 'lucky-canvas'\nimport { name, version } from '../../package."
  },
  {
    "path": "packages/react/src/components/LuckyWheel.js",
    "chars": 2001,
    "preview": "import React from 'react'\nimport { LuckyWheel as Wheel } from 'lucky-canvas'\nimport { name, version } from '../../packag"
  },
  {
    "path": "packages/react/src/components/SlotMachine.js",
    "chars": 1995,
    "preview": "import React from 'react'\nimport { SlotMachine as Slot } from 'lucky-canvas'\nimport { name, version } from '../../packag"
  },
  {
    "path": "packages/react/src/demo/LuckyGrid.js",
    "chars": 2892,
    "preview": "import LuckyGrid from '../components/LuckyGrid.js'\nimport React from 'react'\n\nexport default class GridDemo extends Reac"
  },
  {
    "path": "packages/react/src/demo/LuckyWheel.js",
    "chars": 1732,
    "preview": "import LuckyWheel  from '../components/LuckyWheel.js'\nimport React from 'react'\n\nexport default class Wheel extends Reac"
  },
  {
    "path": "packages/react/src/demo/SlotMachine.js",
    "chars": 2544,
    "preview": "import SlotMachine from '../components/SlotMachine.js'\nimport React from 'react'\n\nexport default class SlotDemo extends "
  },
  {
    "path": "packages/react/src/index.js",
    "chars": 201,
    "preview": "export { default as LuckyWheel } from './components/LuckyWheel.js'\nexport { default as LuckyGrid } from './components/Lu"
  },
  {
    "path": "packages/taro/.gitignore",
    "chars": 236,
    "preview": ".DS_Store\nnode_modules\nyarn.lock\npackage-lock.json\n\n# local env files\n.env.local\n.env.*.local\n\n# Log files\nnpm-debug.log"
  },
  {
    "path": "packages/taro/.npmignore",
    "chars": 1,
    "preview": "*"
  },
  {
    "path": "packages/taro/LICENSE",
    "chars": 11344,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "packages/taro/README.md",
    "chars": 2708,
    "preview": "\n<div align=\"center\">\n  <img src=\"https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.jpg\" width=\"210\" alt=\"logo\" />\n  <h1>"
  },
  {
    "path": "packages/taro/package.json",
    "chars": 680,
    "preview": "{\n  \"name\": \"@lucky-canvas/taro\",\n  \"version\": \"0.0.14\",\n  \"description\": \"基于 taro 实现的大转盘 / 九宫格 / 老虎机抽奖插件\",\n  \"main\": \"i"
  },
  {
    "path": "packages/taro/react/LuckyGrid.js",
    "chars": 7299,
    "preview": "import React from 'react'\nimport Taro from '@tarojs/taro'\nimport { View, Canvas, Image } from '@tarojs/components'\nimpor"
  },
  {
    "path": "packages/taro/react/LuckyWheel.js",
    "chars": 6565,
    "preview": "import React from 'react'\nimport Taro from '@tarojs/taro'\nimport { View, Canvas, Image } from '@tarojs/components'\nimpor"
  },
  {
    "path": "packages/taro/react/SlotMachine.js",
    "chars": 5324,
    "preview": "import React from 'react'\nimport Taro from '@tarojs/taro'\nimport { View, Canvas, Image } from '@tarojs/components'\nimpor"
  },
  {
    "path": "packages/taro/react/index.js",
    "chars": 168,
    "preview": "export { default as LuckyWheel } from './LuckyWheel.js'\nexport { default as LuckyGrid } from './LuckyGrid.js'\nexport { d"
  },
  {
    "path": "packages/taro/utils/index.css",
    "chars": 556,
    "preview": ".lucky-box {\n  position: relative;\n  overflow: hidden;\n  margin: 0 auto;\n}\n.lucky-box .lucky-canvas {\n  position: absolu"
  },
  {
    "path": "packages/taro/utils/index.js",
    "chars": 2133,
    "preview": "import Taro from '@tarojs/taro'\n\nconst windowWidth = Taro.getSystemInfoSync().windowWidth\n\nexport const getFlag = () => "
  },
  {
    "path": "packages/taro/vue/LuckyGrid.vue",
    "chars": 7243,
    "preview": "<template>\n  <view class=\"lucky-box\" :style=\"{ width: boxWidth + 'px', height: boxHeight + 'px' }\">\n    <canvas\n      ty"
  },
  {
    "path": "packages/taro/vue/LuckyWheel.vue",
    "chars": 6223,
    "preview": "<template>\n  <view class=\"lucky-box\" :style=\"{ width: boxWidth + 'px', height: boxHeight + 'px' }\">\n    <canvas\n      ty"
  },
  {
    "path": "packages/taro/vue/SlotMachine.vue",
    "chars": 5110,
    "preview": "<template>\n  <view class=\"lucky-box\" :style=\"{ width: boxWidth + 'px', height: boxHeight + 'px' }\">\n    <canvas\n      ty"
  },
  {
    "path": "packages/taro/vue/index.js",
    "chars": 171,
    "preview": "export { default as LuckyWheel } from './LuckyWheel.vue'\nexport { default as LuckyGrid } from './LuckyGrid.vue'\nexport {"
  },
  {
    "path": "packages/uni/.gitignore",
    "chars": 263,
    "preview": ".DS_Store\nnode_modules\nyarn.lock\npackage-lock.json\n\n# local env files\n.env.local\n.env.*.local\n\n# Log files\nnpm-debug.log"
  },
  {
    "path": "packages/uni/.npmignore",
    "chars": 1,
    "preview": "*"
  },
  {
    "path": "packages/uni/LICENSE",
    "chars": 11344,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "packages/uni/README.md",
    "chars": 5048,
    "preview": "<br />\n\n<div align=\"center\">\n  <img src=\"https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.jpg\" width=\"210\" alt=\"logo\" />"
  },
  {
    "path": "packages/uni/lucky-grid.vue",
    "chars": 9186,
    "preview": "<template>\n  <view v-if=\"isShow\" class=\"lucky-box\" :style=\"{ width: boxWidth + 'px', height: boxHeight + 'px' }\">\n    <c"
  },
  {
    "path": "packages/uni/lucky-wheel.vue",
    "chars": 7069,
    "preview": "<template>\n  <view v-if=\"isShow\" class=\"lucky-box\" :style=\"{ width: boxWidth + 'px', height: boxHeight + 'px' }\">\n    <c"
  },
  {
    "path": "packages/uni/package.json",
    "chars": 456,
    "preview": "{\n  \"name\": \"@lucky-canvas/uni\",\n  \"version\": \"0.0.13\",\n  \"description\": \"uni-app【大转盘 / 九宫格 / 老虎机】抽奖插件\",\n  \"scripts\": {\n"
  },
  {
    "path": "packages/uni/slot-machine.vue",
    "chars": 5598,
    "preview": "<template>\n  <view v-if=\"isShow\" class=\"lucky-box\" :style=\"{ width: boxWidth + 'px', height: boxHeight + 'px' }\">\n    <c"
  },
  {
    "path": "packages/uni/utils.js",
    "chars": 1972,
    "preview": "let windowWidth = uni.getSystemInfoSync().windowWidth\n// uni-app@2.9起, 屏幕最多适配到960, 超出则按375计算\nif (windowWidth > 960) wind"
  },
  {
    "path": "packages/vue/.gitignore",
    "chars": 253,
    "preview": "\n.DS_Store\n*.zip\n*.tgz\nnode_modules\ndist\nyarn.lock\npackage-lock.json\n\n# local env files\n.env.local\n.env.*.local\n\n# Log f"
  },
  {
    "path": "packages/vue/.npmignore",
    "chars": 1,
    "preview": "*"
  },
  {
    "path": "packages/vue/LICENSE",
    "chars": 11343,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "packages/vue/README.md",
    "chars": 4074,
    "preview": "\n<div align=\"center\">\n  <img src=\"https://unpkg.com/buuing@0.0.1/imgs/lucky-canvas.png\" width=\"128\" alt=\"logo\" />\n  <h1>"
  },
  {
    "path": "packages/vue/composition-api.js",
    "chars": 20889,
    "preview": "if (window.Vue && Vue.version.slice(0, 2) === '2.') {\n\n!function(n,t){\"object\"==typeof exports&&\"undefined\"!=typeof modu"
  },
  {
    "path": "packages/vue/index.js",
    "chars": 47,
    "preview": "module.exports = require('./dist/index.esm.js')"
  },
  {
    "path": "packages/vue/package.json",
    "chars": 1592,
    "preview": "{\n  \"name\": \"@lucky-canvas/vue\",\n  \"version\": \"0.1.11\",\n  \"description\": \"一个支持 vue2 / vue3 的(大转盘 / 九宫格 / 老虎机)luckydraw 抽"
  },
  {
    "path": "packages/vue/rollup.config.build.js",
    "chars": 1251,
    "preview": "import ts from 'rollup-plugin-typescript2'\nimport dts from 'rollup-plugin-dts'\nimport commonjs from '@rollup/plugin-comm"
  },
  {
    "path": "packages/vue/rollup.config.dev.js",
    "chars": 780,
    "preview": "import ts from 'rollup-plugin-typescript2'\nimport commonjs from '@rollup/plugin-commonjs'\nimport json from '@rollup/plug"
  },
  {
    "path": "packages/vue/shims-vue.d.ts",
    "chars": 257,
    "preview": "declare module '*.vue' {\n  import type { DefineComponent } from 'vue'\n  const component: DefineComponent<{}, {}, any>\n  "
  },
  {
    "path": "packages/vue/src/components/LuckyGrid.ts",
    "chars": 3061,
    "preview": "import { defineComponent } from 'vue-demi'\nimport { LuckyGrid } from 'lucky-canvas'\nimport h from \"../utils/h-demi\"\n// @"
  },
  {
    "path": "packages/vue/src/components/LuckyWheel.ts",
    "chars": 2510,
    "preview": "import { defineComponent } from 'vue-demi'\nimport { LuckyWheel } from 'lucky-canvas'\nimport h from \"../utils/h-demi\"\n// "
  },
  {
    "path": "packages/vue/src/components/SlotMachine.ts",
    "chars": 2428,
    "preview": "import { defineComponent } from 'vue-demi'\nimport { SlotMachine } from 'lucky-canvas'\nimport h from \"../utils/h-demi\"\n//"
  },
  {
    "path": "packages/vue/src/index.ts",
    "chars": 550,
    "preview": "import { isVue2 } from \"vue-demi\"\nimport LuckyWheel from \"./components/LuckyWheel\"\nimport LuckyGrid from \"./components/L"
  },
  {
    "path": "packages/vue/src/utils/h-demi.ts",
    "chars": 838,
    "preview": "// @ts-nocheck\nimport { h as hDemi, isVue2 } from 'vue-demi'\n\ninterface Options {\n  props?: Object,\n  domProps?: Object\n"
  },
  {
    "path": "packages/vue/tsconfig.json",
    "chars": 599,
    "preview": "{\n  \"compilerOptions\": {\n    \"target\": \"ES5\",\n    \"module\": \"ESNext\",\n    \"strict\": true,\n    \"jsx\": \"preserve\",\n    \"im"
  },
  {
    "path": "packages/vue/types/index.d.ts",
    "chars": 6624,
    "preview": "import * as vue_demi from 'vue-demi';\nimport { LuckyWheel, LuckyGrid, SlotMachine } from 'lucky-canvas';\n\ndeclare const "
  },
  {
    "path": "packages/vue/vue-demi.js",
    "chars": 1738,
    "preview": ";(function (window) {\n  if (window.VueDemi) {\n    return\n  }\n  var VueDemi = {}\n  var Vue = window.Vue\n  if (Vue) {\n    "
  },
  {
    "path": "packages/vue/vue2.html",
    "chars": 2836,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">"
  },
  {
    "path": "packages/vue/vue3.html",
    "chars": 2168,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">"
  }
]

About this extraction

This page contains the full source code of the buuing/lucky-canvas GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 186 files (2.1 MB), approximately 561.0k tokens, and a symbol index with 477 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!