vislite 0.2.0 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORS.txt +6 -6
- package/CHANGELOG +19 -1
- package/LICENSE +20 -20
- package/README.md +53 -53
- package/lib/Canvas/index.umd.js +91 -14
- package/lib/Canvas/index.umd.min.js +7 -3
- package/lib/Cardinal/index.umd.js +6 -2
- package/lib/Cardinal/index.umd.min.js +6 -2
- package/lib/Eoap/index.umd.js +6 -2
- package/lib/Eoap/index.umd.min.js +6 -2
- package/lib/Hermite/index.umd.js +6 -2
- package/lib/Hermite/index.umd.min.js +6 -2
- package/lib/Matrix4/index.umd.js +6 -2
- package/lib/Matrix4/index.umd.min.js +6 -2
- package/lib/Mercator/index.umd.js +6 -2
- package/lib/Mercator/index.umd.min.js +6 -2
- package/lib/OralCanvas/index.es.js +91 -14
- package/lib/OralCanvas/index.es.min.js +7 -3
- package/lib/OralWebGL/index.es.js +8 -2
- package/lib/OralWebGL/index.es.min.js +6 -2
- package/lib/SVG/index.umd.js +82 -62
- package/lib/SVG/index.umd.min.js +7 -3
- package/lib/WebGL/index.umd.js +6 -2
- package/lib/WebGL/index.umd.min.js +6 -2
- package/lib/animation/index.umd.js +6 -2
- package/lib/animation/index.umd.min.js +6 -2
- package/lib/getLoopColors/index.umd.js +6 -2
- package/lib/getLoopColors/index.umd.min.js +6 -2
- package/lib/index.umd.js +167 -74
- package/lib/index.umd.min.js +7 -3
- package/lib/rotate/index.umd.js +6 -2
- package/lib/rotate/index.umd.min.js +6 -2
- package/lib/ruler/index.umd.js +6 -2
- package/lib/ruler/index.umd.min.js +6 -2
- package/lib/viewHandler/index.umd.js +6 -2
- package/lib/viewHandler/index.umd.min.js +6 -2
- package/miniprogram/ui-canvas/index.json +4 -4
- package/miniprogram/ui-canvas/index.wxml +4 -4
- package/miniprogram/ui-canvas/index.wxss +5 -5
- package/package/Canvas/index.ts +1 -1
- package/package/Cardinal/index.ts +2 -2
- package/package/Eoap/index.ts +2 -2
- package/package/Hermite/index.ts +2 -2
- package/package/Matrix4/index.ts +2 -2
- package/package/OralCanvas/index.ts +1 -1
- package/package/OralWebGL/index.ts +1 -1
- package/package/SVG/index.ts +2 -2
- package/package/animation/index.ts +2 -2
- package/package/getLoopColors/index.ts +2 -2
- package/package/rotate/index.ts +2 -2
- package/package/ruler/index.ts +2 -2
- package/package.json +4 -4
- package/src/Matrix4/index.ts +76 -76
- package/src/Matrix4/move.ts +12 -12
- package/src/Matrix4/rotate.ts +15 -15
- package/src/Matrix4/scale.ts +11 -11
- package/src/Matrix4/transform.ts +64 -64
- package/src/animation.ts +99 -99
- package/src/common/canvas/arc.ts +50 -50
- package/src/common/canvas/config.ts +142 -61
- package/src/common/canvas/gradient.ts +29 -0
- package/src/common/canvas/index.ts +122 -82
- package/src/common/canvas/painter.ts +12 -0
- package/src/common/setStyle.ts +5 -5
- package/src/common/svg/config.ts +173 -128
- package/src/common/svg/index.ts +315 -266
- package/src/common/svg/tool.ts +43 -43
- package/src/getLoopColors.ts +42 -42
- package/src/interpolation/Cardinal.ts +91 -91
- package/src/interpolation/Hermite.ts +65 -65
- package/src/rotate.ts +7 -7
- package/src/ruler.ts +99 -99
- package/types/Canvas.d.ts +282 -221
- package/types/CanvasConfig.d.ts +3 -3
- package/types/Cardinal.d.ts +13 -13
- package/types/Gradient.d.ts +15 -0
- package/types/Hermite.d.ts +18 -18
- package/types/Matrix4.d.ts +42 -42
- package/types/SVG.d.ts +210 -210
- package/types/animation.d.ts +6 -6
- package/types/getLoopColors.d.ts +2 -2
- package/types/rotate.d.ts +2 -2
- package/types/ruler.d.ts +2 -2
- package/uni-app/ui-canvas.vue +22 -46
package/src/ruler.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
// 刻度尺刻度求解
|
|
2
|
-
|
|
3
|
-
// 需要注意的是,实际的间距个数可能是 num-1 或 num 或 num+1 或 1
|
|
4
|
-
export default function (maxValue: number, minValue: number, num: number) {
|
|
5
|
-
|
|
6
|
-
// 如果最大值最小值反了
|
|
7
|
-
if (maxValue < minValue) {
|
|
8
|
-
let temp = minValue
|
|
9
|
-
minValue = maxValue
|
|
10
|
-
maxValue = temp
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// 如果相等
|
|
14
|
-
else if (maxValue == minValue) {
|
|
15
|
-
return [maxValue]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// 为了变成 -100 ~ 100 需要放大或者缩小的倍数
|
|
19
|
-
let times100 =
|
|
20
|
-
|
|
21
|
-
(function (_value) {
|
|
22
|
-
|
|
23
|
-
// 先确定基调,是放大还是缩小
|
|
24
|
-
let _times100_base = (_value < 100 && _value > -100) ? 10 : 0.1
|
|
25
|
-
|
|
26
|
-
// 记录当前缩放倍数
|
|
27
|
-
let _times100 = -1, _tiemsValue = _value
|
|
28
|
-
|
|
29
|
-
while (_times100_base == 10 ?
|
|
30
|
-
// 如果是放大,超过 -100 ~ 100 就应该停止
|
|
31
|
-
(_tiemsValue >= -100 && _tiemsValue <= 100)
|
|
32
|
-
:
|
|
33
|
-
// 如果是缩小,进入 -100 ~ 100 就应该停止
|
|
34
|
-
(_tiemsValue <= -100 || _tiemsValue >= 100)
|
|
35
|
-
) {
|
|
36
|
-
|
|
37
|
-
_times100 += 1
|
|
38
|
-
_tiemsValue *= _times100_base
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (_times100_base == 10) {
|
|
43
|
-
return Math.pow(10, _times100)
|
|
44
|
-
} else {
|
|
45
|
-
|
|
46
|
-
// 解决类似 0.1 * 0.1 = 0.010000000000000002 浮点运算不准确问题
|
|
47
|
-
let temp = "0."
|
|
48
|
-
for (let i = 1; i < _times100; i++) {
|
|
49
|
-
temp += "0";
|
|
50
|
-
}
|
|
51
|
-
return +(temp + "1")
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
// 根据差值来缩放
|
|
56
|
-
(maxValue - minValue)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// 求解出 -100 ~ 100 的最佳间距值 后直接转换原来的倍数
|
|
60
|
-
let distance100 = Math.ceil((maxValue - minValue) * times100 / num)
|
|
61
|
-
|
|
62
|
-
// 校对一下
|
|
63
|
-
distance100 = {
|
|
64
|
-
3: 2,
|
|
65
|
-
4: 5,
|
|
66
|
-
6: 5,
|
|
67
|
-
7: 5,
|
|
68
|
-
8: 10,
|
|
69
|
-
9: 10,
|
|
70
|
-
11: 10,
|
|
71
|
-
12: 10,
|
|
72
|
-
13: 15,
|
|
73
|
-
14: 15,
|
|
74
|
-
16: 15,
|
|
75
|
-
17: 15,
|
|
76
|
-
18: 20,
|
|
77
|
-
19: 20,
|
|
78
|
-
21: 20,
|
|
79
|
-
22: 20,
|
|
80
|
-
23: 25,
|
|
81
|
-
24: 25,
|
|
82
|
-
26: 25,
|
|
83
|
-
27: 25
|
|
84
|
-
}[distance100] || distance100
|
|
85
|
-
|
|
86
|
-
let distance = distance100 / times100
|
|
87
|
-
|
|
88
|
-
// 最小值,也就是起点
|
|
89
|
-
let begin = Math.floor(minValue / distance) * distance
|
|
90
|
-
|
|
91
|
-
let rulerArray = []
|
|
92
|
-
// 获取最终的刻度尺数组
|
|
93
|
-
rulerArray.push(begin)
|
|
94
|
-
for (let index = 1; rulerArray[rulerArray.length - 1] < maxValue; index++) {
|
|
95
|
-
rulerArray.push(begin + distance * index)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return rulerArray
|
|
99
|
-
}
|
|
1
|
+
// 刻度尺刻度求解
|
|
2
|
+
|
|
3
|
+
// 需要注意的是,实际的间距个数可能是 num-1 或 num 或 num+1 或 1
|
|
4
|
+
export default function (maxValue: number, minValue: number, num: number) {
|
|
5
|
+
|
|
6
|
+
// 如果最大值最小值反了
|
|
7
|
+
if (maxValue < minValue) {
|
|
8
|
+
let temp = minValue
|
|
9
|
+
minValue = maxValue
|
|
10
|
+
maxValue = temp
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// 如果相等
|
|
14
|
+
else if (maxValue == minValue) {
|
|
15
|
+
return [maxValue]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 为了变成 -100 ~ 100 需要放大或者缩小的倍数
|
|
19
|
+
let times100 =
|
|
20
|
+
|
|
21
|
+
(function (_value) {
|
|
22
|
+
|
|
23
|
+
// 先确定基调,是放大还是缩小
|
|
24
|
+
let _times100_base = (_value < 100 && _value > -100) ? 10 : 0.1
|
|
25
|
+
|
|
26
|
+
// 记录当前缩放倍数
|
|
27
|
+
let _times100 = -1, _tiemsValue = _value
|
|
28
|
+
|
|
29
|
+
while (_times100_base == 10 ?
|
|
30
|
+
// 如果是放大,超过 -100 ~ 100 就应该停止
|
|
31
|
+
(_tiemsValue >= -100 && _tiemsValue <= 100)
|
|
32
|
+
:
|
|
33
|
+
// 如果是缩小,进入 -100 ~ 100 就应该停止
|
|
34
|
+
(_tiemsValue <= -100 || _tiemsValue >= 100)
|
|
35
|
+
) {
|
|
36
|
+
|
|
37
|
+
_times100 += 1
|
|
38
|
+
_tiemsValue *= _times100_base
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (_times100_base == 10) {
|
|
43
|
+
return Math.pow(10, _times100)
|
|
44
|
+
} else {
|
|
45
|
+
|
|
46
|
+
// 解决类似 0.1 * 0.1 = 0.010000000000000002 浮点运算不准确问题
|
|
47
|
+
let temp = "0."
|
|
48
|
+
for (let i = 1; i < _times100; i++) {
|
|
49
|
+
temp += "0";
|
|
50
|
+
}
|
|
51
|
+
return +(temp + "1")
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// 根据差值来缩放
|
|
56
|
+
(maxValue - minValue)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// 求解出 -100 ~ 100 的最佳间距值 后直接转换原来的倍数
|
|
60
|
+
let distance100 = Math.ceil((maxValue - minValue) * times100 / num)
|
|
61
|
+
|
|
62
|
+
// 校对一下
|
|
63
|
+
distance100 = {
|
|
64
|
+
3: 2,
|
|
65
|
+
4: 5,
|
|
66
|
+
6: 5,
|
|
67
|
+
7: 5,
|
|
68
|
+
8: 10,
|
|
69
|
+
9: 10,
|
|
70
|
+
11: 10,
|
|
71
|
+
12: 10,
|
|
72
|
+
13: 15,
|
|
73
|
+
14: 15,
|
|
74
|
+
16: 15,
|
|
75
|
+
17: 15,
|
|
76
|
+
18: 20,
|
|
77
|
+
19: 20,
|
|
78
|
+
21: 20,
|
|
79
|
+
22: 20,
|
|
80
|
+
23: 25,
|
|
81
|
+
24: 25,
|
|
82
|
+
26: 25,
|
|
83
|
+
27: 25
|
|
84
|
+
}[distance100] || distance100
|
|
85
|
+
|
|
86
|
+
let distance = distance100 / times100
|
|
87
|
+
|
|
88
|
+
// 最小值,也就是起点
|
|
89
|
+
let begin = Math.floor(minValue / distance) * distance
|
|
90
|
+
|
|
91
|
+
let rulerArray = []
|
|
92
|
+
// 获取最终的刻度尺数组
|
|
93
|
+
rulerArray.push(begin)
|
|
94
|
+
for (let index = 1; rulerArray[rulerArray.length - 1] < maxValue; index++) {
|
|
95
|
+
rulerArray.push(begin + distance * index)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return rulerArray
|
|
99
|
+
}
|