(containerWidth, cycleRadius)
| 1 | class GestureLock { |
| 2 | |
| 3 | constructor(containerWidth, cycleRadius) { |
| 4 | this.containerWidth = containerWidth; // 容器宽度 |
| 5 | this.cycleRadius = cycleRadius; // 圆的半径 |
| 6 | |
| 7 | this.circleArray = []; // 全部圆的对象数组 |
| 8 | this.checkPoints = []; // 选中的圆的对象数组 |
| 9 | this.lineArray = []; // 已激活锁之间的线段数组 |
| 10 | this.lastCheckPoint = 0; // 最后一个激活的锁 |
| 11 | this.offsetX = 0; // 容器的 X 偏移 |
| 12 | this.offsetY = 0; // 容器的 Y 偏移 |
| 13 | this.activeLine = {}; // 最后一个激活的锁与当前位置之间的线段 |
| 14 | |
| 15 | this.windowWidth = wx.getSystemInfoSync().windowWidth; // 窗口大小(用于rpx 和 px 转换) |
| 16 | |
| 17 | this.initCircleArray(); |
| 18 | } |
| 19 | |
| 20 | // 初始化 画布上的 9个圆 |
| 21 | initCircleArray() { |
nothing calls this directly
no test coverage detected