@ibiz-template/vue3-components 0.7.41-alpha.45 → 0.7.41-alpha.46
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/dist/{index-DgqTP4Vw.js → index-B0XiEslO.js} +1 -1
- package/dist/{index-Dr0VM8iS.js → index-B6kaPJDO.js} +1 -1
- package/dist/{index-yLzheFmH.js → index-DTj1Yy9-.js} +4 -4
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/{wang-editor-homqxACE.js → wang-editor-CRTv7Ujm.js} +1 -1
- package/dist/{xlsx-util-C5MBICNN.js → xlsx-util-CqW4WJ9G.js} +1 -1
- package/es/common/button-list/button-list.css +1 -1
- package/es/index.mjs +1 -0
- package/es/locale/en/index.mjs +13 -0
- package/es/locale/zh-CN/index.mjs +13 -0
- package/es/node_modules/.pnpm/modern-screenshot@4.6.7/node_modules/modern-screenshot/dist/index.mjs +1652 -0
- package/es/util/ai-chat-util/ai-chat-util.mjs +21 -21
- package/es/util/app-util/app-util.mjs +2 -4
- package/es/util/index.mjs +1 -0
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +3 -3
- package/es/util/screen-shot-util/screen-shot/components/index.mjs +3 -0
- package/es/util/screen-shot-util/screen-shot/components/screen-shot/screen-shot.css +1 -0
- package/es/util/screen-shot-util/screen-shot/components/screen-shot/screen-shot.mjs +113 -0
- package/es/util/screen-shot-util/screen-shot/components/screen-shot-toolbar/screen-shot-toolbar.css +1 -0
- package/es/util/screen-shot-util/screen-shot/components/screen-shot-toolbar/screen-shot-toolbar.mjs +105 -0
- package/es/util/screen-shot-util/screen-shot/constant/index.mjs +172 -0
- package/es/util/screen-shot-util/screen-shot/controller/index.mjs +3 -0
- package/es/util/screen-shot-util/screen-shot/controller/screen-shot.controller.mjs +366 -0
- package/es/util/screen-shot-util/screen-shot/controller/screen-shot.store.mjs +51 -0
- package/es/util/screen-shot-util/screen-shot/icon/icon.mjs +90 -0
- package/es/util/screen-shot-util/screen-shot/icon/index.mjs +3 -0
- package/es/util/screen-shot-util/screen-shot/index.mjs +4 -0
- package/es/util/screen-shot-util/screen-shot/module/draw-arrow.mjs +109 -0
- package/es/util/screen-shot-util/screen-shot/module/draw-circle.mjs +25 -0
- package/es/util/screen-shot-util/screen-shot/module/draw-mosaic.mjs +54 -0
- package/es/util/screen-shot-util/screen-shot/module/draw-pencil.mjs +15 -0
- package/es/util/screen-shot-util/screen-shot/module/draw-rectangle.mjs +12 -0
- package/es/util/screen-shot-util/screen-shot/module/draw-text.mjs +12 -0
- package/es/util/screen-shot-util/screen-shot/module/index.mjs +8 -0
- package/es/util/screen-shot-util/screen-shot/type/index.mjs +16 -0
- package/es/util/screen-shot-util/screen-shot/util/index.mjs +8 -0
- package/es/util/screen-shot-util/screen-shot-util.mjs +67 -0
- package/es/web-app/main.mjs +2 -0
- package/lib/common/button-list/button-list.css +1 -1
- package/lib/index.cjs +2 -0
- package/lib/locale/en/index.cjs +13 -0
- package/lib/locale/zh-CN/index.cjs +13 -0
- package/lib/node_modules/.pnpm/modern-screenshot@4.6.7/node_modules/modern-screenshot/dist/index.cjs +1667 -0
- package/lib/util/ai-chat-util/ai-chat-util.cjs +21 -21
- package/lib/util/app-util/app-util.cjs +2 -4
- package/lib/util/index.cjs +2 -0
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +3 -3
- package/lib/util/screen-shot-util/screen-shot/components/index.cjs +7 -0
- package/lib/util/screen-shot-util/screen-shot/components/screen-shot/screen-shot.cjs +115 -0
- package/lib/util/screen-shot-util/screen-shot/components/screen-shot/screen-shot.css +1 -0
- package/lib/util/screen-shot-util/screen-shot/components/screen-shot-toolbar/screen-shot-toolbar.cjs +107 -0
- package/lib/util/screen-shot-util/screen-shot/components/screen-shot-toolbar/screen-shot-toolbar.css +1 -0
- package/lib/util/screen-shot-util/screen-shot/constant/index.cjs +174 -0
- package/lib/util/screen-shot-util/screen-shot/controller/index.cjs +7 -0
- package/lib/util/screen-shot-util/screen-shot/controller/screen-shot.controller.cjs +368 -0
- package/lib/util/screen-shot-util/screen-shot/controller/screen-shot.store.cjs +53 -0
- package/lib/util/screen-shot-util/screen-shot/icon/icon.cjs +100 -0
- package/lib/util/screen-shot-util/screen-shot/icon/index.cjs +15 -0
- package/lib/util/screen-shot-util/screen-shot/index.cjs +8 -0
- package/lib/util/screen-shot-util/screen-shot/module/draw-arrow.cjs +111 -0
- package/lib/util/screen-shot-util/screen-shot/module/draw-circle.cjs +27 -0
- package/lib/util/screen-shot-util/screen-shot/module/draw-mosaic.cjs +56 -0
- package/lib/util/screen-shot-util/screen-shot/module/draw-pencil.cjs +18 -0
- package/lib/util/screen-shot-util/screen-shot/module/draw-rectangle.cjs +14 -0
- package/lib/util/screen-shot-util/screen-shot/module/draw-text.cjs +14 -0
- package/lib/util/screen-shot-util/screen-shot/module/index.cjs +18 -0
- package/lib/util/screen-shot-util/screen-shot/type/index.cjs +18 -0
- package/lib/util/screen-shot-util/screen-shot/util/index.cjs +10 -0
- package/lib/util/screen-shot-util/screen-shot-util.cjs +69 -0
- package/lib/web-app/main.cjs +2 -0
- package/package.json +6 -5
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index$1 = require('../../../../node_modules/.pnpm/modern-screenshot@4.6.7/node_modules/modern-screenshot/dist/index.cjs');
|
|
4
|
+
var screenShot_store = require('./screen-shot.store.cjs');
|
|
5
|
+
var index$2 = require('../type/index.cjs');
|
|
6
|
+
require('../module/index.cjs');
|
|
7
|
+
var index = require('../util/index.cjs');
|
|
8
|
+
var drawArrow = require('../module/draw-arrow.cjs');
|
|
9
|
+
var drawText = require('../module/draw-text.cjs');
|
|
10
|
+
var drawPencil = require('../module/draw-pencil.cjs');
|
|
11
|
+
var drawMosaic = require('../module/draw-mosaic.cjs');
|
|
12
|
+
var drawCircle = require('../module/draw-circle.cjs');
|
|
13
|
+
var drawRectangle = require('../module/draw-rectangle.cjs');
|
|
14
|
+
|
|
15
|
+
"use strict";
|
|
16
|
+
var __defProp = Object.defineProperty;
|
|
17
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
|
+
var __publicField = (obj, key, value) => {
|
|
19
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
class ScreenShotController {
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instance of ScreenShotController.
|
|
25
|
+
* @memberof ScreenShotController
|
|
26
|
+
*/
|
|
27
|
+
constructor() {
|
|
28
|
+
/**
|
|
29
|
+
* @description 状态对象
|
|
30
|
+
* @type {ScreenShotState}
|
|
31
|
+
* @memberof ScreenShotController
|
|
32
|
+
*/
|
|
33
|
+
__publicField(this, "store");
|
|
34
|
+
/**
|
|
35
|
+
* @description 当前工具
|
|
36
|
+
* @private
|
|
37
|
+
* @type {ToolbarItemType}
|
|
38
|
+
* @memberof ScreenShotController
|
|
39
|
+
*/
|
|
40
|
+
__publicField(this, "toolName");
|
|
41
|
+
/**
|
|
42
|
+
* @description 画笔配置
|
|
43
|
+
* @private
|
|
44
|
+
* @type {IBrushOption}
|
|
45
|
+
* @memberof ScreenShotController
|
|
46
|
+
*/
|
|
47
|
+
__publicField(this, "brushOption");
|
|
48
|
+
/**
|
|
49
|
+
* @description 画布上下文
|
|
50
|
+
* @private
|
|
51
|
+
* @type {(CanvasRenderingContext2D | undefined)}
|
|
52
|
+
* @memberof ScreenShotController
|
|
53
|
+
*/
|
|
54
|
+
__publicField(this, "canvasCtx");
|
|
55
|
+
/**
|
|
56
|
+
* @description 绘制状态
|
|
57
|
+
* @private
|
|
58
|
+
* @type {boolean}
|
|
59
|
+
* @memberof ScreenShotController
|
|
60
|
+
*/
|
|
61
|
+
__publicField(this, "drawing", false);
|
|
62
|
+
/**
|
|
63
|
+
* @description 最大可撤销次数
|
|
64
|
+
* @private
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @memberof ScreenShotController
|
|
67
|
+
*/
|
|
68
|
+
__publicField(this, "maxUndoNum", 15);
|
|
69
|
+
/**
|
|
70
|
+
* @description 文本输入框位置
|
|
71
|
+
* @private
|
|
72
|
+
* @type {IMousePosition}
|
|
73
|
+
* @memberof ScreenShotController
|
|
74
|
+
*/
|
|
75
|
+
__publicField(this, "textInputInfo", {
|
|
76
|
+
mouseX: 0,
|
|
77
|
+
mouseY: 0,
|
|
78
|
+
size: 14,
|
|
79
|
+
color: "#F53340"
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* @description 图形位置参数
|
|
83
|
+
* @private
|
|
84
|
+
* @type {IMousePosition}
|
|
85
|
+
* @memberof ScreenShotController
|
|
86
|
+
*/
|
|
87
|
+
__publicField(this, "drawGraphPosition", {
|
|
88
|
+
mouseX: 0,
|
|
89
|
+
mouseY: 0
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* @description 递增变粗箭头的实现
|
|
93
|
+
* @private
|
|
94
|
+
* @memberof ScreenShotController
|
|
95
|
+
*/
|
|
96
|
+
__publicField(this, "drawArrow", new drawArrow.DrawArrow());
|
|
97
|
+
this.store = new screenShot_store.ScreenShotStore();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @description 显示最新的画布状态
|
|
101
|
+
* @private
|
|
102
|
+
* @memberof ScreenShotController
|
|
103
|
+
*/
|
|
104
|
+
showLastHistory() {
|
|
105
|
+
if (!this.canvasCtx)
|
|
106
|
+
return;
|
|
107
|
+
if (this.store.history.value.length <= 0)
|
|
108
|
+
this.addHistory();
|
|
109
|
+
const data = this.store.history.value[this.store.history.value.length - 1].data;
|
|
110
|
+
this.canvasCtx.putImageData(data, 0, 0);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @description 添加历史
|
|
114
|
+
* @private
|
|
115
|
+
* @memberof ScreenShotController
|
|
116
|
+
*/
|
|
117
|
+
addHistory() {
|
|
118
|
+
if (!this.store.canvasElement.value || !this.canvasCtx)
|
|
119
|
+
return;
|
|
120
|
+
if (this.store.history.value.length > this.maxUndoNum)
|
|
121
|
+
this.store.history.value.shift();
|
|
122
|
+
const controller = this.store.canvasElement.value;
|
|
123
|
+
this.store.history.value.push({
|
|
124
|
+
data: this.canvasCtx.getImageData(
|
|
125
|
+
0,
|
|
126
|
+
0,
|
|
127
|
+
controller.width,
|
|
128
|
+
controller.height
|
|
129
|
+
)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @description 回退历史
|
|
134
|
+
* @private
|
|
135
|
+
* @memberof ScreenShotController
|
|
136
|
+
*/
|
|
137
|
+
goBackToHistory() {
|
|
138
|
+
var _a;
|
|
139
|
+
if (!this.store.history.value.length)
|
|
140
|
+
return;
|
|
141
|
+
this.store.history.value.pop();
|
|
142
|
+
const data = (_a = this.store.history.value[this.store.history.value.length - 1]) == null ? void 0 : _a.data;
|
|
143
|
+
if (this.canvasCtx && data)
|
|
144
|
+
this.canvasCtx.putImageData(data, 0, 0);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @description 启用文本编辑
|
|
148
|
+
* @private
|
|
149
|
+
* @param {number} X
|
|
150
|
+
* @param {number} Y
|
|
151
|
+
* @returns {*} {void}
|
|
152
|
+
* @memberof ScreenShotController
|
|
153
|
+
*/
|
|
154
|
+
enableTextEditing(event) {
|
|
155
|
+
const element = this.store.textInputElement.value;
|
|
156
|
+
if (!this.canvasCtx || !element || !this.brushOption)
|
|
157
|
+
return;
|
|
158
|
+
this.showLastHistory();
|
|
159
|
+
this.store.textStatus.value = true;
|
|
160
|
+
const { clientX, clientY } = event;
|
|
161
|
+
const { mouseX, mouseY, size, color } = this.textInputInfo;
|
|
162
|
+
const position = index.getMousePosition(event);
|
|
163
|
+
if (element.innerText && mouseX !== 0 && mouseY !== 0 && mouseX !== position.mouseX && mouseY !== position.mouseY) {
|
|
164
|
+
drawText.drawText(
|
|
165
|
+
element.innerText,
|
|
166
|
+
this.textInputInfo.mouseX,
|
|
167
|
+
this.textInputInfo.mouseY,
|
|
168
|
+
color,
|
|
169
|
+
size,
|
|
170
|
+
this.canvasCtx
|
|
171
|
+
);
|
|
172
|
+
element.innerText = "";
|
|
173
|
+
this.addHistory();
|
|
174
|
+
}
|
|
175
|
+
element.style.fontFamily = "none";
|
|
176
|
+
element.style.left = "".concat(clientX, "px");
|
|
177
|
+
element.style.fontSize = "".concat(this.brushOption.size, "px");
|
|
178
|
+
element.style.color = this.brushOption.color;
|
|
179
|
+
setTimeout(() => {
|
|
180
|
+
const containerHeight = element.offsetHeight;
|
|
181
|
+
element.style.top = "".concat(clientY - Math.floor(containerHeight / 2), "px");
|
|
182
|
+
element.focus();
|
|
183
|
+
this.textInputInfo = {
|
|
184
|
+
mouseX: position.mouseX,
|
|
185
|
+
mouseY: position.mouseY,
|
|
186
|
+
size: this.brushOption.size,
|
|
187
|
+
color: this.brushOption.color
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* @description 结束文本编辑
|
|
193
|
+
* @private
|
|
194
|
+
* @returns {*} {void}
|
|
195
|
+
* @memberof ScreenShotController
|
|
196
|
+
*/
|
|
197
|
+
endTextEditing() {
|
|
198
|
+
const element = this.store.textInputElement.value;
|
|
199
|
+
if (!element || !this.canvasCtx)
|
|
200
|
+
return;
|
|
201
|
+
if (element.innerText) {
|
|
202
|
+
const { mouseX, mouseY, size, color } = this.textInputInfo;
|
|
203
|
+
drawText.drawText(element.innerText, mouseX, mouseY, color, size, this.canvasCtx);
|
|
204
|
+
this.addHistory();
|
|
205
|
+
}
|
|
206
|
+
element.innerHTML = "";
|
|
207
|
+
this.store.textStatus.value = false;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* @description DOM生成Canvas
|
|
211
|
+
* @param {HTMLElement} el DOM元素
|
|
212
|
+
* @param {{ container?: HTMLElement; itemClassName?: string }} opts 如果需针对dom内部滚动容器截图,则需配置:滚动容器,滚动容器项类名,用以排除非可视区元素
|
|
213
|
+
* @returns {*} {Promise<void>}
|
|
214
|
+
* @memberof ScreenShotController
|
|
215
|
+
*/
|
|
216
|
+
async domToCanvas(el, opts) {
|
|
217
|
+
var _a;
|
|
218
|
+
this.store.isLoading.value = true;
|
|
219
|
+
const { container, itemClassName } = opts;
|
|
220
|
+
const containerRect = container == null ? void 0 : container.getBoundingClientRect();
|
|
221
|
+
const canvas = await index$1.domToCanvas(el, {
|
|
222
|
+
scale: window.devicePixelRatio || 1,
|
|
223
|
+
quality: 1,
|
|
224
|
+
filter: (node) => {
|
|
225
|
+
var _a2, _b;
|
|
226
|
+
if (containerRect && itemClassName) {
|
|
227
|
+
const element = node;
|
|
228
|
+
if ((container == null ? void 0 : container.contains(element)) && ((_a2 = element.classList) == null ? void 0 : _a2.contains(itemClassName))) {
|
|
229
|
+
const elementRect = (_b = element.getBoundingClientRect) == null ? void 0 : _b.call(element);
|
|
230
|
+
if (elementRect)
|
|
231
|
+
return elementRect.bottom > containerRect.top && elementRect.top < containerRect.bottom && elementRect.right > containerRect.left && elementRect.left < containerRect.right;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
this.canvasCtx = (_a = this.store.canvasElement.value) == null ? void 0 : _a.getContext("2d");
|
|
238
|
+
if (this.canvasCtx) {
|
|
239
|
+
this.store.canvasElement.value.width = canvas.width;
|
|
240
|
+
this.store.canvasElement.value.height = canvas.height;
|
|
241
|
+
this.store.canvasElement.value.style.top = "".concat(el.offsetTop, "px");
|
|
242
|
+
this.store.canvasElement.value.style.left = "".concat(el.offsetLeft, "px");
|
|
243
|
+
this.canvasCtx.drawImage(canvas, 0, 0);
|
|
244
|
+
}
|
|
245
|
+
this.store.isLoading.value = false;
|
|
246
|
+
this.store.toolbarStatus.value = true;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* @description 工具点击
|
|
250
|
+
* @param {ToolbarItemType} toolName
|
|
251
|
+
* @param {IBrushOption} opt
|
|
252
|
+
* @memberof ScreenShotController
|
|
253
|
+
*/
|
|
254
|
+
onToolClick(toolName, opt) {
|
|
255
|
+
if (toolName === index$2.ToolbarItemType.DRAWDOWN)
|
|
256
|
+
this.goBackToHistory();
|
|
257
|
+
this.brushOption = opt;
|
|
258
|
+
this.toolName = toolName;
|
|
259
|
+
this.endTextEditing();
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* @description 鼠标按下
|
|
263
|
+
* @param {MouseEvent} event
|
|
264
|
+
* @memberof ScreenShotController
|
|
265
|
+
*/
|
|
266
|
+
mouseDownEvent(event) {
|
|
267
|
+
if (event.button !== 0 || !this.toolName || this.toolName === index$2.ToolbarItemType.DRAWDOWN || !this.canvasCtx)
|
|
268
|
+
return;
|
|
269
|
+
this.drawing = true;
|
|
270
|
+
const { mouseX, mouseY } = index.getMousePosition(event);
|
|
271
|
+
Object.assign(this.drawGraphPosition, {
|
|
272
|
+
mouseX,
|
|
273
|
+
mouseY
|
|
274
|
+
});
|
|
275
|
+
switch (this.toolName) {
|
|
276
|
+
case index$2.ToolbarItemType.BRUSH:
|
|
277
|
+
drawPencil.initPencil(this.canvasCtx, mouseX, mouseY);
|
|
278
|
+
break;
|
|
279
|
+
case index$2.ToolbarItemType.TEXT:
|
|
280
|
+
this.enableTextEditing(event);
|
|
281
|
+
break;
|
|
282
|
+
default:
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* @description 鼠标移动
|
|
288
|
+
* @param {MouseEvent} event
|
|
289
|
+
* @returns {*} {void}
|
|
290
|
+
* @memberof ScreenShotController
|
|
291
|
+
*/
|
|
292
|
+
mouseMoveEvent(event) {
|
|
293
|
+
if (!this.toolName || !this.drawing || !this.canvasCtx || !this.brushOption)
|
|
294
|
+
return;
|
|
295
|
+
const { mouseX, mouseY } = index.getMousePosition(event);
|
|
296
|
+
const { mouseX: startX, mouseY: startY } = this.drawGraphPosition;
|
|
297
|
+
if (this.toolName !== index$2.ToolbarItemType.MOSAIC)
|
|
298
|
+
this.showLastHistory();
|
|
299
|
+
switch (this.toolName) {
|
|
300
|
+
case index$2.ToolbarItemType.BRUSH:
|
|
301
|
+
drawPencil.drawPencil(
|
|
302
|
+
this.canvasCtx,
|
|
303
|
+
mouseX,
|
|
304
|
+
mouseY,
|
|
305
|
+
this.brushOption.size,
|
|
306
|
+
this.brushOption.color
|
|
307
|
+
);
|
|
308
|
+
break;
|
|
309
|
+
case index$2.ToolbarItemType.RECT:
|
|
310
|
+
drawRectangle.drawRectangle(
|
|
311
|
+
startX,
|
|
312
|
+
startY,
|
|
313
|
+
mouseX - startX,
|
|
314
|
+
mouseY - startY,
|
|
315
|
+
this.brushOption.color,
|
|
316
|
+
this.brushOption.size,
|
|
317
|
+
this.canvasCtx
|
|
318
|
+
);
|
|
319
|
+
break;
|
|
320
|
+
case index$2.ToolbarItemType.CIRCLE:
|
|
321
|
+
drawCircle.drawCircle(
|
|
322
|
+
this.canvasCtx,
|
|
323
|
+
mouseX,
|
|
324
|
+
mouseY,
|
|
325
|
+
startX,
|
|
326
|
+
startY,
|
|
327
|
+
this.brushOption.size,
|
|
328
|
+
this.brushOption.color
|
|
329
|
+
);
|
|
330
|
+
break;
|
|
331
|
+
case index$2.ToolbarItemType.ARROW:
|
|
332
|
+
this.drawArrow.draw(
|
|
333
|
+
this.canvasCtx,
|
|
334
|
+
startX,
|
|
335
|
+
startY,
|
|
336
|
+
mouseX,
|
|
337
|
+
mouseY,
|
|
338
|
+
this.brushOption.color
|
|
339
|
+
);
|
|
340
|
+
break;
|
|
341
|
+
case index$2.ToolbarItemType.MOSAIC:
|
|
342
|
+
drawMosaic.drawMosaic(
|
|
343
|
+
mouseX - 10,
|
|
344
|
+
mouseY - 10,
|
|
345
|
+
this.brushOption.size,
|
|
346
|
+
5,
|
|
347
|
+
this.canvasCtx
|
|
348
|
+
);
|
|
349
|
+
break;
|
|
350
|
+
default:
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* @description 鼠标抬起
|
|
356
|
+
* @returns {*} {void}
|
|
357
|
+
* @memberof ScreenShotController
|
|
358
|
+
*/
|
|
359
|
+
mouseUpEvent() {
|
|
360
|
+
this.drawing = false;
|
|
361
|
+
if (!this.toolName || this.toolName === index$2.ToolbarItemType.DRAWDOWN || !this.canvasCtx)
|
|
362
|
+
return;
|
|
363
|
+
if (this.toolName !== index$2.ToolbarItemType.TEXT)
|
|
364
|
+
this.addHistory();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
exports.ScreenShotController = ScreenShotController;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __publicField = (obj, key, value) => {
|
|
9
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
class ScreenShotStore {
|
|
13
|
+
constructor() {
|
|
14
|
+
/**
|
|
15
|
+
* @description 画布元素
|
|
16
|
+
* @type {(Ref<HTMLCanvasElement | undefined>)}
|
|
17
|
+
* @memberof ScreenShotStore
|
|
18
|
+
*/
|
|
19
|
+
__publicField(this, "canvasElement", vue.ref(void 0));
|
|
20
|
+
/**
|
|
21
|
+
* @description 文本输入框颜色
|
|
22
|
+
* @type {(Ref<HTMLCanvasElement | undefined>)}
|
|
23
|
+
* @memberof ScreenShotStore
|
|
24
|
+
*/
|
|
25
|
+
__publicField(this, "textInputElement", vue.ref(void 0));
|
|
26
|
+
/**
|
|
27
|
+
* @description 加载状态
|
|
28
|
+
* @type {Ref<boolean>}
|
|
29
|
+
* @memberof ScreenShotStore
|
|
30
|
+
*/
|
|
31
|
+
__publicField(this, "isLoading", vue.ref(false));
|
|
32
|
+
/**
|
|
33
|
+
* @description 文本状态
|
|
34
|
+
* @type {Ref<boolean>}
|
|
35
|
+
* @memberof ScreenShotStore
|
|
36
|
+
*/
|
|
37
|
+
__publicField(this, "textStatus", vue.ref(false));
|
|
38
|
+
/**
|
|
39
|
+
* @description 工具栏状态
|
|
40
|
+
* @type {Ref<boolean>}
|
|
41
|
+
* @memberof ScreenShotStore
|
|
42
|
+
*/
|
|
43
|
+
__publicField(this, "toolbarStatus", vue.ref(false));
|
|
44
|
+
/**
|
|
45
|
+
* @description 历史
|
|
46
|
+
* @type {Ref<{ data: ImageData }[]>}
|
|
47
|
+
* @memberof ScreenShotStore
|
|
48
|
+
*/
|
|
49
|
+
__publicField(this, "history", vue.ref([]));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.ScreenShotStore = ScreenShotStore;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
const BrushIcon = vue.createVNode("svg", {
|
|
7
|
+
"viewBox": "0 0 1024 1024",
|
|
8
|
+
"version": "1.1",
|
|
9
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
10
|
+
"p-id": "72848"
|
|
11
|
+
}, [vue.createVNode("path", {
|
|
12
|
+
"d": "M1.704 971.096l77.824-281.16L746.568 23.12c30.992-30.992 70.944-30.64 101.76 0l152.56 152.544c30.64 30.648 30.992 70.592 0 101.76L334.192 944.4l-281.52 77.824c-38.744 8.096-58.888-12.048-50.968-51.136z m668.76-769.952l152.56 152.368 101.76-101.752c26.336-26.168 24.616-26 0-50.792l-101.76-101.584c-24.112-26-26.352-26-50.8 0l-101.76 101.76z m-483.488 483.28l152.552 152.552L772.056 404.48 619.496 251.92 186.976 684.432zM78.672 945.28l210.064-57.504-152.56-152.544-57.504 210.048z",
|
|
13
|
+
"p-id": "72849"
|
|
14
|
+
}, null)]);
|
|
15
|
+
const RectIcon = vue.createVNode("svg", {
|
|
16
|
+
"viewBox": "0 0 1024 1024",
|
|
17
|
+
"version": "1.1",
|
|
18
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
19
|
+
"p-id": "64858"
|
|
20
|
+
}, [vue.createVNode("path", {
|
|
21
|
+
"d": "M26.962385 997.037615v-970.07523h970.07523v970.07523h-970.07523z m913.011981-913.011981h-855.948732v855.948732h855.948732v-855.948732z",
|
|
22
|
+
"p-id": "64859"
|
|
23
|
+
}, null)]);
|
|
24
|
+
const CircleIcon = vue.createVNode("svg", {
|
|
25
|
+
"viewBox": "0 0 1024 1024",
|
|
26
|
+
"version": "1.1",
|
|
27
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
28
|
+
"p-id": "65871"
|
|
29
|
+
}, [vue.createVNode("path", {
|
|
30
|
+
"d": "M510.633 120.298c52.92 0 104.269 10.302 152.555 30.725 46.625 19.729 88.611 47.922 124.562 83.795 36.041 35.963 64.295 77.773 83.977 124.293 20.468 48.182 30.791 99.42 30.791 152.231 0 52.806-10.323 104.044-30.791 152.225-19.767 46.524-48.022 88.419-83.977 124.293-36.041 35.963-77.937 64.156-124.562 83.795-48.286 20.424-99.635 30.725-152.555 30.725-52.926 0-104.274-10.301-152.561-30.725-46.621-19.724-88.611-47.918-124.562-83.795-36.041-35.963-64.295-77.768-83.977-124.293-20.467-48.182-30.791-99.42-30.791-152.225 0-52.811 10.324-104.049 30.791-152.231 19.771-46.52 48.026-88.419 83.977-124.293 35.951-35.873 77.941-64.156 124.562-83.795 48.287-20.423 99.636-30.725 152.561-30.725m0-55.862c-247.382 0-447.873 200.058-447.873 446.905 0 246.842 200.491 446.9 447.873 446.9 247.377 0 447.868-200.058 447.868-446.9 0-246.847-200.491-446.905-447.868-446.905z m0 0",
|
|
31
|
+
"p-id": "65872"
|
|
32
|
+
}, null)]);
|
|
33
|
+
const MarkerIcon = vue.createVNode("svg", {
|
|
34
|
+
"preserveAspectRatio": "none",
|
|
35
|
+
"viewBox": "0 0 1024 1024",
|
|
36
|
+
"version": "1.1",
|
|
37
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
38
|
+
"p-id": "55036"
|
|
39
|
+
}, [vue.createVNode("path", {
|
|
40
|
+
"d": "M512.01893 1.779421c-282.28432 0-511.110289 228.82597-511.110289 511.110289s228.82597 511.110289 511.110289 511.110289c282.26539 0 511.091359-228.82597 511.091359-511.110289S794.28432 1.779421 512.01893 1.779421zM512 986.139979c-261.366658 0-473.250268-211.88361-473.250268-473.250268 0-261.385588 211.88361-473.250268 473.250268-473.250268 261.385588 0 473.269198 211.88361 473.269198 473.250268C985.269198 774.237439 773.385588 986.139979 512 986.139979zM406.90058 399.309646l0 56.790032c40.207343-16.544829 71.574371-33.108589 94.063223-49.691278l0 269.752653 58.550523 0L559.514327 301.706511l-44.353015 0C502.118534 341.932784 466.037934 374.454542 406.90058 399.309646z",
|
|
41
|
+
"p-id": "55037"
|
|
42
|
+
}, null)]);
|
|
43
|
+
const TextIcon = vue.createVNode("svg", {
|
|
44
|
+
"preserveAspectRatio": "none",
|
|
45
|
+
"viewBox": "0 0 1024 1024",
|
|
46
|
+
"version": "1.1",
|
|
47
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
48
|
+
"p-id": "17173"
|
|
49
|
+
}, [vue.createVNode("path", {
|
|
50
|
+
"d": "M832 896H730.56l-72.576-210.24H361.856L293.44 896H192l270.848-768h98.24L832 896zM629.504 598.976L522.112 279.68c-3.392-10.176-7.04-28.096-11.008-53.504H508.8c-3.392 23.168-7.232 40.96-11.456 53.504l-106.56 319.296h238.72z",
|
|
51
|
+
"p-id": "17174"
|
|
52
|
+
}, null)]);
|
|
53
|
+
const ArrowIcon = vue.createVNode("svg", {
|
|
54
|
+
"preserveAspectRatio": "none",
|
|
55
|
+
"viewBox": "0 0 1024 1024",
|
|
56
|
+
"version": "1.1",
|
|
57
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
58
|
+
"p-id": "23296"
|
|
59
|
+
}, [vue.createVNode("path", {
|
|
60
|
+
"d": "M738.133333 256L230.4 763.733333l29.866667 29.866667L768 285.866667V554.666667h42.666667V213.333333h-341.333334v42.666667h268.8z",
|
|
61
|
+
"p-id": "23297"
|
|
62
|
+
}, null)]);
|
|
63
|
+
const AIIcon = vue.createVNode("svg", {
|
|
64
|
+
"version": "1.1",
|
|
65
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
66
|
+
"preserveAspectRatio": "none",
|
|
67
|
+
"viewBox": "0 0 1024 1024"
|
|
68
|
+
}, [vue.createVNode("path", {
|
|
69
|
+
"d": "M274.344554 173.673875c16.429399 0 30.950568 8.00526 39.956484 20.338945a34.906655 34.906655 0 0 1 14.660796 15.754537l1.117013 2.815803 210.138065 597.927736c6.795162 19.268474-5.329083 40.817516-27.041022 48.147913-20.641469 6.95806-42.493035-1.419537-50.451753-18.803052l-1.117013-2.815803-54.477653-154.939008H134.997185L80.566074 837.039954c-6.771891 19.268474-29.856826 28.949253-51.568765 21.618855-20.641469-6.981331-32.602816-26.761769-27.925325-45.239025l0.861031-2.908888L212.047809 212.58316c4.025901-11.426112 13.799764-19.477914 25.598214-22.619512 9.029188-10.006575 22.107548-16.289773 36.67526-16.289773z m386.416675 169.460176c21.828295 0 39.723774 10.890876 41.469106 24.713912l0.116356 2.210755v461.652153c0 14.893506-18.616883 26.947938-41.585462 26.947938-21.805024 0-39.700503-10.890876-41.422565-24.737183l-0.162897-2.210755V370.081989c0-14.870235 18.616883-26.924667 41.585462-26.924667z m-389.697901-48.171184L163.620643 600.628812h214.88537l-107.442685-305.665945z m602.163076-206.181978a12.566396 12.566396 0 0 1 8.144887 8.051802l32.509731 99.041817 101.694723 36.07021a12.566396 12.566396 0 0 1-0.791218 23.922695l-99.53051 27.995137-30.857483 97.552467a12.566396 12.566396 0 0 1-23.899423 0.116355l-32.509732-99.018546-98.669479-31.322905a12.566396 12.566396 0 0 1-0.186169-23.876152l97.505924-32.812256 30.834212-97.529195a12.566396 12.566396 0 0 1 15.754537-8.191429zM649.544557 0.513593c2.676177 0.884302 4.770576 3.025243 5.608336 5.724692l18.523798 59.294772 60.970292 20.66474a8.796477 8.796477 0 0 1-0.325796 16.755194l-60.73758 18.058377-19.780438 59.550754a8.796477 8.796477 0 0 1-16.731924-0.162898l-18.523798-59.271501-59.062061-17.825665a8.796477 8.796477 0 0 1-0.395609-16.708653l59.574025-20.943993 19.780438-59.574025a8.796477 8.796477 0 0 1 11.100317-5.561794z"
|
|
70
|
+
}, null)]);
|
|
71
|
+
const MosaicIcon = vue.createVNode("svg", {
|
|
72
|
+
"class": "icon",
|
|
73
|
+
"viewBox": "0 0 1024 1024",
|
|
74
|
+
"version": "1.1",
|
|
75
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
76
|
+
"p-id": "73852"
|
|
77
|
+
}, [vue.createVNode("path", {
|
|
78
|
+
"d": "M512 64h448v896H64V64h448z m192 64h-192v384h384V128h-192zM320 512H128v384h384V512h-192z",
|
|
79
|
+
"p-id": "73853"
|
|
80
|
+
}, null)]);
|
|
81
|
+
const DrawdownIcon = vue.createVNode("svg", {
|
|
82
|
+
"class": "icon",
|
|
83
|
+
"viewBox": "0 0 1024 1024",
|
|
84
|
+
"version": "1.1",
|
|
85
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
86
|
+
"p-id": "80469"
|
|
87
|
+
}, [vue.createVNode("path", {
|
|
88
|
+
"d": "M341.333333 298.666667v170.666666L85.333333 256l256-213.333333v170.666666h213.333334a341.333333 341.333333 0 1 1 0 682.666667H170.666667v-85.333333h384a256 256 0 0 0 0-512H341.333333z",
|
|
89
|
+
"p-id": "80470"
|
|
90
|
+
}, null)]);
|
|
91
|
+
|
|
92
|
+
exports.AIIcon = AIIcon;
|
|
93
|
+
exports.ArrowIcon = ArrowIcon;
|
|
94
|
+
exports.BrushIcon = BrushIcon;
|
|
95
|
+
exports.CircleIcon = CircleIcon;
|
|
96
|
+
exports.DrawdownIcon = DrawdownIcon;
|
|
97
|
+
exports.MarkerIcon = MarkerIcon;
|
|
98
|
+
exports.MosaicIcon = MosaicIcon;
|
|
99
|
+
exports.RectIcon = RectIcon;
|
|
100
|
+
exports.TextIcon = TextIcon;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var icon = require('./icon.cjs');
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
exports.AIIcon = icon.AIIcon;
|
|
8
|
+
exports.ArrowIcon = icon.ArrowIcon;
|
|
9
|
+
exports.BrushIcon = icon.BrushIcon;
|
|
10
|
+
exports.CircleIcon = icon.CircleIcon;
|
|
11
|
+
exports.DrawdownIcon = icon.DrawdownIcon;
|
|
12
|
+
exports.MarkerIcon = icon.MarkerIcon;
|
|
13
|
+
exports.MosaicIcon = icon.MosaicIcon;
|
|
14
|
+
exports.RectIcon = icon.RectIcon;
|
|
15
|
+
exports.TextIcon = icon.TextIcon;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => {
|
|
7
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
class DrawArrow {
|
|
11
|
+
constructor() {
|
|
12
|
+
// 起始点与结束点
|
|
13
|
+
__publicField(this, "beginPoint", { x: 0, y: 0 });
|
|
14
|
+
__publicField(this, "stopPoint", { x: 0, y: 0 });
|
|
15
|
+
// 多边形的尺寸信息
|
|
16
|
+
__publicField(this, "polygonVertex", []);
|
|
17
|
+
// 起点与X轴之间的夹角角度值
|
|
18
|
+
__publicField(this, "angle", 0);
|
|
19
|
+
// 箭头信息
|
|
20
|
+
__publicField(this, "arrowInfo", {
|
|
21
|
+
edgeLen: 50,
|
|
22
|
+
// 箭头的头部长度
|
|
23
|
+
angle: 30
|
|
24
|
+
// 箭头的头部角度
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 绘制箭头
|
|
29
|
+
* @param ctx 需要进行绘制的画布
|
|
30
|
+
* @param originX 鼠标按下时的x轴坐标
|
|
31
|
+
* @param originY 鼠标按下式的y轴坐标
|
|
32
|
+
* @param x 当前鼠标x轴坐标
|
|
33
|
+
* @param y 当前鼠标y轴坐标
|
|
34
|
+
* @param color 箭头颜色
|
|
35
|
+
*/
|
|
36
|
+
draw(ctx, originX, originY, x, y, color) {
|
|
37
|
+
this.beginPoint.x = originX;
|
|
38
|
+
this.beginPoint.y = originY;
|
|
39
|
+
this.stopPoint.x = x;
|
|
40
|
+
this.stopPoint.y = y;
|
|
41
|
+
this.arrowCord(this.beginPoint, this.stopPoint);
|
|
42
|
+
this.sideCord();
|
|
43
|
+
this.drawArrow(ctx, color);
|
|
44
|
+
}
|
|
45
|
+
// 在画布上画出递增变粗的箭头
|
|
46
|
+
drawArrow(ctx, color) {
|
|
47
|
+
ctx.fillStyle = color;
|
|
48
|
+
ctx.beginPath();
|
|
49
|
+
ctx.moveTo(this.polygonVertex[0], this.polygonVertex[1]);
|
|
50
|
+
ctx.lineTo(this.polygonVertex[2], this.polygonVertex[3]);
|
|
51
|
+
ctx.lineTo(this.polygonVertex[4], this.polygonVertex[5]);
|
|
52
|
+
ctx.lineTo(this.polygonVertex[6], this.polygonVertex[7]);
|
|
53
|
+
ctx.lineTo(this.polygonVertex[8], this.polygonVertex[9]);
|
|
54
|
+
ctx.lineTo(this.polygonVertex[10], this.polygonVertex[11]);
|
|
55
|
+
ctx.closePath();
|
|
56
|
+
ctx.fill();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 设置箭头的相关绘制信息
|
|
60
|
+
* @param edgeLen 长度
|
|
61
|
+
* @param angle 角度
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
setArrowInfo(edgeLen, angle) {
|
|
65
|
+
this.arrowInfo.edgeLen = edgeLen;
|
|
66
|
+
this.arrowInfo.angle = angle;
|
|
67
|
+
}
|
|
68
|
+
// 计算箭头尺寸
|
|
69
|
+
dynArrowSize() {
|
|
70
|
+
const x = this.stopPoint.x - this.beginPoint.x;
|
|
71
|
+
const y = this.stopPoint.y - this.beginPoint.y;
|
|
72
|
+
const length = Math.sqrt(x ** 2 + y ** 2);
|
|
73
|
+
if (length < 50) {
|
|
74
|
+
this.arrowInfo.edgeLen = length / 2;
|
|
75
|
+
} else if (length < 250) {
|
|
76
|
+
this.arrowInfo.edgeLen /= 2;
|
|
77
|
+
} else if (length < 500) {
|
|
78
|
+
this.arrowInfo.edgeLen = this.arrowInfo.edgeLen * length / 500;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// 计算起点与X轴之间的夹角角度值
|
|
82
|
+
getRadian(beginPoint, stopPoint) {
|
|
83
|
+
this.angle = Math.atan2(stopPoint.y - beginPoint.y, stopPoint.x - beginPoint.x) / Math.PI * 180;
|
|
84
|
+
this.setArrowInfo(50, 30);
|
|
85
|
+
this.dynArrowSize();
|
|
86
|
+
}
|
|
87
|
+
// 计算箭头底边两个点位置信息
|
|
88
|
+
arrowCord(beginPoint, stopPoint) {
|
|
89
|
+
this.polygonVertex[0] = beginPoint.x;
|
|
90
|
+
this.polygonVertex[1] = beginPoint.y;
|
|
91
|
+
this.polygonVertex[6] = stopPoint.x;
|
|
92
|
+
this.polygonVertex[7] = stopPoint.y;
|
|
93
|
+
this.getRadian(beginPoint, stopPoint);
|
|
94
|
+
this.polygonVertex[8] = stopPoint.x - this.arrowInfo.edgeLen * Math.cos(Math.PI / 180 * (this.angle + this.arrowInfo.angle));
|
|
95
|
+
this.polygonVertex[9] = stopPoint.y - this.arrowInfo.edgeLen * Math.sin(Math.PI / 180 * (this.angle + this.arrowInfo.angle));
|
|
96
|
+
this.polygonVertex[4] = stopPoint.x - this.arrowInfo.edgeLen * Math.cos(Math.PI / 180 * (this.angle - this.arrowInfo.angle));
|
|
97
|
+
this.polygonVertex[5] = stopPoint.y - this.arrowInfo.edgeLen * Math.sin(Math.PI / 180 * (this.angle - this.arrowInfo.angle));
|
|
98
|
+
}
|
|
99
|
+
// 计算另两个底边侧面点
|
|
100
|
+
sideCord() {
|
|
101
|
+
const midpoint = { x: 0, y: 0 };
|
|
102
|
+
midpoint.x = (this.polygonVertex[4] + this.polygonVertex[8]) / 2;
|
|
103
|
+
midpoint.y = (this.polygonVertex[5] + this.polygonVertex[9]) / 2;
|
|
104
|
+
this.polygonVertex[2] = (this.polygonVertex[4] + midpoint.x) / 2;
|
|
105
|
+
this.polygonVertex[3] = (this.polygonVertex[5] + midpoint.y) / 2;
|
|
106
|
+
this.polygonVertex[10] = (this.polygonVertex[8] + midpoint.x) / 2;
|
|
107
|
+
this.polygonVertex[11] = (this.polygonVertex[9] + midpoint.y) / 2;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
exports.DrawArrow = DrawArrow;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
function drawCircle(context, mouseX, mouseY, mouseStartX, mouseStartY, borderWidth, color) {
|
|
5
|
+
const startX = mouseX < mouseStartX ? mouseX : mouseStartX;
|
|
6
|
+
const startY = mouseY < mouseStartY ? mouseY : mouseStartY;
|
|
7
|
+
const endX = mouseX >= mouseStartX ? mouseX : mouseStartX;
|
|
8
|
+
const endY = mouseY >= mouseStartY ? mouseY : mouseStartY;
|
|
9
|
+
const radiusX = (endX - startX) * 0.5;
|
|
10
|
+
const radiusY = (endY - startY) * 0.5;
|
|
11
|
+
const centerX = startX + radiusX;
|
|
12
|
+
const centerY = startY + radiusY;
|
|
13
|
+
context.save();
|
|
14
|
+
context.beginPath();
|
|
15
|
+
context.lineWidth = borderWidth;
|
|
16
|
+
context.strokeStyle = color;
|
|
17
|
+
if (typeof context.ellipse === "function") {
|
|
18
|
+
context.ellipse(centerX, centerY, radiusX, radiusY, 0, 0, 2 * Math.PI);
|
|
19
|
+
} else {
|
|
20
|
+
throw new Error("\u4F60\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301ellipse\uFF0C\u65E0\u6CD5\u7ED8\u5236\u692D\u5706");
|
|
21
|
+
}
|
|
22
|
+
context.stroke();
|
|
23
|
+
context.closePath();
|
|
24
|
+
context.restore();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.drawCircle = drawCircle;
|