vislite 1.2.0-alpha.2 → 1.2.0-alpha.4

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 (72) hide show
  1. package/CHANGELOG +266 -254
  2. package/lib/Buffer/index.es.js +1 -1
  3. package/lib/Buffer/index.es.min.js +1 -1
  4. package/lib/Canvas/index.es.js +16 -5
  5. package/lib/Canvas/index.es.min.js +2 -2
  6. package/lib/Cardinal/index.es.js +1 -1
  7. package/lib/Cardinal/index.es.min.js +1 -1
  8. package/lib/Eoap/index.es.js +1 -1
  9. package/lib/Eoap/index.es.min.js +1 -1
  10. package/lib/Hermite/index.es.js +1 -1
  11. package/lib/Hermite/index.es.min.js +1 -1
  12. package/lib/Matrix4/index.es.js +1 -1
  13. package/lib/Matrix4/index.es.min.js +1 -1
  14. package/lib/Mercator/index.es.js +1 -1
  15. package/lib/Mercator/index.es.min.js +1 -1
  16. package/lib/RawCanvas/index.es.js +15 -4
  17. package/lib/RawCanvas/index.es.min.js +2 -2
  18. package/lib/SVG/index.es.js +12 -8
  19. package/lib/SVG/index.es.min.js +2 -2
  20. package/lib/Shader/index.es.js +1 -1
  21. package/lib/Shader/index.es.min.js +1 -1
  22. package/lib/Texture/index.es.js +1 -1
  23. package/lib/Texture/index.es.min.js +1 -1
  24. package/lib/TreeLayout/index.es.js +38 -8
  25. package/lib/TreeLayout/index.es.min.js +2 -2
  26. package/lib/animation/index.es.js +38 -8
  27. package/lib/animation/index.es.min.js +2 -2
  28. package/lib/assemble/index.es.js +1 -1
  29. package/lib/assemble/index.es.min.js +1 -1
  30. package/lib/getLoopColors/index.es.js +1 -1
  31. package/lib/getLoopColors/index.es.min.js +1 -1
  32. package/lib/getWebGLContext/index.es.js +1 -1
  33. package/lib/getWebGLContext/index.es.min.js +1 -1
  34. package/lib/index.umd.js +88 -36
  35. package/lib/index.umd.min.js +2 -2
  36. package/lib/initOption/index.es.js +1 -1
  37. package/lib/initOption/index.es.min.js +1 -1
  38. package/lib/mergeOption/index.es.js +1 -1
  39. package/lib/mergeOption/index.es.min.js +1 -1
  40. package/lib/move/index.es.js +1 -1
  41. package/lib/move/index.es.min.js +1 -1
  42. package/lib/rotate/index.es.js +1 -1
  43. package/lib/rotate/index.es.min.js +1 -1
  44. package/lib/ruler/index.es.js +1 -1
  45. package/lib/ruler/index.es.min.js +1 -1
  46. package/lib/scale/index.es.js +1 -1
  47. package/lib/scale/index.es.min.js +1 -1
  48. package/lib/throttle/index.es.js +25 -25
  49. package/lib/throttle/index.es.min.js +2 -2
  50. package/miniprogram/ui-canvas/index.js +115 -115
  51. package/package/animation/index.ts +1 -1
  52. package/package/throttle/index.ts +1 -1
  53. package/package.json +7 -2
  54. package/src/Canvas.ts +84 -84
  55. package/src/common/canvas/gradient.ts +32 -24
  56. package/src/common/canvas/index.ts +182 -177
  57. package/src/common/canvas/painter.ts +9 -3
  58. package/src/common/svg/config.ts +194 -190
  59. package/src/common/svg/index.ts +350 -347
  60. package/src/common/svg/tool.ts +42 -44
  61. package/src/layout/TreeLayout.ts +1 -1
  62. package/types/Canvas.d.ts +10 -1
  63. package/types/CanvasConfig.d.ts +116 -106
  64. package/types/SVGConfig.d.ts +89 -79
  65. package/types/animation.d.ts +2 -6
  66. package/types/index.d.ts +160 -158
  67. package/types/painterConfig.d.ts +5 -3
  68. package/types/throttle.d.ts +2 -4
  69. package/types/throttleOption.d.ts +1 -22
  70. package/types/uni-canvas.d.ts +4 -0
  71. package/src/animation.ts +0 -99
  72. package/src/throttle.ts +0 -53
package/types/index.d.ts CHANGED
@@ -1,159 +1,161 @@
1
- import CardinalType from './Cardinal'
2
- import HermiteType from './Hermite'
3
-
4
- import Matrix4Type from './Matrix4'
5
- import rotateType from './rotate'
6
- import moveType from './move'
7
- import scaleType from './scale'
8
-
9
- import getLoopColorsType from './getLoopColors'
10
- import animationType from './animation'
11
- import rulerType from './ruler'
12
-
13
- import SVGType from './SVG'
14
- import CanvasType from './Canvas'
15
-
16
- import CanvasOptionType from './CanvasOption'
17
-
18
- import getWebGLContextType from './getWebGLContext'
19
- import ShaderType from './Shader'
20
- import BufferType from './Buffer'
21
- import TextureType from './Texture'
22
-
23
- import MapType from './Map'
24
-
25
- import throttleType from './throttle'
26
- import assembleType from './assemble'
27
-
28
- import TreeLayoutType from './TreeLayout'
29
- import TreeConfigType from './TreeConfig'
30
-
31
- import { initOptionType, mergeOptionType } from './option'
32
-
33
- // 插值
34
- interface NewCardinalType extends CardinalType {
35
- new(t?: number): this
36
- }
37
- interface NewHermiteType extends HermiteType {
38
- new(u?: number): this
39
- }
40
-
41
- // 变换
42
- interface NewMatrix4Type extends Matrix4Type {
43
- new(initMatrix4?: number[]): this
44
- }
45
-
46
- // 画笔
47
- interface NewSVGType extends SVGType {
48
- new(el: HTMLElement | null): this
49
- }
50
- interface NewCanvasType extends CanvasType {
51
- new(el: HTMLElement | null, option?: CanvasOptionType, width?: number, height?: number): this
52
- }
53
-
54
- // WebGL
55
- interface NewShaderType extends ShaderType {
56
- new(painter: WebGLRenderingContext): this
57
- }
58
- interface NewBufferType extends BufferType {
59
- new(painter: WebGLRenderingContext, isElement?: boolean): this
60
- }
61
- interface NewTextureType extends TextureType {
62
- new(painter: WebGLRenderingContext, type: string, unit?: number): this
63
- }
64
-
65
- // 投影
66
- interface NewEoapType extends MapType {
67
- new(scale?: number, center?: number[]): this
68
- }
69
- interface NewMercatorType extends MapType {
70
- new(scale?: number, center?: number[]): this
71
- }
72
-
73
- // 布局
74
- interface NewTreeLayoutType extends TreeLayoutType {
75
- new(config?: TreeConfigType): this
76
- }
77
-
78
- export default class VISLite {
79
-
80
- // 插值
81
- static Cardinal: NewCardinalType
82
- static Hermite: NewHermiteType
83
-
84
- // 变换
85
- static Matrix4: NewMatrix4Type
86
- static rotate: rotateType
87
- static move: moveType
88
- static scale: scaleType
89
-
90
- // 工具
91
- static getLoopColors: getLoopColorsType
92
- static animation: animationType
93
- static ruler: rulerType
94
-
95
- // 画笔
96
- static SVG: NewSVGType
97
- static Canvas: NewCanvasType
98
-
99
- // WebGL
100
- static getWebGLContext: getWebGLContextType
101
- static Shader: NewShaderType
102
- static Buffer: NewBufferType
103
- static Texture: NewTextureType
104
-
105
- // 投影
106
- static Eoap: NewEoapType
107
- static Mercator: NewMercatorType
108
-
109
- // 辅助
110
- static throttle: throttleType
111
- static assemble: assembleType
112
-
113
- // 布局
114
- static TreeLayout: NewTreeLayoutType
115
-
116
- // 配置项
117
- static initOption: initOptionType
118
- static mergeOption: mergeOptionType
119
- }
120
-
121
- // 插值
122
- export let Cardinal: NewCardinalType
123
- export let Hermite: NewHermiteType
124
-
125
- // 变换
126
- export let Matrix4: NewMatrix4Type
127
- export let rotate: rotateType
128
- export let move: moveType
129
- export let scale: scaleType
130
-
131
- // 工具
132
- export let getLoopColors: getLoopColorsType
133
- export let animation: animationType
134
- export let ruler: rulerType
135
-
136
- // 画笔
137
- export let SVG: NewSVGType
138
- export let Canvas: NewCanvasType
139
-
140
- // WebGL
141
- export let getWebGLContext: getWebGLContextType
142
- export let Shader: NewShaderType
143
- export let Buffer: NewBufferType
144
- export let Texture: NewTextureType
145
-
146
- // 投影
147
- export let Eoap: NewEoapType
148
- export let Mercator: NewMercatorType
149
-
150
- // 辅助
151
- export let throttle: throttleType
152
- export let assemble: assembleType
153
-
154
- // 布局
155
- export let TreeLayout: NewTreeLayoutType
156
-
157
- // 配置项
158
- export let initOption: initOptionType
1
+ /// <reference path="./uni-canvas.d.ts" />
2
+
3
+ import CardinalType from './Cardinal'
4
+ import HermiteType from './Hermite'
5
+
6
+ import Matrix4Type from './Matrix4'
7
+ import rotateType from './rotate'
8
+ import moveType from './move'
9
+ import scaleType from './scale'
10
+
11
+ import getLoopColorsType from './getLoopColors'
12
+ import animationType from './animation'
13
+ import rulerType from './ruler'
14
+
15
+ import SVGType from './SVG'
16
+ import CanvasType from './Canvas'
17
+
18
+ import CanvasOptionType from './CanvasOption'
19
+
20
+ import getWebGLContextType from './getWebGLContext'
21
+ import ShaderType from './Shader'
22
+ import BufferType from './Buffer'
23
+ import TextureType from './Texture'
24
+
25
+ import MapType from './Map'
26
+
27
+ import throttleType from './throttle'
28
+ import assembleType from './assemble'
29
+
30
+ import TreeLayoutType from './TreeLayout'
31
+ import TreeConfigType from './TreeConfig'
32
+
33
+ import { initOptionType, mergeOptionType } from './option'
34
+
35
+ // 插值
36
+ interface NewCardinalType extends CardinalType {
37
+ new(t?: number): this
38
+ }
39
+ interface NewHermiteType extends HermiteType {
40
+ new(u?: number): this
41
+ }
42
+
43
+ // 变换
44
+ interface NewMatrix4Type extends Matrix4Type {
45
+ new(initMatrix4?: number[]): this
46
+ }
47
+
48
+ // 画笔
49
+ interface NewSVGType extends SVGType {
50
+ new(el: HTMLElement | null): this
51
+ }
52
+ interface NewCanvasType extends CanvasType {
53
+ new(el: HTMLElement | null, option?: CanvasOptionType, width?: number, height?: number): this
54
+ }
55
+
56
+ // WebGL
57
+ interface NewShaderType extends ShaderType {
58
+ new(painter: WebGLRenderingContext): this
59
+ }
60
+ interface NewBufferType extends BufferType {
61
+ new(painter: WebGLRenderingContext, isElement?: boolean): this
62
+ }
63
+ interface NewTextureType extends TextureType {
64
+ new(painter: WebGLRenderingContext, type: string, unit?: number): this
65
+ }
66
+
67
+ // 投影
68
+ interface NewEoapType extends MapType {
69
+ new(scale?: number, center?: number[]): this
70
+ }
71
+ interface NewMercatorType extends MapType {
72
+ new(scale?: number, center?: number[]): this
73
+ }
74
+
75
+ // 布局
76
+ interface NewTreeLayoutType extends TreeLayoutType {
77
+ new(config?: TreeConfigType): this
78
+ }
79
+
80
+ export default class VISLite {
81
+
82
+ // 插值
83
+ static Cardinal: NewCardinalType
84
+ static Hermite: NewHermiteType
85
+
86
+ // 变换
87
+ static Matrix4: NewMatrix4Type
88
+ static rotate: rotateType
89
+ static move: moveType
90
+ static scale: scaleType
91
+
92
+ // 工具
93
+ static getLoopColors: getLoopColorsType
94
+ static animation: animationType
95
+ static ruler: rulerType
96
+
97
+ // 画笔
98
+ static SVG: NewSVGType
99
+ static Canvas: NewCanvasType
100
+
101
+ // WebGL
102
+ static getWebGLContext: getWebGLContextType
103
+ static Shader: NewShaderType
104
+ static Buffer: NewBufferType
105
+ static Texture: NewTextureType
106
+
107
+ // 投影
108
+ static Eoap: NewEoapType
109
+ static Mercator: NewMercatorType
110
+
111
+ // 辅助
112
+ static throttle: throttleType
113
+ static assemble: assembleType
114
+
115
+ // 布局
116
+ static TreeLayout: NewTreeLayoutType
117
+
118
+ // 配置项
119
+ static initOption: initOptionType
120
+ static mergeOption: mergeOptionType
121
+ }
122
+
123
+ // 插值
124
+ export let Cardinal: NewCardinalType
125
+ export let Hermite: NewHermiteType
126
+
127
+ // 变换
128
+ export let Matrix4: NewMatrix4Type
129
+ export let rotate: rotateType
130
+ export let move: moveType
131
+ export let scale: scaleType
132
+
133
+ // 工具
134
+ export let getLoopColors: getLoopColorsType
135
+ export let animation: animationType
136
+ export let ruler: rulerType
137
+
138
+ // 画笔
139
+ export let SVG: NewSVGType
140
+ export let Canvas: NewCanvasType
141
+
142
+ // WebGL
143
+ export let getWebGLContext: getWebGLContextType
144
+ export let Shader: NewShaderType
145
+ export let Buffer: NewBufferType
146
+ export let Texture: NewTextureType
147
+
148
+ // 投影
149
+ export let Eoap: NewEoapType
150
+ export let Mercator: NewMercatorType
151
+
152
+ // 辅助
153
+ export let throttle: throttleType
154
+ export let assemble: assembleType
155
+
156
+ // 布局
157
+ export let TreeLayout: NewTreeLayoutType
158
+
159
+ // 配置项
160
+ export let initOption: initOptionType
159
161
  export let mergeOption: mergeOptionType
@@ -1,3 +1,5 @@
1
- export type arcCapType = "butt" | "round" | "-round"
2
- export type textAlignType = "left" | "center" | "right"
3
- export type textBaselineType = "top" | "middle" | "bottom"
1
+ export type arcCapType = "butt" | "round" | "-round"
2
+ export type textAlignType = "left" | "center" | "right"
3
+ export type textBaselineType = "top" | "middle" | "bottom"
4
+ export type lineCapType = "butt" | "round" | "square"
5
+ export type lineJoinType = "miter" | "bevel" | "round"
@@ -1,8 +1,6 @@
1
- import throttleOptionType from './throttleOption'
1
+ import { throttleType } from "@oipage/core.js/src/throttle"
2
2
 
3
3
  /**
4
4
  * 节流函数
5
5
  */
6
- export default interface throttle {
7
- (callback: Function, option?: throttleOptionType): Function
8
- }
6
+ export default throttleType
@@ -1,22 +1 @@
1
- export type throttleOpportunityType = "begin" | "end" | "wide"
2
-
3
- export default interface throttleOptionType {
4
-
5
- /**
6
- * 节流时长
7
- */
8
- time?: number
9
-
10
- /**
11
- * 是否持续节流
12
- */
13
- keep?: boolean
14
-
15
- /**
16
- * 执行时机
17
- *
18
- * begin(开始触发)、end(结束触发)、wide(第一次开始触发,其余结束触发)
19
- */
20
- opportunity?: throttleOpportunityType
21
-
22
- }
1
+ export * from "@oipage/core.js/src/throttle"
@@ -0,0 +1,4 @@
1
+ /**
2
+ * ui-canvas
3
+ */
4
+ declare module "vislite/uni-app/ui-canvas.vue";
package/src/animation.ts DELETED
@@ -1,99 +0,0 @@
1
- //当前正在运动的动画的tick函数堆栈
2
- let $timers: any[] = []
3
- //唯一定时器的定时间隔
4
- const $interval = 13
5
- //定时器ID
6
- let $timerId: any
7
-
8
- /**
9
- * 动画轮播
10
- * @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
11
- * @param {number} duration 动画时长,可选
12
- * @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
13
- *
14
- * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
15
- */
16
- export default function (doback: (deep: number) => void, duration: number = 400, callback: (deep: number) => void = () => { }): Function {
17
-
18
- const clock = {
19
- //把tick函数推入堆栈
20
- "timer": function (tick: (deep: number) => void, duration: number, callback: (deep: number) => void) {
21
- if (!tick) {
22
- throw new Error('Tick is required!')
23
- }
24
- const id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0)
25
- $timers.push({
26
- "id": id,
27
- "createTime": new Date(),
28
- "tick": tick,
29
- "duration": duration,
30
- "callback": callback
31
- })
32
- clock.start()
33
- return id
34
- },
35
-
36
- //开启唯一的定时器timerId
37
- "start": function () {
38
- if (!$timerId) {
39
- $timerId = setInterval(clock.tick, $interval)
40
- }
41
- },
42
-
43
- //被定时器调用,遍历timers堆栈
44
- "tick": function () {
45
- let createTime: Date, flag: number, tick: (deep: number) => void, callback: (deep: number) => void, timer: any, duration: number, passTime: number
46
- const timers: any[] = $timers
47
- $timers = []
48
- $timers.length = 0
49
- for (flag = 0; flag < timers.length; flag++) {
50
- //初始化数据
51
- timer = timers[flag]
52
- createTime = timer.createTime
53
- tick = timer.tick
54
- duration = timer.duration
55
- callback = timer.callback
56
-
57
- //执行
58
- passTime = (+new Date().valueOf() - createTime.valueOf()) / duration
59
- passTime = passTime > 1 ? 1 : passTime
60
- tick(passTime)
61
- if (passTime < 1 && timer.id) {
62
- //动画没有结束再添加
63
- $timers.push(timer)
64
- } else {
65
- callback(passTime)
66
- }
67
- }
68
- if ($timers.length <= 0) {
69
- clock.stop()
70
- }
71
- },
72
-
73
- //停止定时器,重置timerId=null
74
- "stop": function () {
75
- if ($timerId) {
76
- clearInterval($timerId)
77
- $timerId = null
78
- }
79
- }
80
- }
81
-
82
- const id = clock.timer(function (deep: number) {
83
- //其中deep为0-1,表示改变的程度
84
- doback(deep)
85
- }, duration, callback)
86
-
87
- // 返回一个函数
88
- // 用于在动画结束前结束动画
89
- return function () {
90
- let i: string
91
- for (i in $timers) {
92
- if ($timers[i].id == id) {
93
- $timers[i].id = void 0
94
- return
95
- }
96
- }
97
- }
98
-
99
- }
package/src/throttle.ts DELETED
@@ -1,53 +0,0 @@
1
- import type throttleOptionType from '../types/throttleOption'
2
-
3
- import { initOption } from './common/option'
4
-
5
- export default function (callback: Function, option: throttleOptionType = {}) {
6
-
7
- // 校对缺省值
8
- option = initOption(option, <throttleOptionType>{
9
- time: 200,
10
- keep: false,
11
- opportunity: "end"
12
- })
13
-
14
- let hadInterval = false
15
- let hadClick = false
16
- let oneClick = false
17
-
18
- let arg: any
19
- return function () {
20
- const _this = this
21
- // eslint-disable-next-line prefer-rest-params
22
- arg = arguments
23
-
24
- // 如果前置任务都完成了
25
- if (!hadInterval) {
26
- if (option.opportunity != 'end') {
27
- callback.apply(_this, arg)
28
- }
29
- hadInterval = true
30
-
31
- const interval = setInterval(() => {
32
- if (hadClick) {
33
- if (!option.keep) {
34
- callback.apply(_this, arg)
35
- }
36
- } else {
37
- if (option.opportunity != 'begin') {
38
- if (oneClick || option.opportunity == 'end') callback.apply(_this, arg)
39
- }
40
- hadInterval = false
41
- oneClick = false
42
- clearInterval(interval)
43
- }
44
- hadClick = false
45
- }, option.time)
46
- } else {
47
- hadClick = true
48
- oneClick = true
49
- }
50
-
51
- }
52
-
53
- }