vislite 0.2.0 → 0.3.0-alpha.1

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