vislite 0.5.0-alpha.0 → 0.5.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 (63) hide show
  1. package/CHANGELOG +4 -1
  2. package/lib/Buffer/index.umd.js +2 -2
  3. package/lib/Buffer/index.umd.min.js +2 -2
  4. package/lib/Canvas/index.umd.js +2 -2
  5. package/lib/Canvas/index.umd.min.js +2 -2
  6. package/lib/Cardinal/index.umd.js +2 -2
  7. package/lib/Cardinal/index.umd.min.js +2 -2
  8. package/lib/Eoap/index.umd.js +2 -2
  9. package/lib/Eoap/index.umd.min.js +2 -2
  10. package/lib/Geometry/index.umd.js +26 -25
  11. package/lib/Geometry/index.umd.min.js +3 -3
  12. package/lib/Hermite/index.umd.js +2 -2
  13. package/lib/Hermite/index.umd.min.js +2 -2
  14. package/lib/Matrix4/index.umd.js +2 -2
  15. package/lib/Matrix4/index.umd.min.js +2 -2
  16. package/lib/Mercator/index.umd.js +2 -2
  17. package/lib/Mercator/index.umd.min.js +2 -2
  18. package/lib/OralCanvas/index.es.js +2 -2
  19. package/lib/OralCanvas/index.es.min.js +2 -2
  20. package/lib/OralWebGL/index.es.js +2 -2
  21. package/lib/OralWebGL/index.es.min.js +2 -2
  22. package/lib/SVG/index.umd.js +8 -2
  23. package/lib/SVG/index.umd.min.js +3 -3
  24. package/lib/Shader/index.umd.js +2 -2
  25. package/lib/Shader/index.umd.min.js +2 -2
  26. package/lib/Texture/index.umd.js +2 -2
  27. package/lib/Texture/index.umd.min.js +2 -2
  28. package/lib/TreeLayout/index.umd.js +7 -4
  29. package/lib/TreeLayout/index.umd.min.js +3 -3
  30. package/lib/WebGL/index.umd.js +2 -2
  31. package/lib/WebGL/index.umd.min.js +2 -2
  32. package/lib/animation/index.umd.js +2 -2
  33. package/lib/animation/index.umd.min.js +2 -2
  34. package/lib/formatColor/index.umd.js +2 -2
  35. package/lib/formatColor/index.umd.min.js +2 -2
  36. package/lib/getLoopColors/index.umd.js +2 -2
  37. package/lib/getLoopColors/index.umd.min.js +2 -2
  38. package/lib/getWebGLContext/index.umd.js +2 -2
  39. package/lib/getWebGLContext/index.umd.min.js +2 -2
  40. package/lib/index.umd.js +37 -27
  41. package/lib/index.umd.min.js +3 -3
  42. package/lib/resizeObserver/index.umd.js +2 -2
  43. package/lib/resizeObserver/index.umd.min.js +2 -2
  44. package/lib/rotate/index.umd.js +2 -2
  45. package/lib/rotate/index.umd.min.js +2 -2
  46. package/lib/ruler/index.umd.js +2 -2
  47. package/lib/ruler/index.umd.min.js +2 -2
  48. package/lib/throttle/index.umd.js +2 -2
  49. package/lib/throttle/index.umd.min.js +2 -2
  50. package/lib/viewHandler/index.umd.js +2 -2
  51. package/lib/viewHandler/index.umd.min.js +2 -2
  52. package/package.json +1 -1
  53. package/src/Geometry.ts +17 -16
  54. package/src/TreeLayout/index.ts +186 -185
  55. package/src/common/geometry/prism-horizontal.ts +8 -9
  56. package/src/common/svg/index.ts +344 -336
  57. package/types/Canvas.d.ts +295 -295
  58. package/types/CanvasConfig.d.ts +106 -82
  59. package/types/Geometry.d.ts +6 -0
  60. package/types/Hermite.d.ts +5 -5
  61. package/types/SVG.d.ts +215 -210
  62. package/types/SVGConfig.d.ts +16 -0
  63. package/types/TreeLayout.d.ts +54 -48
@@ -1,336 +1,344 @@
1
- import type SVGConfigType from "../../../types/SVGConfig"
2
- import type { arcCapType, textAlignType, textBaselineType } from "../../../types/painterConfig"
3
-
4
- import { initText, initCircle, initPath, initRect, initArc } from "./config"
5
- import { toNode, setAttribute, getAttribute, full, fill, stroke } from "./tool"
6
- import rotate from "../../rotate"
7
-
8
- // 属性名向下兼容
9
- let oldAttrName = {
10
- "font-size": "fontSize",
11
- "font-family": "fontFamily",
12
- "arc-start-cap": "arcStartCap",
13
- "arc-end-cap": "arcEndCap",
14
- }
15
-
16
- class SVG {
17
- readonly name: string = "SVG"
18
-
19
- // 用于记录配置
20
- private __config = {
21
- // 基本设置
22
- fillStyle: "#000",
23
- strokeStyle: "#000",
24
- lineWidth: 1,
25
-
26
- // 文字对齐方式
27
- textAlign: <textAlignType>"left",
28
- textBaseline: <textBaselineType>"middle",
29
-
30
- // 文字设置
31
- "fontSize": 16,
32
- "fontFamily": "sans-serif",
33
-
34
- // arc二端闭合方式['butt':直线闭合,'round':圆帽闭合]
35
- "arcStartCap": <arcCapType>"butt",
36
- "arcEndCap": <arcCapType>"butt",
37
-
38
- // 虚线设置
39
- lineDash: [],
40
- }
41
-
42
- // 作用的节点
43
- private __useEl: SVGElement
44
-
45
- // 路径(和canvas2D的类似)
46
- private __path: string = ""
47
- private __currentPosition: number[] = []
48
-
49
- private __svg: SVGElement
50
- constructor(svg: SVGElement) {
51
- this.__svg = svg
52
- }
53
-
54
- // 属性设置或获取
55
- config(params: SVGConfigType) {
56
- if (typeof params !== "object") {
57
- return this.__config[oldAttrName[params] || params]
58
- } else {
59
- for (let key in params) {
60
- let _key = oldAttrName[key] || key
61
- this.__config[_key] = params[key]
62
- }
63
- }
64
- return this
65
- }
66
-
67
- /**
68
- * 基础方法
69
- * ---------------------------------
70
- */
71
-
72
- // 标记应用节点
73
- // 也就是后续操作都会作用在此节点
74
- useEl(el: SVGElement) {
75
- this.__useEl = el
76
- return this
77
- }
78
-
79
- // 获取当前应用的节点
80
- getEl() {
81
- return this.__useEl
82
- }
83
-
84
- // 追加节点
85
- // el可以是结点或字符串,字符串的话表示节点名称
86
- // context可选,表示追加位置,可选,默认根svg
87
- // 此外,和appendBoard等操作一样,执行后新加入的结点会自动变成应用节点
88
- appendEl(el: string | SVGElement, context?: SVGElement) {
89
- context = context || this.__svg
90
-
91
- if (typeof el == "string") el = toNode(el)
92
- context.appendChild(el as SVGElement)
93
-
94
- this.__useEl = el as SVGElement
95
- return this
96
- }
97
-
98
- // 追加绘制板
99
- // 参数和appendEl类似,只是el如果是字符串的话,表示需要绘制对应什么内容,
100
- // 比如el = “arc”,表示画弧(不是路径arc),那么我们会创建path节点,因为我们是使用path实现的
101
- appendBoard(el: string | SVGElement, context?: SVGElement) {
102
- let _el = el
103
-
104
- if (typeof el == "string")
105
- _el =
106
- {
107
- text: "text",
108
- path: "path",
109
- arc: "path",
110
- circle: "circle",
111
- rect: "rect",
112
- }[el] || ""
113
-
114
- if (_el == "") throw new Error("Unsupported drawing method:" + el)
115
- return this.appendEl(_el, context)
116
- }
117
-
118
- // 删除当前维护的节点
119
- remove() {
120
- if (!this.__useEl) {
121
- throw new Error("Currently, no node can be deleted.")
122
- } else {
123
- ((this.__useEl as SVGElement).parentNode as SVGElement).removeChild(
124
- this.__useEl
125
- )
126
- }
127
- return this
128
- }
129
-
130
- // 设置或获取节点属性
131
- attr(params: any) {
132
- if (!this.__useEl)
133
- throw new Error("Currently, no node can be modified or viewed.")
134
-
135
- if (typeof params !== "object") {
136
- return getAttribute(this.__useEl, params)
137
- } else {
138
- for (let key in params) {
139
- setAttribute(this.__useEl, key, params[key])
140
- }
141
- return this
142
- }
143
- }
144
-
145
- /**
146
- * 绘制方法
147
- * ---------------------------------
148
- */
149
-
150
- // 文字
151
- // deg表示文字旋转角度,是角度值,不是弧度
152
- fillText(text: string, x: number, y: number, deg: number = 0) {
153
- initText(this.__useEl, this.__config, x, y, deg)
154
- this.__useEl.textContent = text
155
- fill(this.__useEl, this.__config)
156
- return this
157
- }
158
- strokeText(text: string, x: number, y: number, deg: number = 0) {
159
- initText(this.__useEl, this.__config, x, y, deg)
160
- this.__useEl.textContent = text
161
- stroke(this.__useEl, this.__config)
162
- return this
163
- }
164
- fullText(text: string, x: number, y: number, deg: number = 0) {
165
- initText(this.__useEl, this.__config, x, y, deg)
166
- this.__useEl.textContent = text
167
- full(this.__useEl, this.__config)
168
- return this
169
- }
170
-
171
- // 弧
172
- fillArc(
173
- cx: number,
174
- cy: number,
175
- r1: number,
176
- r2: number,
177
- beginDeg: number,
178
- deg: number
179
- ) {
180
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg)
181
- fill(this.__useEl, this.__config)
182
- return this
183
- }
184
- strokeArc(
185
- cx: number,
186
- cy: number,
187
- r1: number,
188
- r2: number,
189
- beginDeg: number,
190
- deg: number
191
- ) {
192
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg)
193
- stroke(this.__useEl, this.__config)
194
- return this
195
- }
196
- fullArc(
197
- cx: number,
198
- cy: number,
199
- r1: number,
200
- r2: number,
201
- beginDeg: number,
202
- deg: number
203
- ) {
204
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg)
205
- full(this.__useEl, this.__config)
206
- return this
207
- }
208
-
209
- // 圆形
210
- fillCircle(cx: number, cy: number, r: number) {
211
- initCircle(this.__useEl, cx, cy, r)
212
- fill(this.__useEl, this.__config)
213
- return this
214
- }
215
- strokeCircle(cx: number, cy: number, r: number) {
216
- initCircle(this.__useEl, cx, cy, r)
217
- stroke(this.__useEl, this.__config)
218
- return this
219
- }
220
- fullCircle(cx: number, cy: number, r: number) {
221
- initCircle(this.__useEl, cx, cy, r)
222
- full(this.__useEl, this.__config)
223
- return this
224
- }
225
-
226
- // 矩形
227
- fillRect(x: number, y: number, width: number, height: number) {
228
- initRect(this.__useEl, x, y, width, height)
229
- fill(this.__useEl, this.__config)
230
- return this
231
- }
232
- strokeRect(x: number, y: number, width: number, height: number) {
233
- initRect(this.__useEl, x, y, width, height)
234
- stroke(this.__useEl, this.__config)
235
- return this
236
- }
237
- fullRect(x: number, y: number, width: number, height: number) {
238
- initRect(this.__useEl, x, y, width, height)
239
- full(this.__useEl, this.__config)
240
- return this
241
- }
242
-
243
- // 路径
244
- beginPath() {
245
- this.__currentPosition = []
246
- this.__path = ""
247
- return this
248
- }
249
- closePath() {
250
- this.__path += "Z"
251
- return this
252
- }
253
- moveTo(x: number, y: number) {
254
- this.__currentPosition = [x, y]
255
-
256
- this.__path += "M" + x + " " + y
257
- return this
258
- }
259
- lineTo(x: number, y: number) {
260
- this.__currentPosition = [x, y]
261
-
262
- this.__path += (this.__path == "" ? "M" : "L") + x + " " + y
263
- return this
264
- }
265
- fill() {
266
- initPath(this.__useEl, this.__path)
267
- fill(this.__useEl, this.__config)
268
- return this
269
- }
270
- stroke() {
271
- initPath(this.__useEl, this.__path)
272
- stroke(this.__useEl, this.__config)
273
- return this
274
- }
275
- full() {
276
- initPath(this.__useEl, this.__path);
277
- full(this.__useEl, this.__config)
278
- return this
279
- }
280
-
281
- arc(x: number, y: number, r: number, beginDeg: number, deg: number) {
282
- let begPosition = rotate(x, y, (beginDeg / 180) * Math.PI, x + r, y)
283
- let endPosition = rotate(
284
- x,
285
- y,
286
- ((beginDeg + deg) / 180) * Math.PI,
287
- x + r,
288
- y
289
- )
290
- // 如果当前没有路径,说明是开始的,就移动到正确位置
291
- if (this.__path == "") {
292
- this.__path += "M" + begPosition[0] + "," + begPosition[1]
293
- }
294
- // 如果当前有路径,位置不正确,应该画到正确位置(和canvas保持一致)
295
- else if (
296
- begPosition[0] != this.__currentPosition[0] ||
297
- begPosition[1] != this.__currentPosition[1]
298
- ) {
299
- this.__path += "L" + begPosition[0] + "," + begPosition[1]
300
- }
301
- this.__path +=
302
- "A" +
303
- r +
304
- "," +
305
- r +
306
- " 0 " +
307
- (deg > 180 || deg < -180 ? 1 : 0) +
308
- "," +
309
- (deg > 0 ? 1 : 0) +
310
- " " +
311
- endPosition[0] +
312
- "," +
313
- endPosition[1]
314
- return this
315
- }
316
-
317
- // 路径 - 贝塞尔曲线
318
- quadraticCurveTo(cpx: number, cpy: number, x: number, y: number) {
319
- this.__path += "Q" + cpx + " " + cpy + "," + x + " " + y
320
- return this
321
- }
322
- bezierCurveTo(
323
- cp1x: number,
324
- cp1y: number,
325
- cp2x: number,
326
- cp2y: number,
327
- x: number,
328
- y: number
329
- ) {
330
- this.__path +=
331
- "C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y
332
- return this
333
- }
334
- }
335
-
336
- export default SVG
1
+ import type SVGConfigType from "../../../types/SVGConfig"
2
+ import type { arcCapType, textAlignType, textBaselineType } from "../../../types/painterConfig"
3
+
4
+ import { initText, initCircle, initPath, initRect, initArc } from "./config"
5
+ import { toNode, setAttribute, getAttribute, full, fill, stroke } from "./tool"
6
+ import rotate from "../../rotate"
7
+
8
+ // 属性名向下兼容
9
+ let oldAttrName = {
10
+ "font-size": "fontSize",
11
+ "font-family": "fontFamily",
12
+ "arc-start-cap": "arcStartCap",
13
+ "arc-end-cap": "arcEndCap",
14
+ }
15
+
16
+ class SVG {
17
+ readonly name: string = "SVG"
18
+
19
+ // 用于记录配置
20
+ private __config = {
21
+ // 基本设置
22
+ fillStyle: "#000",
23
+ strokeStyle: "#000",
24
+ lineWidth: 1,
25
+
26
+ // 文字对齐方式
27
+ textAlign: <textAlignType>"left",
28
+ textBaseline: <textBaselineType>"middle",
29
+
30
+ // 文字设置
31
+ "fontSize": 16,
32
+ "fontFamily": "sans-serif",
33
+
34
+ // arc二端闭合方式['butt':直线闭合,'round':圆帽闭合]
35
+ "arcStartCap": <arcCapType>"butt",
36
+ "arcEndCap": <arcCapType>"butt",
37
+
38
+ // 虚线设置
39
+ lineDash: [],
40
+ }
41
+
42
+ // 作用的节点
43
+ private __useEl: SVGElement
44
+
45
+ // 路径(和canvas2D的类似)
46
+ private __path: string = ""
47
+ private __currentPosition: number[] = []
48
+
49
+ private __svg: SVGElement
50
+ constructor(svg: SVGElement) {
51
+ this.__svg = svg
52
+ }
53
+
54
+ // 属性设置或获取
55
+ config(params: SVGConfigType) {
56
+ if (typeof params !== "object") {
57
+ return this.__config[oldAttrName[params] || params]
58
+ } else {
59
+ for (let key in params) {
60
+ let _key = oldAttrName[key] || key
61
+ this.__config[_key] = params[key]
62
+ }
63
+ }
64
+ return this
65
+ }
66
+
67
+ /**
68
+ * 基础方法
69
+ * ---------------------------------
70
+ */
71
+
72
+ // 标记应用节点
73
+ // 也就是后续操作都会作用在此节点
74
+ useEl(el: SVGElement) {
75
+ this.__useEl = el
76
+ return this
77
+ }
78
+
79
+ // 获取当前应用的节点
80
+ getEl() {
81
+ return this.__useEl
82
+ }
83
+
84
+ // 追加节点
85
+ // el可以是结点或字符串,字符串的话表示节点名称
86
+ // context可选,表示追加位置,可选,默认根svg
87
+ // 此外,和appendBoard等操作一样,执行后新加入的结点会自动变成应用节点
88
+ appendEl(el: string | SVGElement, context?: SVGElement) {
89
+ context = context || this.__svg
90
+
91
+ if (typeof el == "string") el = toNode(el)
92
+ context.appendChild(el as SVGElement)
93
+
94
+ this.__useEl = el as SVGElement
95
+ return this
96
+ }
97
+
98
+ // 追加绘制板
99
+ // 参数和appendEl类似,只是el如果是字符串的话,表示需要绘制对应什么内容,
100
+ // 比如el = “arc”,表示画弧(不是路径arc),那么我们会创建path节点,因为我们是使用path实现的
101
+ appendBoard(el: string | SVGElement, context?: SVGElement) {
102
+ let _el = el
103
+
104
+ if (typeof el == "string")
105
+ _el =
106
+ {
107
+ text: "text",
108
+ path: "path",
109
+ arc: "path",
110
+ circle: "circle",
111
+ rect: "rect",
112
+ }[el] || ""
113
+
114
+ if (_el == "") throw new Error("Unsupported drawing method:" + el)
115
+ return this.appendEl(_el, context)
116
+ }
117
+
118
+ // 删除当前维护的节点
119
+ remove() {
120
+ if (!this.__useEl) {
121
+ throw new Error("Currently, no node can be deleted.")
122
+ } else {
123
+ ((this.__useEl as SVGElement).parentNode as SVGElement).removeChild(
124
+ this.__useEl
125
+ )
126
+ }
127
+ return this
128
+ }
129
+
130
+ // 设置或获取节点属性
131
+ attr(params: any) {
132
+ if (!this.__useEl)
133
+ throw new Error("Currently, no node can be modified or viewed.")
134
+
135
+ if (typeof params !== "object") {
136
+ return getAttribute(this.__useEl, params)
137
+ } else {
138
+ for (let key in params) {
139
+ setAttribute(this.__useEl, key, params[key])
140
+ }
141
+ return this
142
+ }
143
+ }
144
+
145
+ /**
146
+ * 绘制方法
147
+ * ---------------------------------
148
+ */
149
+
150
+ // 文字
151
+ // deg表示文字旋转角度,是角度值,不是弧度
152
+ fillText(text: string, x: number, y: number, deg: number = 0) {
153
+ initText(this.__useEl, this.__config, x, y, deg)
154
+ this.__useEl.textContent = text
155
+ fill(this.__useEl, this.__config)
156
+ return this
157
+ }
158
+ strokeText(text: string, x: number, y: number, deg: number = 0) {
159
+ initText(this.__useEl, this.__config, x, y, deg)
160
+ this.__useEl.textContent = text
161
+ stroke(this.__useEl, this.__config)
162
+ return this
163
+ }
164
+ fullText(text: string, x: number, y: number, deg: number = 0) {
165
+ initText(this.__useEl, this.__config, x, y, deg)
166
+ this.__useEl.textContent = text
167
+ full(this.__useEl, this.__config)
168
+ return this
169
+ }
170
+
171
+ // 弧
172
+ fillArc(
173
+ cx: number,
174
+ cy: number,
175
+ r1: number,
176
+ r2: number,
177
+ beginDeg: number,
178
+ deg: number
179
+ ) {
180
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg)
181
+ fill(this.__useEl, this.__config)
182
+ return this
183
+ }
184
+ strokeArc(
185
+ cx: number,
186
+ cy: number,
187
+ r1: number,
188
+ r2: number,
189
+ beginDeg: number,
190
+ deg: number
191
+ ) {
192
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg)
193
+ stroke(this.__useEl, this.__config)
194
+ return this
195
+ }
196
+ fullArc(
197
+ cx: number,
198
+ cy: number,
199
+ r1: number,
200
+ r2: number,
201
+ beginDeg: number,
202
+ deg: number
203
+ ) {
204
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg)
205
+ full(this.__useEl, this.__config)
206
+ return this
207
+ }
208
+
209
+ // 圆形
210
+ fillCircle(cx: number, cy: number, r: number) {
211
+ initCircle(this.__useEl, cx, cy, r)
212
+ fill(this.__useEl, this.__config)
213
+ return this
214
+ }
215
+ strokeCircle(cx: number, cy: number, r: number) {
216
+ initCircle(this.__useEl, cx, cy, r)
217
+ stroke(this.__useEl, this.__config)
218
+ return this
219
+ }
220
+ fullCircle(cx: number, cy: number, r: number) {
221
+ initCircle(this.__useEl, cx, cy, r)
222
+ full(this.__useEl, this.__config)
223
+ return this
224
+ }
225
+
226
+ // 矩形
227
+ fillRect(x: number, y: number, width: number, height: number) {
228
+ initRect(this.__useEl, x, y, width, height)
229
+ fill(this.__useEl, this.__config)
230
+ return this
231
+ }
232
+ strokeRect(x: number, y: number, width: number, height: number) {
233
+ initRect(this.__useEl, x, y, width, height)
234
+ stroke(this.__useEl, this.__config)
235
+ return this
236
+ }
237
+ fullRect(x: number, y: number, width: number, height: number) {
238
+ initRect(this.__useEl, x, y, width, height)
239
+ full(this.__useEl, this.__config)
240
+ return this
241
+ }
242
+
243
+ // 路径
244
+ beginPath() {
245
+ this.__currentPosition = []
246
+ this.__path = ""
247
+ return this
248
+ }
249
+ closePath() {
250
+ this.__path += "Z"
251
+ return this
252
+ }
253
+ moveTo(x: number, y: number) {
254
+ this.__currentPosition = [x, y]
255
+
256
+ this.__path += "M" + x + " " + y
257
+ return this
258
+ }
259
+ lineTo(x: number, y: number) {
260
+ this.__currentPosition = [x, y]
261
+
262
+ this.__path += (this.__path == "" ? "M" : "L") + x + " " + y
263
+ return this
264
+ }
265
+ fill() {
266
+ initPath(this.__useEl, this.__path)
267
+ fill(this.__useEl, this.__config)
268
+ return this
269
+ }
270
+ stroke() {
271
+ initPath(this.__useEl, this.__path)
272
+ stroke(this.__useEl, this.__config)
273
+ return this
274
+ }
275
+ full() {
276
+ initPath(this.__useEl, this.__path);
277
+ full(this.__useEl, this.__config)
278
+ return this
279
+ }
280
+
281
+ arc(x: number, y: number, r: number, beginDeg: number, deg: number) {
282
+ let begPosition = rotate(x, y, (beginDeg / 180) * Math.PI, x + r, y)
283
+ let endPosition = rotate(
284
+ x,
285
+ y,
286
+ ((beginDeg + deg) / 180) * Math.PI,
287
+ x + r,
288
+ y
289
+ )
290
+ // 如果当前没有路径,说明是开始的,就移动到正确位置
291
+ if (this.__path == "") {
292
+ this.__path += "M" + begPosition[0] + "," + begPosition[1]
293
+ }
294
+ // 如果当前有路径,位置不正确,应该画到正确位置(和canvas保持一致)
295
+ else if (
296
+ begPosition[0] != this.__currentPosition[0] ||
297
+ begPosition[1] != this.__currentPosition[1]
298
+ ) {
299
+ this.__path += "L" + begPosition[0] + "," + begPosition[1]
300
+ }
301
+ this.__path +=
302
+ "A" +
303
+ r +
304
+ "," +
305
+ r +
306
+ " 0 " +
307
+ (deg > 180 || deg < -180 ? 1 : 0) +
308
+ "," +
309
+ (deg > 0 ? 1 : 0) +
310
+ " " +
311
+ endPosition[0] +
312
+ "," +
313
+ endPosition[1]
314
+ return this
315
+ }
316
+
317
+ // 路径 - 贝塞尔曲线
318
+ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number) {
319
+ this.__path += "Q" + cpx + " " + cpy + "," + x + " " + y
320
+ return this
321
+ }
322
+ bezierCurveTo(
323
+ cp1x: number,
324
+ cp1y: number,
325
+ cp2x: number,
326
+ cp2y: number,
327
+ x: number,
328
+ y: number
329
+ ) {
330
+ this.__path +=
331
+ "C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y
332
+ return this
333
+ }
334
+
335
+ // 绑定事件
336
+ bind(eventType: string, callback: (event: Event, target: SVGElement) => void) {
337
+ this.__useEl.addEventListener(eventType, function (event: Event) {
338
+ callback.call(this, event, this)
339
+ }, false)
340
+ return this
341
+ }
342
+ }
343
+
344
+ export default SVG