bhd-components 0.9.1 → 0.9.2
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/{100c4e1e.esm.es5.development.js → a5565b8a.esm.es5.development.js} +9674 -2548
- package/dist/deb6cc9b.esm.es5.production.js +485 -0
- package/dist/index.esm.es5.development.css +379 -0
- package/dist/index.esm.es5.development.js +3871 -6326
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/es2017/customerService/index.js +1 -1
- package/es2017/customerService/js-screen-shot/assets/less/screen-shot.less +478 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/CanvasPatch.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/CanvasPatch.js +15 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.d.ts +2 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.js +32 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/FixedData.d.ts +11 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/FixedData.js +17 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.d.ts +5 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.js +18 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.d.ts +4 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.js +25 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetColor.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetColor.js +41 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.js +23 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.d.ts +7 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.js +9 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/ImgScaling.d.ts +11 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/ImgScaling.js +41 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.d.ts +8 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.js +125 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.js +37 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.js +26 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SelectColor.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SelectColor.js +6 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SelectTextSize.d.ts +5 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SelectTextSize.js +26 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SetBrushSize.d.ts +14 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SetBrushSize.js +50 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.d.ts +7 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.js +28 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.js +20 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.js +10 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.d.ts +17 -0
- package/es2017/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.js +92 -0
- package/es2017/customerService/js-screen-shot/lib/config/Toolbar.d.ts +5 -0
- package/es2017/customerService/js-screen-shot/lib/config/Toolbar.js +46 -0
- package/es2017/customerService/js-screen-shot/lib/main-entrance/CreateDom.d.ts +24 -0
- package/es2017/customerService/js-screen-shot/lib/main-entrance/CreateDom.js +304 -0
- package/es2017/customerService/js-screen-shot/lib/main-entrance/InitData.d.ts +78 -0
- package/es2017/customerService/js-screen-shot/lib/main-entrance/InitData.js +538 -0
- package/es2017/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.d.ts +46 -0
- package/es2017/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.js +162 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/AddHistoryData.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/AddHistoryData.js +23 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.d.ts +8 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.js +13 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.d.ts +5 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.js +21 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.d.ts +16 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.js +39 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawArrow.d.ts +31 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawArrow.js +131 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCircle.d.ts +11 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCircle.js +37 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.d.ts +19 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.js +118 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.d.ts +13 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.js +51 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMasking.d.ts +6 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMasking.js +41 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMosaic.d.ts +12 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMosaic.js +67 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawPencil.d.ts +13 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawPencil.js +27 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawRectangle.d.ts +11 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawRectangle.js +22 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawText.d.ts +10 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/DrawText.js +24 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.d.ts +10 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.js +50 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.d.ts +2 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.js +61 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.js +132 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/drawCrossImg.d.ts +1 -0
- package/es2017/customerService/js-screen-shot/lib/split-methods/drawCrossImg.js +32 -0
- package/es2017/customerService/js-screen-shot/lib/type/ComponentType.d.ts +133 -0
- package/es2017/customerService/js-screen-shot/lib/type/ComponentType.js +2 -0
- package/es2017/customerService/js-screen-shot/main.d.ts +110 -0
- package/es2017/customerService/js-screen-shot/main.js +1098 -0
- package/esm/customerService/index.js +1 -1
- package/esm/customerService/js-screen-shot/assets/less/screen-shot.less +478 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/CanvasPatch.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/CanvasPatch.js +15 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.d.ts +2 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.js +32 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/FixedData.d.ts +11 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/FixedData.js +17 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.d.ts +5 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.js +18 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.d.ts +4 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.js +25 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetColor.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetColor.js +41 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.js +23 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.d.ts +7 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.js +10 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/ImgScaling.d.ts +11 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/ImgScaling.js +38 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.d.ts +8 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.js +125 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.js +37 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.js +26 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SelectColor.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SelectColor.js +6 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SelectTextSize.d.ts +5 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SelectTextSize.js +26 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SetBrushSize.d.ts +14 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SetBrushSize.js +50 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.d.ts +7 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.js +28 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.js +20 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.js +10 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.d.ts +17 -0
- package/esm/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.js +92 -0
- package/esm/customerService/js-screen-shot/lib/config/Toolbar.d.ts +5 -0
- package/esm/customerService/js-screen-shot/lib/config/Toolbar.js +46 -0
- package/esm/customerService/js-screen-shot/lib/main-entrance/CreateDom.d.ts +24 -0
- package/esm/customerService/js-screen-shot/lib/main-entrance/CreateDom.js +345 -0
- package/esm/customerService/js-screen-shot/lib/main-entrance/InitData.d.ts +78 -0
- package/esm/customerService/js-screen-shot/lib/main-entrance/InitData.js +758 -0
- package/esm/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.d.ts +46 -0
- package/esm/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.js +259 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/AddHistoryData.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/AddHistoryData.js +23 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.d.ts +8 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.js +13 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.d.ts +5 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.js +21 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.d.ts +16 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.js +39 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawArrow.d.ts +31 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawArrow.js +159 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawCircle.d.ts +11 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawCircle.js +37 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.d.ts +19 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.js +119 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.d.ts +13 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.js +51 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawMasking.d.ts +6 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawMasking.js +41 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawMosaic.d.ts +12 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawMosaic.js +67 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawPencil.d.ts +13 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawPencil.js +27 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawRectangle.d.ts +11 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawRectangle.js +22 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawText.d.ts +10 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/DrawText.js +24 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.d.ts +10 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.js +61 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.d.ts +2 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.js +62 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.js +132 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/drawCrossImg.d.ts +1 -0
- package/esm/customerService/js-screen-shot/lib/split-methods/drawCrossImg.js +32 -0
- package/esm/customerService/js-screen-shot/lib/type/ComponentType.d.ts +133 -0
- package/esm/customerService/js-screen-shot/lib/type/ComponentType.js +2 -0
- package/esm/customerService/js-screen-shot/main.d.ts +110 -0
- package/esm/customerService/js-screen-shot/main.js +1201 -0
- package/package.json +1 -1
- package/dist/a4d5ce04.esm.es5.production.js +0 -468
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
let enableWebRtc = true;
|
|
2
|
+
// electron环境下使用webrtc需要自己传入屏幕流
|
|
3
|
+
let screenFlow = null;
|
|
4
|
+
// 数据初始化标识
|
|
5
|
+
let initStatus = false;
|
|
6
|
+
// 画布宽高
|
|
7
|
+
let canvasWidth = 0;
|
|
8
|
+
let canvasHeight = 0;
|
|
9
|
+
// 展示截屏图片至容器
|
|
10
|
+
let showScreenData = false;
|
|
11
|
+
let screenShotDom = null;
|
|
12
|
+
let destroyContainer = true;
|
|
13
|
+
// 蒙层颜色
|
|
14
|
+
const maskColor = {
|
|
15
|
+
r: 0,
|
|
16
|
+
g: 0,
|
|
17
|
+
b: 0,
|
|
18
|
+
a: 0.6
|
|
19
|
+
};
|
|
20
|
+
let writeBase64 = true;
|
|
21
|
+
let cutBoxBdColor = "#2CABFF";
|
|
22
|
+
// 最大可撤销次数
|
|
23
|
+
let maxUndoNum = 15;
|
|
24
|
+
// 是否使用等比例箭头
|
|
25
|
+
let useRatioArrow = false;
|
|
26
|
+
// 开启图片自适应
|
|
27
|
+
let imgAutoFit = false;
|
|
28
|
+
let saveCallback = null;
|
|
29
|
+
let saveImgTitle = null;
|
|
30
|
+
class PlugInParameters {
|
|
31
|
+
// 设置数据初始化标识
|
|
32
|
+
setInitStatus(status) {
|
|
33
|
+
initStatus = status;
|
|
34
|
+
}
|
|
35
|
+
// 获取数据初始化标识
|
|
36
|
+
getInitStatus() {
|
|
37
|
+
return initStatus;
|
|
38
|
+
}
|
|
39
|
+
// 获取webrtc启用状态
|
|
40
|
+
getWebRtcStatus() {
|
|
41
|
+
return enableWebRtc;
|
|
42
|
+
}
|
|
43
|
+
// 设置webrtc启用状态
|
|
44
|
+
setWebRtcStatus(status) {
|
|
45
|
+
enableWebRtc = status;
|
|
46
|
+
}
|
|
47
|
+
setScreenShotDom(dom) {
|
|
48
|
+
screenShotDom = dom;
|
|
49
|
+
}
|
|
50
|
+
getCutBoxBdColor() {
|
|
51
|
+
return cutBoxBdColor;
|
|
52
|
+
}
|
|
53
|
+
setCutBoxBdColor(color) {
|
|
54
|
+
cutBoxBdColor = color;
|
|
55
|
+
}
|
|
56
|
+
getScreenShotDom() {
|
|
57
|
+
return screenShotDom;
|
|
58
|
+
}
|
|
59
|
+
// 获取屏幕流
|
|
60
|
+
getScreenFlow() {
|
|
61
|
+
return screenFlow;
|
|
62
|
+
}
|
|
63
|
+
// 设置屏幕流
|
|
64
|
+
setScreenFlow(stream) {
|
|
65
|
+
screenFlow = stream;
|
|
66
|
+
}
|
|
67
|
+
// 获取画布宽高
|
|
68
|
+
getCanvasSize() {
|
|
69
|
+
return {
|
|
70
|
+
canvasWidth: canvasWidth,
|
|
71
|
+
canvasHeight: canvasHeight
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// 设置画布宽高
|
|
75
|
+
setCanvasSize(width, height) {
|
|
76
|
+
canvasWidth = width;
|
|
77
|
+
canvasHeight = height;
|
|
78
|
+
}
|
|
79
|
+
// 获取展示图片至容器的状态
|
|
80
|
+
getShowScreenDataStatus() {
|
|
81
|
+
return showScreenData;
|
|
82
|
+
}
|
|
83
|
+
// 设置展示图片至容器的状态
|
|
84
|
+
setShowScreenDataStatus(status) {
|
|
85
|
+
showScreenData = status;
|
|
86
|
+
}
|
|
87
|
+
// 设置蒙层颜色
|
|
88
|
+
setMaskColor(color) {
|
|
89
|
+
maskColor.r = color.r;
|
|
90
|
+
maskColor.g = color.g;
|
|
91
|
+
maskColor.b = color.b;
|
|
92
|
+
maskColor.a = color.a;
|
|
93
|
+
}
|
|
94
|
+
getMaskColor() {
|
|
95
|
+
return maskColor;
|
|
96
|
+
}
|
|
97
|
+
// 设置截图数据的写入状态
|
|
98
|
+
setWriteImgState(state) {
|
|
99
|
+
writeBase64 = state;
|
|
100
|
+
}
|
|
101
|
+
getWriteImgState() {
|
|
102
|
+
return writeBase64;
|
|
103
|
+
}
|
|
104
|
+
setSaveCallback(saveFn) {
|
|
105
|
+
saveCallback = saveFn;
|
|
106
|
+
}
|
|
107
|
+
getSaveCallback() {
|
|
108
|
+
return saveCallback;
|
|
109
|
+
}
|
|
110
|
+
setMaxUndoNum(num) {
|
|
111
|
+
maxUndoNum = num;
|
|
112
|
+
}
|
|
113
|
+
getMaxUndoNum() {
|
|
114
|
+
return maxUndoNum;
|
|
115
|
+
}
|
|
116
|
+
setRatioArrow(state) {
|
|
117
|
+
useRatioArrow = state;
|
|
118
|
+
}
|
|
119
|
+
getRatioArrow() {
|
|
120
|
+
return useRatioArrow;
|
|
121
|
+
}
|
|
122
|
+
setImgAutoFit(state) {
|
|
123
|
+
imgAutoFit = state;
|
|
124
|
+
}
|
|
125
|
+
getImgAutoFit() {
|
|
126
|
+
return imgAutoFit;
|
|
127
|
+
}
|
|
128
|
+
setSaveImgTitle(title) {
|
|
129
|
+
saveImgTitle = title;
|
|
130
|
+
}
|
|
131
|
+
getSaveImgTitle() {
|
|
132
|
+
return saveImgTitle;
|
|
133
|
+
}
|
|
134
|
+
setDestroyContainerState(state) {
|
|
135
|
+
destroyContainer = state;
|
|
136
|
+
}
|
|
137
|
+
getDestroyContainerState() {
|
|
138
|
+
return destroyContainer;
|
|
139
|
+
}
|
|
140
|
+
constructor(){
|
|
141
|
+
// 标识为true时则初始化数据
|
|
142
|
+
if (initStatus) {
|
|
143
|
+
enableWebRtc = true;
|
|
144
|
+
canvasWidth = 0;
|
|
145
|
+
canvasHeight = 0;
|
|
146
|
+
cutBoxBdColor = "#2CABFF";
|
|
147
|
+
showScreenData = false;
|
|
148
|
+
writeBase64 = true;
|
|
149
|
+
screenFlow = null;
|
|
150
|
+
// 初始化完成设置其值为false
|
|
151
|
+
initStatus = false;
|
|
152
|
+
screenShotDom = null;
|
|
153
|
+
saveCallback = null;
|
|
154
|
+
maxUndoNum = 15;
|
|
155
|
+
useRatioArrow = false;
|
|
156
|
+
imgAutoFit = false;
|
|
157
|
+
saveImgTitle = null;
|
|
158
|
+
destroyContainer = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export { PlugInParameters as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addHistory(): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import InitData from "../main-entrance/InitData";
|
|
2
|
+
import PlugInParameters from "../main-entrance/PlugInParameters";
|
|
3
|
+
// 保存当前画布状态
|
|
4
|
+
export function addHistory() {
|
|
5
|
+
const data = new InitData();
|
|
6
|
+
const plugInParameters = new PlugInParameters();
|
|
7
|
+
const screenShotController = data.getScreenShotContainer();
|
|
8
|
+
if (screenShotController == null) return;
|
|
9
|
+
// 获取canvas容器
|
|
10
|
+
// 获取canvas画布与容器
|
|
11
|
+
const context = screenShotController.getContext("2d");
|
|
12
|
+
const controller = screenShotController;
|
|
13
|
+
if (data.getHistory().length > plugInParameters.getMaxUndoNum()) {
|
|
14
|
+
// 删除最早的一条画布记录
|
|
15
|
+
data.shiftHistory();
|
|
16
|
+
}
|
|
17
|
+
// 保存当前画布状态
|
|
18
|
+
data.pushHistory({
|
|
19
|
+
data: context.getImageData(0, 0, controller.width, controller.height)
|
|
20
|
+
});
|
|
21
|
+
// 启用撤销按钮
|
|
22
|
+
data.setUndoStatus(true);
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { positionInfoType } from "../type/ComponentType";
|
|
2
|
+
/**
|
|
3
|
+
* 获取工具栏工具边界绘制状态
|
|
4
|
+
* @param startX x轴绘制起点
|
|
5
|
+
* @param startY y轴绘制起点
|
|
6
|
+
* @param cutBoxPosition 裁剪框位置信息
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDrawBoundaryStatus(startX: number, startY: number, cutBoxPosition: positionInfoType): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取工具栏工具边界绘制状态
|
|
3
|
+
* @param startX x轴绘制起点
|
|
4
|
+
* @param startY y轴绘制起点
|
|
5
|
+
* @param cutBoxPosition 裁剪框位置信息
|
|
6
|
+
*/ export function getDrawBoundaryStatus(startX, startY, cutBoxPosition) {
|
|
7
|
+
if (startX < cutBoxPosition.startX || startY < cutBoxPosition.startY || startX > cutBoxPosition.startX + cutBoxPosition.width || startY > cutBoxPosition.startY + cutBoxPosition.height) {
|
|
8
|
+
// 无法绘制
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
// 可以绘制
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 计算截图工具栏画笔选项三角形角标位置
|
|
3
|
+
* @param index
|
|
4
|
+
*/ export function calculateOptionIcoPosition(index) {
|
|
5
|
+
switch(index){
|
|
6
|
+
case 1:
|
|
7
|
+
return 24 - 8;
|
|
8
|
+
case 2:
|
|
9
|
+
return 24 * 2 + 8;
|
|
10
|
+
case 3:
|
|
11
|
+
return 24 * 4 - 6;
|
|
12
|
+
case 4:
|
|
13
|
+
return 24 * 5 + 8;
|
|
14
|
+
case 5:
|
|
15
|
+
return 24 * 7 + 6;
|
|
16
|
+
case 6:
|
|
17
|
+
return 24 * 9 - 6;
|
|
18
|
+
default:
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { positionInfoType, toolPositionValType } from "../type/ComponentType";
|
|
2
|
+
/**
|
|
3
|
+
* 计算截图工具栏位置
|
|
4
|
+
* @param position 裁剪框位置信息
|
|
5
|
+
* @param toolWidth 截图工具栏宽度
|
|
6
|
+
* @param containerWidth 截图容器宽度
|
|
7
|
+
* @param placement 展示位置
|
|
8
|
+
* @param containerLocation 截图容器位置信息
|
|
9
|
+
*/
|
|
10
|
+
export declare function calculateToolLocation(position: positionInfoType, toolWidth: number, containerWidth: number, placement: toolPositionValType, containerLocation: {
|
|
11
|
+
top: number;
|
|
12
|
+
left: number;
|
|
13
|
+
}): {
|
|
14
|
+
mouseX: number;
|
|
15
|
+
mouseY: number;
|
|
16
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 计算截图工具栏位置
|
|
3
|
+
* @param position 裁剪框位置信息
|
|
4
|
+
* @param toolWidth 截图工具栏宽度
|
|
5
|
+
* @param containerWidth 截图容器宽度
|
|
6
|
+
* @param placement 展示位置
|
|
7
|
+
* @param containerLocation 截图容器位置信息
|
|
8
|
+
*/ export function calculateToolLocation(position, toolWidth, containerWidth, placement, containerLocation) {
|
|
9
|
+
// 工具栏X轴坐标 = (裁剪框的宽度 - 工具栏的宽度) / 2 + (裁剪框距离左侧的距离 - 容器距离左侧的距离)
|
|
10
|
+
let mouseX = (position.width - toolWidth) / 2 + (position.startX - containerLocation.left);
|
|
11
|
+
// 左对齐
|
|
12
|
+
if (placement === "left") {
|
|
13
|
+
mouseX = position.startX;
|
|
14
|
+
}
|
|
15
|
+
// 右对齐
|
|
16
|
+
if (placement === "right") {
|
|
17
|
+
mouseX = position.startX + position.width - toolWidth;
|
|
18
|
+
}
|
|
19
|
+
// 工具栏超出画布左侧可视区域,进行位置修正
|
|
20
|
+
if (mouseX < 0) mouseX = 0;
|
|
21
|
+
// 计算工具栏在画布内的占用面积
|
|
22
|
+
const toolSize = mouseX + toolWidth;
|
|
23
|
+
// 工具栏超出画布右侧可视区域,进行位置修正
|
|
24
|
+
if (toolSize > containerWidth) {
|
|
25
|
+
mouseX = containerWidth - toolWidth;
|
|
26
|
+
}
|
|
27
|
+
// 工具栏Y轴坐标
|
|
28
|
+
let mouseY = position.startY + position.height + 10;
|
|
29
|
+
if (position.width < 0 && position.height < 0 || position.width > 0 && position.height < 0) {
|
|
30
|
+
// 从右下角或者左下角拖动时,工具条y轴的位置应该为position.startY + 10
|
|
31
|
+
mouseY = position.startY + 10;
|
|
32
|
+
}
|
|
33
|
+
// 需要减去容器本身距离顶部的距离
|
|
34
|
+
mouseY -= containerLocation.top;
|
|
35
|
+
return {
|
|
36
|
+
mouseX,
|
|
37
|
+
mouseY
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare class DrawArrow {
|
|
2
|
+
private beginPoint;
|
|
3
|
+
private stopPoint;
|
|
4
|
+
private polygonVertex;
|
|
5
|
+
private angle;
|
|
6
|
+
private arrowInfo;
|
|
7
|
+
private size;
|
|
8
|
+
/**
|
|
9
|
+
* 绘制箭头
|
|
10
|
+
* @param ctx 需要进行绘制的画布
|
|
11
|
+
* @param originX 鼠标按下时的x轴坐标
|
|
12
|
+
* @param originY 鼠标按下式的y轴坐标
|
|
13
|
+
* @param x 当前鼠标x轴坐标
|
|
14
|
+
* @param y 当前鼠标y轴坐标
|
|
15
|
+
* @param color 箭头颜色
|
|
16
|
+
* @param size 箭头尺寸
|
|
17
|
+
*/
|
|
18
|
+
draw(ctx: CanvasRenderingContext2D, originX: number, originY: number, x: number, y: number, color: string, size: number): void;
|
|
19
|
+
private arrowCord;
|
|
20
|
+
private getRadian;
|
|
21
|
+
private sideCord;
|
|
22
|
+
/**
|
|
23
|
+
* 设置箭头的相关绘制信息
|
|
24
|
+
* @param edgeLen 长度
|
|
25
|
+
* @param angle 角度
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
private setArrowInfo;
|
|
29
|
+
private dynArrowSize;
|
|
30
|
+
private drawArrow;
|
|
31
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
+
export class DrawArrow {
|
|
3
|
+
/**
|
|
4
|
+
* 绘制箭头
|
|
5
|
+
* @param ctx 需要进行绘制的画布
|
|
6
|
+
* @param originX 鼠标按下时的x轴坐标
|
|
7
|
+
* @param originY 鼠标按下式的y轴坐标
|
|
8
|
+
* @param x 当前鼠标x轴坐标
|
|
9
|
+
* @param y 当前鼠标y轴坐标
|
|
10
|
+
* @param color 箭头颜色
|
|
11
|
+
* @param size 箭头尺寸
|
|
12
|
+
*/ draw(ctx, originX, originY, x, y, color, size) {
|
|
13
|
+
this.beginPoint.x = originX;
|
|
14
|
+
this.beginPoint.y = originY;
|
|
15
|
+
this.stopPoint.x = x;
|
|
16
|
+
this.stopPoint.y = y;
|
|
17
|
+
this.arrowCord(this.beginPoint, this.stopPoint);
|
|
18
|
+
this.sideCord();
|
|
19
|
+
this.drawArrow(ctx, color);
|
|
20
|
+
switch(size){
|
|
21
|
+
case 2:
|
|
22
|
+
this.size = 1;
|
|
23
|
+
break;
|
|
24
|
+
case 5:
|
|
25
|
+
this.size = 1.3;
|
|
26
|
+
break;
|
|
27
|
+
case 10:
|
|
28
|
+
this.size = 1.7;
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
this.size = 1;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// 计算箭头底边两个点位置信息
|
|
36
|
+
arrowCord(beginPoint, stopPoint) {
|
|
37
|
+
this.polygonVertex[0] = beginPoint.x;
|
|
38
|
+
// 多边形的第一个顶点设为起点
|
|
39
|
+
this.polygonVertex[1] = beginPoint.y;
|
|
40
|
+
this.polygonVertex[6] = stopPoint.x;
|
|
41
|
+
// 第七个顶点设为终点
|
|
42
|
+
this.polygonVertex[7] = stopPoint.y;
|
|
43
|
+
// 计算夹角
|
|
44
|
+
this.getRadian(beginPoint, stopPoint);
|
|
45
|
+
// 使用三角函数计算出8、9顶点的坐标
|
|
46
|
+
this.polygonVertex[8] = stopPoint.x - this.arrowInfo.edgeLen * Math.cos(Math.PI / 180 * (this.angle + this.arrowInfo.angle));
|
|
47
|
+
this.polygonVertex[9] = stopPoint.y - this.arrowInfo.edgeLen * Math.sin(Math.PI / 180 * (this.angle + this.arrowInfo.angle));
|
|
48
|
+
// 使用三角函数计算出4、5顶点的坐标
|
|
49
|
+
this.polygonVertex[4] = stopPoint.x - this.arrowInfo.edgeLen * Math.cos(Math.PI / 180 * (this.angle - this.arrowInfo.angle));
|
|
50
|
+
this.polygonVertex[5] = stopPoint.y - this.arrowInfo.edgeLen * Math.sin(Math.PI / 180 * (this.angle - this.arrowInfo.angle));
|
|
51
|
+
}
|
|
52
|
+
// 计算两个点之间的夹角
|
|
53
|
+
getRadian(beginPoint, stopPoint) {
|
|
54
|
+
// 使用atan2算出夹角(弧度),并将其转换为角度值(弧度 / 180)
|
|
55
|
+
this.angle = Math.atan2(stopPoint.y - beginPoint.y, stopPoint.x - beginPoint.x) / Math.PI * 180;
|
|
56
|
+
this.setArrowInfo(50 * this.size, 30 * this.size);
|
|
57
|
+
this.dynArrowSize();
|
|
58
|
+
}
|
|
59
|
+
// 计算另两个底边侧面点
|
|
60
|
+
sideCord() {
|
|
61
|
+
const midpoint = {
|
|
62
|
+
x: 0,
|
|
63
|
+
y: 0
|
|
64
|
+
};
|
|
65
|
+
midpoint.x = (this.polygonVertex[4] + this.polygonVertex[8]) / 2;
|
|
66
|
+
// 通过求出第5个顶点和第9个顶点的横纵坐标的平均值,得到多边形的中心点坐标,
|
|
67
|
+
midpoint.y = (this.polygonVertex[5] + this.polygonVertex[9]) / 2;
|
|
68
|
+
this.polygonVertex[2] = (this.polygonVertex[4] + midpoint.x) / 2;
|
|
69
|
+
this.polygonVertex[3] = (this.polygonVertex[5] + midpoint.y) / 2;
|
|
70
|
+
this.polygonVertex[10] = (this.polygonVertex[8] + midpoint.x) / 2;
|
|
71
|
+
this.polygonVertex[11] = (this.polygonVertex[9] + midpoint.y) / 2;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 设置箭头的相关绘制信息
|
|
75
|
+
* @param edgeLen 长度
|
|
76
|
+
* @param angle 角度
|
|
77
|
+
* @private
|
|
78
|
+
*/ setArrowInfo(edgeLen, angle) {
|
|
79
|
+
this.arrowInfo.edgeLen = edgeLen;
|
|
80
|
+
this.arrowInfo.angle = angle;
|
|
81
|
+
}
|
|
82
|
+
// 计算箭头尺寸
|
|
83
|
+
dynArrowSize() {
|
|
84
|
+
const x = this.stopPoint.x - this.beginPoint.x;
|
|
85
|
+
const y = this.stopPoint.y - this.beginPoint.y;
|
|
86
|
+
// 计算两点之间的直线距离
|
|
87
|
+
const length = Math.sqrt(x ** 2 + y ** 2);
|
|
88
|
+
// 根据箭头始点和终点之间的距离自适应地调整箭头大小。
|
|
89
|
+
if (length < 50) {
|
|
90
|
+
this.arrowInfo.edgeLen = length / 2;
|
|
91
|
+
} else if (length < 250) {
|
|
92
|
+
this.arrowInfo.edgeLen /= 2;
|
|
93
|
+
} else if (length < 500) {
|
|
94
|
+
this.arrowInfo.edgeLen = this.arrowInfo.edgeLen * length / 500;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// 在画布上画出递增变粗的箭头
|
|
98
|
+
drawArrow(ctx, color) {
|
|
99
|
+
ctx.fillStyle = color;
|
|
100
|
+
ctx.beginPath();
|
|
101
|
+
ctx.moveTo(this.polygonVertex[0], this.polygonVertex[1]);
|
|
102
|
+
ctx.lineTo(this.polygonVertex[2], this.polygonVertex[3]);
|
|
103
|
+
ctx.lineTo(this.polygonVertex[4], this.polygonVertex[5]);
|
|
104
|
+
ctx.lineTo(this.polygonVertex[6], this.polygonVertex[7]);
|
|
105
|
+
ctx.lineTo(this.polygonVertex[8], this.polygonVertex[9]);
|
|
106
|
+
ctx.lineTo(this.polygonVertex[10], this.polygonVertex[11]);
|
|
107
|
+
ctx.closePath();
|
|
108
|
+
ctx.fill();
|
|
109
|
+
}
|
|
110
|
+
constructor(){
|
|
111
|
+
// 起始点与结束点
|
|
112
|
+
_define_property(this, "beginPoint", {
|
|
113
|
+
x: 0,
|
|
114
|
+
y: 0
|
|
115
|
+
});
|
|
116
|
+
_define_property(this, "stopPoint", {
|
|
117
|
+
x: 0,
|
|
118
|
+
y: 0
|
|
119
|
+
});
|
|
120
|
+
// 多边形的尺寸信息
|
|
121
|
+
_define_property(this, "polygonVertex", []);
|
|
122
|
+
// 起点与X轴之间的夹角角度值
|
|
123
|
+
_define_property(this, "angle", 0);
|
|
124
|
+
// 箭头信息
|
|
125
|
+
_define_property(this, "arrowInfo", {
|
|
126
|
+
edgeLen: 50,
|
|
127
|
+
angle: 30 // 箭头的头部角度
|
|
128
|
+
});
|
|
129
|
+
_define_property(this, "size", 1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绘制圆形
|
|
3
|
+
* @param context 需要进行绘制的画布
|
|
4
|
+
* @param mouseX 当前鼠标x轴坐标
|
|
5
|
+
* @param mouseY 当前鼠标y轴坐标
|
|
6
|
+
* @param mouseStartX 鼠标按下时的x轴坐标
|
|
7
|
+
* @param mouseStartY 鼠标按下时的y轴坐标
|
|
8
|
+
* @param borderWidth 边框宽度
|
|
9
|
+
* @param color 边框颜色
|
|
10
|
+
*/
|
|
11
|
+
export declare function drawCircle(context: CanvasRenderingContext2D, mouseX: number, mouseY: number, mouseStartX: number, mouseStartY: number, borderWidth: number, color: string): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绘制圆形
|
|
3
|
+
* @param context 需要进行绘制的画布
|
|
4
|
+
* @param mouseX 当前鼠标x轴坐标
|
|
5
|
+
* @param mouseY 当前鼠标y轴坐标
|
|
6
|
+
* @param mouseStartX 鼠标按下时的x轴坐标
|
|
7
|
+
* @param mouseStartY 鼠标按下时的y轴坐标
|
|
8
|
+
* @param borderWidth 边框宽度
|
|
9
|
+
* @param color 边框颜色
|
|
10
|
+
*/ export function drawCircle(context, mouseX, mouseY, mouseStartX, mouseStartY, borderWidth, color) {
|
|
11
|
+
// 坐标边界处理,解决反向绘制椭圆时的报错问题
|
|
12
|
+
const startX = mouseX < mouseStartX ? mouseX : mouseStartX;
|
|
13
|
+
const startY = mouseY < mouseStartY ? mouseY : mouseStartY;
|
|
14
|
+
const endX = mouseX >= mouseStartX ? mouseX : mouseStartX;
|
|
15
|
+
const endY = mouseY >= mouseStartY ? mouseY : mouseStartY;
|
|
16
|
+
// 计算圆的半径
|
|
17
|
+
const radiusX = (endX - startX) * 0.5;
|
|
18
|
+
const radiusY = (endY - startY) * 0.5;
|
|
19
|
+
// 计算圆心的x、y坐标
|
|
20
|
+
const centerX = startX + radiusX;
|
|
21
|
+
const centerY = startY + radiusY;
|
|
22
|
+
// 开始绘制
|
|
23
|
+
context.save();
|
|
24
|
+
context.beginPath();
|
|
25
|
+
context.lineWidth = borderWidth;
|
|
26
|
+
context.strokeStyle = color;
|
|
27
|
+
if (typeof context.ellipse === "function") {
|
|
28
|
+
// 绘制圆,旋转角度与起始角度都为0,结束角度为2*PI
|
|
29
|
+
context.ellipse(centerX, centerY, radiusX, radiusY, 0, 0, 2 * Math.PI);
|
|
30
|
+
} else {
|
|
31
|
+
throw "你的浏览器不支持ellipse,无法绘制椭圆";
|
|
32
|
+
}
|
|
33
|
+
context.stroke();
|
|
34
|
+
context.closePath();
|
|
35
|
+
// 结束绘制
|
|
36
|
+
context.restore();
|
|
37
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绘制裁剪框
|
|
3
|
+
* @param mouseX 鼠标x轴坐标
|
|
4
|
+
* @param mouseY 鼠标y轴坐标
|
|
5
|
+
* @param width 裁剪框宽度
|
|
6
|
+
* @param height 裁剪框高度
|
|
7
|
+
* @param context 需要进行绘制的canvas画布
|
|
8
|
+
* @param borderSize 边框节点直径
|
|
9
|
+
* @param controller 需要进行操作的canvas容器
|
|
10
|
+
* @param imageController 图片canvas容器
|
|
11
|
+
* @param drawBorders
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
export declare function drawCutOutBox(mouseX: number, mouseY: number, width: number, height: number, context: CanvasRenderingContext2D, borderSize: number, controller: HTMLCanvasElement, imageController: HTMLCanvasElement, drawBorders?: boolean): {
|
|
15
|
+
startX: number;
|
|
16
|
+
startY: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import PlugInParameters from "../main-entrance/PlugInParameters";
|
|
2
|
+
/**
|
|
3
|
+
* 绘制裁剪框
|
|
4
|
+
* @param mouseX 鼠标x轴坐标
|
|
5
|
+
* @param mouseY 鼠标y轴坐标
|
|
6
|
+
* @param width 裁剪框宽度
|
|
7
|
+
* @param height 裁剪框高度
|
|
8
|
+
* @param context 需要进行绘制的canvas画布
|
|
9
|
+
* @param borderSize 边框节点直径
|
|
10
|
+
* @param controller 需要进行操作的canvas容器
|
|
11
|
+
* @param imageController 图片canvas容器
|
|
12
|
+
* @param drawBorders
|
|
13
|
+
* @private
|
|
14
|
+
*/ export function drawCutOutBox(mouseX, mouseY, width, height, context, borderSize, controller, imageController, drawBorders = true) {
|
|
15
|
+
// 获取画布宽高
|
|
16
|
+
const canvasWidth = controller === null || controller === void 0 ? void 0 : controller.width;
|
|
17
|
+
const canvasHeight = controller === null || controller === void 0 ? void 0 : controller.height;
|
|
18
|
+
const dpr = window.devicePixelRatio || 1;
|
|
19
|
+
const data = new PlugInParameters();
|
|
20
|
+
// 画布、图片不存在则return
|
|
21
|
+
if (!canvasWidth || !canvasHeight || !imageController || !controller) return;
|
|
22
|
+
// 清除画布
|
|
23
|
+
context.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
24
|
+
width = width != 0 ? width : 5;
|
|
25
|
+
height = height != 0 ? height : 5;
|
|
26
|
+
// 绘制蒙层
|
|
27
|
+
context.save();
|
|
28
|
+
const maskColor = data.getMaskColor();
|
|
29
|
+
context.fillStyle = "rgba(0, 0, 0, .6)";
|
|
30
|
+
if (maskColor) {
|
|
31
|
+
context.fillStyle = `rgba(${maskColor.r}, ${maskColor.g}, ${maskColor.b}, ${maskColor.a})`;
|
|
32
|
+
}
|
|
33
|
+
context.fillRect(0, 0, canvasWidth, canvasHeight);
|
|
34
|
+
// 将蒙层凿开
|
|
35
|
+
context.globalCompositeOperation = "source-atop";
|
|
36
|
+
// 裁剪选择框
|
|
37
|
+
context.clearRect(mouseX, mouseY, width, height);
|
|
38
|
+
// 绘制8个边框像素点并保存坐标信息以及事件参数
|
|
39
|
+
context.globalCompositeOperation = "source-over";
|
|
40
|
+
context.fillStyle = data.getCutBoxBdColor();
|
|
41
|
+
// 是否绘制裁剪框的8个像素点
|
|
42
|
+
if (drawBorders) {
|
|
43
|
+
// 像素点大小
|
|
44
|
+
const size = borderSize;
|
|
45
|
+
// 绘制像素点
|
|
46
|
+
context.fillRect(mouseX - size / 2, mouseY - size / 2, size, size);
|
|
47
|
+
context.fillRect(mouseX - size / 2 + width / 2, mouseY - size / 2, size, size);
|
|
48
|
+
context.fillRect(mouseX - size / 2 + width, mouseY - size / 2, size, size);
|
|
49
|
+
context.fillRect(mouseX - size / 2, mouseY - size / 2 + height / 2, size, size);
|
|
50
|
+
context.fillRect(mouseX - size / 2 + width, mouseY - size / 2 + height / 2, size, size);
|
|
51
|
+
context.fillRect(mouseX - size / 2, mouseY - size / 2 + height, size, size);
|
|
52
|
+
context.fillRect(mouseX - size / 2 + width / 2, mouseY - size / 2 + height, size, size);
|
|
53
|
+
context.fillRect(mouseX - size / 2 + width, mouseY - size / 2 + height, size, size);
|
|
54
|
+
}
|
|
55
|
+
// 绘制结束
|
|
56
|
+
context.restore();
|
|
57
|
+
// 使用drawImage将图片绘制到蒙层下方
|
|
58
|
+
context.save();
|
|
59
|
+
context.globalCompositeOperation = "destination-over";
|
|
60
|
+
// 图片尺寸使用canvas容器的css中的尺寸
|
|
61
|
+
let { imgWidth , imgHeight } = {
|
|
62
|
+
imgWidth: parseInt(controller === null || controller === void 0 ? void 0 : controller.style.width),
|
|
63
|
+
imgHeight: parseInt(controller === null || controller === void 0 ? void 0 : controller.style.height)
|
|
64
|
+
};
|
|
65
|
+
// 用户有传入截图dom绘制时使用其dom的尺寸
|
|
66
|
+
const screenShotDom = data.getScreenShotDom();
|
|
67
|
+
if (screenShotDom != null) {
|
|
68
|
+
imgWidth = screenShotDom.clientWidth;
|
|
69
|
+
imgHeight = screenShotDom.clientHeight;
|
|
70
|
+
}
|
|
71
|
+
// 非webrtc模式、未开启图片自适应、未传入截图dom时,图片的宽高不做处理
|
|
72
|
+
if (!data.getWebRtcStatus() && !data.getImgAutoFit() && screenShotDom == null) {
|
|
73
|
+
imgWidth = imageController.width / dpr;
|
|
74
|
+
imgHeight = imageController.height / dpr;
|
|
75
|
+
}
|
|
76
|
+
context.drawImage(imageController, 0, 0, imgWidth, imgHeight);
|
|
77
|
+
context.restore();
|
|
78
|
+
// 返回裁剪框临时位置信息
|
|
79
|
+
if (width > 0 && height > 0) {
|
|
80
|
+
// 考虑左上往右下拉区域的情况
|
|
81
|
+
return {
|
|
82
|
+
startX: mouseX,
|
|
83
|
+
startY: mouseY,
|
|
84
|
+
width: width,
|
|
85
|
+
height: height
|
|
86
|
+
};
|
|
87
|
+
} else if (width < 0 && height < 0) {
|
|
88
|
+
// 考虑右下往左上拉区域的情况
|
|
89
|
+
return {
|
|
90
|
+
startX: mouseX + width,
|
|
91
|
+
startY: mouseY + height,
|
|
92
|
+
width: Math.abs(width),
|
|
93
|
+
height: Math.abs(height)
|
|
94
|
+
};
|
|
95
|
+
} else if (width > 0 && height < 0) {
|
|
96
|
+
// 考虑左下往右上拉区域的情况
|
|
97
|
+
return {
|
|
98
|
+
startX: mouseX,
|
|
99
|
+
startY: mouseY + height,
|
|
100
|
+
width: width,
|
|
101
|
+
height: Math.abs(height)
|
|
102
|
+
};
|
|
103
|
+
} else if (width < 0 && height > 0) {
|
|
104
|
+
// 考虑右上往左下拉区域的情况
|
|
105
|
+
return {
|
|
106
|
+
startX: mouseX + width,
|
|
107
|
+
startY: mouseY,
|
|
108
|
+
width: Math.abs(width),
|
|
109
|
+
height: height
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
startX: mouseX,
|
|
114
|
+
startY: mouseY,
|
|
115
|
+
width: width,
|
|
116
|
+
height: height
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绘制箭头
|
|
3
|
+
* @param context 需要进行绘制的画布
|
|
4
|
+
* @param mouseStartX 鼠标按下时的x轴坐标 P1
|
|
5
|
+
* @param mouseStartY 鼠标按下式的y轴坐标 P1
|
|
6
|
+
* @param mouseX 当前鼠标x轴坐标 P2
|
|
7
|
+
* @param mouseY 当前鼠标y轴坐标 P2
|
|
8
|
+
* @param theta 箭头斜线与直线的夹角角度 (θ) P3 ---> (P1、P2) || P4 ---> P1(P1、P2)
|
|
9
|
+
* @param slashLength 箭头斜线的长度 P3 ---> P2 || P4 ---> P2
|
|
10
|
+
* @param borderWidth 边框宽度
|
|
11
|
+
* @param color 边框颜色
|
|
12
|
+
*/
|
|
13
|
+
export declare function drawLineArrow(context: CanvasRenderingContext2D, mouseStartX: number, mouseStartY: number, mouseX: number, mouseY: number, theta: number, slashLength: number, borderWidth: number, color: string): void;
|