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.
Files changed (84) hide show
  1. package/AUTHORS.txt +6 -6
  2. package/CHANGELOG +19 -1
  3. package/LICENSE +20 -20
  4. package/README.md +53 -53
  5. package/lib/Canvas/index.umd.js +91 -14
  6. package/lib/Canvas/index.umd.min.js +7 -3
  7. package/lib/Cardinal/index.umd.js +6 -2
  8. package/lib/Cardinal/index.umd.min.js +6 -2
  9. package/lib/Eoap/index.umd.js +6 -2
  10. package/lib/Eoap/index.umd.min.js +6 -2
  11. package/lib/Hermite/index.umd.js +6 -2
  12. package/lib/Hermite/index.umd.min.js +6 -2
  13. package/lib/Matrix4/index.umd.js +6 -2
  14. package/lib/Matrix4/index.umd.min.js +6 -2
  15. package/lib/Mercator/index.umd.js +6 -2
  16. package/lib/Mercator/index.umd.min.js +6 -2
  17. package/lib/OralCanvas/index.es.js +91 -14
  18. package/lib/OralCanvas/index.es.min.js +7 -3
  19. package/lib/OralWebGL/index.es.js +8 -2
  20. package/lib/OralWebGL/index.es.min.js +6 -2
  21. package/lib/SVG/index.umd.js +82 -62
  22. package/lib/SVG/index.umd.min.js +7 -3
  23. package/lib/WebGL/index.umd.js +6 -2
  24. package/lib/WebGL/index.umd.min.js +6 -2
  25. package/lib/animation/index.umd.js +6 -2
  26. package/lib/animation/index.umd.min.js +6 -2
  27. package/lib/getLoopColors/index.umd.js +6 -2
  28. package/lib/getLoopColors/index.umd.min.js +6 -2
  29. package/lib/index.umd.js +167 -74
  30. package/lib/index.umd.min.js +7 -3
  31. package/lib/rotate/index.umd.js +6 -2
  32. package/lib/rotate/index.umd.min.js +6 -2
  33. package/lib/ruler/index.umd.js +6 -2
  34. package/lib/ruler/index.umd.min.js +6 -2
  35. package/lib/viewHandler/index.umd.js +6 -2
  36. package/lib/viewHandler/index.umd.min.js +6 -2
  37. package/miniprogram/ui-canvas/index.json +4 -4
  38. package/miniprogram/ui-canvas/index.wxml +4 -4
  39. package/miniprogram/ui-canvas/index.wxss +5 -5
  40. package/package/Canvas/index.ts +1 -1
  41. package/package/Cardinal/index.ts +2 -2
  42. package/package/Eoap/index.ts +2 -2
  43. package/package/Hermite/index.ts +2 -2
  44. package/package/Matrix4/index.ts +2 -2
  45. package/package/OralCanvas/index.ts +1 -1
  46. package/package/OralWebGL/index.ts +1 -1
  47. package/package/SVG/index.ts +2 -2
  48. package/package/animation/index.ts +2 -2
  49. package/package/getLoopColors/index.ts +2 -2
  50. package/package/rotate/index.ts +2 -2
  51. package/package/ruler/index.ts +2 -2
  52. package/package.json +4 -4
  53. package/src/Matrix4/index.ts +76 -76
  54. package/src/Matrix4/move.ts +12 -12
  55. package/src/Matrix4/rotate.ts +15 -15
  56. package/src/Matrix4/scale.ts +11 -11
  57. package/src/Matrix4/transform.ts +64 -64
  58. package/src/animation.ts +99 -99
  59. package/src/common/canvas/arc.ts +50 -50
  60. package/src/common/canvas/config.ts +142 -61
  61. package/src/common/canvas/gradient.ts +29 -0
  62. package/src/common/canvas/index.ts +122 -82
  63. package/src/common/canvas/painter.ts +12 -0
  64. package/src/common/setStyle.ts +5 -5
  65. package/src/common/svg/config.ts +173 -128
  66. package/src/common/svg/index.ts +315 -266
  67. package/src/common/svg/tool.ts +43 -43
  68. package/src/getLoopColors.ts +42 -42
  69. package/src/interpolation/Cardinal.ts +91 -91
  70. package/src/interpolation/Hermite.ts +65 -65
  71. package/src/rotate.ts +7 -7
  72. package/src/ruler.ts +99 -99
  73. package/types/Canvas.d.ts +282 -221
  74. package/types/CanvasConfig.d.ts +3 -3
  75. package/types/Cardinal.d.ts +13 -13
  76. package/types/Gradient.d.ts +15 -0
  77. package/types/Hermite.d.ts +18 -18
  78. package/types/Matrix4.d.ts +42 -42
  79. package/types/SVG.d.ts +210 -210
  80. package/types/animation.d.ts +6 -6
  81. package/types/getLoopColors.d.ts +2 -2
  82. package/types/rotate.d.ts +2 -2
  83. package/types/ruler.d.ts +2 -2
  84. 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
+ }