bhd-components 0.9.0 → 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/{f8c2008a.esm.es5.development.js → a5565b8a.esm.es5.development.js} +9382 -1289
- package/dist/deb6cc9b.esm.es5.production.js +485 -0
- package/dist/index.esm.es5.development.css +2278 -1580
- package/dist/index.esm.es5.development.js +4454 -221
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/es2017/bhdDatePicker/index.d.ts +0 -1
- package/es2017/bhdDatePicker/index.js +238 -171
- package/es2017/bhdDatePicker/index.module.less +81 -46
- package/es2017/customerService/index.js +122 -23
- 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/es2017/customerService/screenShotPlugin.esm.js +6515 -0
- package/es2017/customerService/screenshotTool.d.ts +1 -0
- package/es2017/customerService/screenshotTool.js +23 -15
- package/es2017/theme/variable.less +27 -0
- package/esm/bhdDatePicker/index.d.ts +0 -1
- package/esm/bhdDatePicker/index.js +242 -175
- package/esm/bhdDatePicker/index.module.less +81 -46
- package/esm/customerService/index.js +127 -27
- 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/esm/customerService/screenShotPlugin.esm.js +6516 -0
- package/esm/customerService/screenshotTool.d.ts +1 -0
- package/esm/customerService/screenshotTool.js +21 -13
- package/esm/theme/variable.less +27 -0
- package/package.json +20 -2
- package/dist/256789e0.esm.es5.production.js +0 -468
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default class PlugInParameters {
|
|
2
|
+
constructor();
|
|
3
|
+
setInitStatus(status: boolean): void;
|
|
4
|
+
getInitStatus(): boolean;
|
|
5
|
+
getWebRtcStatus(): boolean;
|
|
6
|
+
setWebRtcStatus(status: boolean): void;
|
|
7
|
+
setScreenShotDom(dom: HTMLElement): void;
|
|
8
|
+
getCutBoxBdColor(): string;
|
|
9
|
+
setCutBoxBdColor(color: string): void;
|
|
10
|
+
getScreenShotDom(): HTMLElement;
|
|
11
|
+
getScreenFlow(): MediaStream;
|
|
12
|
+
setScreenFlow(stream: MediaStream): void;
|
|
13
|
+
getCanvasSize(): {
|
|
14
|
+
canvasWidth: number;
|
|
15
|
+
canvasHeight: number;
|
|
16
|
+
};
|
|
17
|
+
setCanvasSize(width: number, height: number): void;
|
|
18
|
+
getShowScreenDataStatus(): boolean;
|
|
19
|
+
setShowScreenDataStatus(status: boolean): void;
|
|
20
|
+
setMaskColor(color: {
|
|
21
|
+
r: number;
|
|
22
|
+
g: number;
|
|
23
|
+
b: number;
|
|
24
|
+
a: number;
|
|
25
|
+
}): void;
|
|
26
|
+
getMaskColor(): {
|
|
27
|
+
r: number;
|
|
28
|
+
g: number;
|
|
29
|
+
b: number;
|
|
30
|
+
a: number;
|
|
31
|
+
};
|
|
32
|
+
setWriteImgState(state: boolean): void;
|
|
33
|
+
getWriteImgState(): boolean;
|
|
34
|
+
setSaveCallback(saveFn: (code: number, msg: string) => void): void;
|
|
35
|
+
getSaveCallback(): (code: number, msg: string) => void;
|
|
36
|
+
setMaxUndoNum(num: number): void;
|
|
37
|
+
getMaxUndoNum(): number;
|
|
38
|
+
setRatioArrow(state: boolean): void;
|
|
39
|
+
getRatioArrow(): boolean;
|
|
40
|
+
setImgAutoFit(state: boolean): void;
|
|
41
|
+
getImgAutoFit(): boolean;
|
|
42
|
+
setSaveImgTitle(title: string): void;
|
|
43
|
+
getSaveImgTitle(): string;
|
|
44
|
+
setDestroyContainerState(state: boolean): void;
|
|
45
|
+
getDestroyContainerState(): boolean;
|
|
46
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
|
2
|
+
import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
|
3
|
+
var enableWebRtc = true;
|
|
4
|
+
// electron环境下使用webrtc需要自己传入屏幕流
|
|
5
|
+
var screenFlow = null;
|
|
6
|
+
// 数据初始化标识
|
|
7
|
+
var initStatus = false;
|
|
8
|
+
// 画布宽高
|
|
9
|
+
var canvasWidth = 0;
|
|
10
|
+
var canvasHeight = 0;
|
|
11
|
+
// 展示截屏图片至容器
|
|
12
|
+
var showScreenData = false;
|
|
13
|
+
var screenShotDom = null;
|
|
14
|
+
var destroyContainer = true;
|
|
15
|
+
// 蒙层颜色
|
|
16
|
+
var maskColor = {
|
|
17
|
+
r: 0,
|
|
18
|
+
g: 0,
|
|
19
|
+
b: 0,
|
|
20
|
+
a: 0.6
|
|
21
|
+
};
|
|
22
|
+
var writeBase64 = true;
|
|
23
|
+
var cutBoxBdColor = "#2CABFF";
|
|
24
|
+
// 最大可撤销次数
|
|
25
|
+
var maxUndoNum = 15;
|
|
26
|
+
// 是否使用等比例箭头
|
|
27
|
+
var useRatioArrow = false;
|
|
28
|
+
// 开启图片自适应
|
|
29
|
+
var imgAutoFit = false;
|
|
30
|
+
var saveCallback = null;
|
|
31
|
+
var saveImgTitle = null;
|
|
32
|
+
var PlugInParameters = /*#__PURE__*/ function() {
|
|
33
|
+
"use strict";
|
|
34
|
+
function PlugInParameters() {
|
|
35
|
+
_class_call_check(this, PlugInParameters);
|
|
36
|
+
// 标识为true时则初始化数据
|
|
37
|
+
if (initStatus) {
|
|
38
|
+
enableWebRtc = true;
|
|
39
|
+
canvasWidth = 0;
|
|
40
|
+
canvasHeight = 0;
|
|
41
|
+
cutBoxBdColor = "#2CABFF";
|
|
42
|
+
showScreenData = false;
|
|
43
|
+
writeBase64 = true;
|
|
44
|
+
screenFlow = null;
|
|
45
|
+
// 初始化完成设置其值为false
|
|
46
|
+
initStatus = false;
|
|
47
|
+
screenShotDom = null;
|
|
48
|
+
saveCallback = null;
|
|
49
|
+
maxUndoNum = 15;
|
|
50
|
+
useRatioArrow = false;
|
|
51
|
+
imgAutoFit = false;
|
|
52
|
+
saveImgTitle = null;
|
|
53
|
+
destroyContainer = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
_create_class(PlugInParameters, [
|
|
57
|
+
{
|
|
58
|
+
key: "setInitStatus",
|
|
59
|
+
value: // 设置数据初始化标识
|
|
60
|
+
function setInitStatus(status) {
|
|
61
|
+
initStatus = status;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
key: "getInitStatus",
|
|
66
|
+
value: // 获取数据初始化标识
|
|
67
|
+
function getInitStatus() {
|
|
68
|
+
return initStatus;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: "getWebRtcStatus",
|
|
73
|
+
value: // 获取webrtc启用状态
|
|
74
|
+
function getWebRtcStatus() {
|
|
75
|
+
return enableWebRtc;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
key: "setWebRtcStatus",
|
|
80
|
+
value: // 设置webrtc启用状态
|
|
81
|
+
function setWebRtcStatus(status) {
|
|
82
|
+
enableWebRtc = status;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
key: "setScreenShotDom",
|
|
87
|
+
value: function setScreenShotDom(dom) {
|
|
88
|
+
screenShotDom = dom;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: "getCutBoxBdColor",
|
|
93
|
+
value: function getCutBoxBdColor() {
|
|
94
|
+
return cutBoxBdColor;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
key: "setCutBoxBdColor",
|
|
99
|
+
value: function setCutBoxBdColor(color) {
|
|
100
|
+
cutBoxBdColor = color;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
key: "getScreenShotDom",
|
|
105
|
+
value: function getScreenShotDom() {
|
|
106
|
+
return screenShotDom;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
key: "getScreenFlow",
|
|
111
|
+
value: // 获取屏幕流
|
|
112
|
+
function getScreenFlow() {
|
|
113
|
+
return screenFlow;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
key: "setScreenFlow",
|
|
118
|
+
value: // 设置屏幕流
|
|
119
|
+
function setScreenFlow(stream) {
|
|
120
|
+
screenFlow = stream;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: "getCanvasSize",
|
|
125
|
+
value: // 获取画布宽高
|
|
126
|
+
function getCanvasSize() {
|
|
127
|
+
return {
|
|
128
|
+
canvasWidth: canvasWidth,
|
|
129
|
+
canvasHeight: canvasHeight
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
key: "setCanvasSize",
|
|
135
|
+
value: // 设置画布宽高
|
|
136
|
+
function setCanvasSize(width, height) {
|
|
137
|
+
canvasWidth = width;
|
|
138
|
+
canvasHeight = height;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
key: "getShowScreenDataStatus",
|
|
143
|
+
value: // 获取展示图片至容器的状态
|
|
144
|
+
function getShowScreenDataStatus() {
|
|
145
|
+
return showScreenData;
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: "setShowScreenDataStatus",
|
|
150
|
+
value: // 设置展示图片至容器的状态
|
|
151
|
+
function setShowScreenDataStatus(status) {
|
|
152
|
+
showScreenData = status;
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
key: "setMaskColor",
|
|
157
|
+
value: // 设置蒙层颜色
|
|
158
|
+
function setMaskColor(color) {
|
|
159
|
+
maskColor.r = color.r;
|
|
160
|
+
maskColor.g = color.g;
|
|
161
|
+
maskColor.b = color.b;
|
|
162
|
+
maskColor.a = color.a;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key: "getMaskColor",
|
|
167
|
+
value: function getMaskColor() {
|
|
168
|
+
return maskColor;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
key: "setWriteImgState",
|
|
173
|
+
value: // 设置截图数据的写入状态
|
|
174
|
+
function setWriteImgState(state) {
|
|
175
|
+
writeBase64 = state;
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
key: "getWriteImgState",
|
|
180
|
+
value: function getWriteImgState() {
|
|
181
|
+
return writeBase64;
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: "setSaveCallback",
|
|
186
|
+
value: function setSaveCallback(saveFn) {
|
|
187
|
+
saveCallback = saveFn;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
key: "getSaveCallback",
|
|
192
|
+
value: function getSaveCallback() {
|
|
193
|
+
return saveCallback;
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
key: "setMaxUndoNum",
|
|
198
|
+
value: function setMaxUndoNum(num) {
|
|
199
|
+
maxUndoNum = num;
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
key: "getMaxUndoNum",
|
|
204
|
+
value: function getMaxUndoNum() {
|
|
205
|
+
return maxUndoNum;
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
key: "setRatioArrow",
|
|
210
|
+
value: function setRatioArrow(state) {
|
|
211
|
+
useRatioArrow = state;
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
key: "getRatioArrow",
|
|
216
|
+
value: function getRatioArrow() {
|
|
217
|
+
return useRatioArrow;
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: "setImgAutoFit",
|
|
222
|
+
value: function setImgAutoFit(state) {
|
|
223
|
+
imgAutoFit = state;
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
key: "getImgAutoFit",
|
|
228
|
+
value: function getImgAutoFit() {
|
|
229
|
+
return imgAutoFit;
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: "setSaveImgTitle",
|
|
234
|
+
value: function setSaveImgTitle(title) {
|
|
235
|
+
saveImgTitle = title;
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
key: "getSaveImgTitle",
|
|
240
|
+
value: function getSaveImgTitle() {
|
|
241
|
+
return saveImgTitle;
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
key: "setDestroyContainerState",
|
|
246
|
+
value: function setDestroyContainerState(state) {
|
|
247
|
+
destroyContainer = state;
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
key: "getDestroyContainerState",
|
|
252
|
+
value: function getDestroyContainerState() {
|
|
253
|
+
return destroyContainer;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
]);
|
|
257
|
+
return PlugInParameters;
|
|
258
|
+
}();
|
|
259
|
+
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
|
+
var data = new InitData();
|
|
6
|
+
var plugInParameters = new PlugInParameters();
|
|
7
|
+
var screenShotController = data.getScreenShotContainer();
|
|
8
|
+
if (screenShotController == null) return;
|
|
9
|
+
// 获取canvas容器
|
|
10
|
+
// 获取canvas画布与容器
|
|
11
|
+
var context = screenShotController.getContext("2d");
|
|
12
|
+
var 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
|
+
var 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
|
+
var toolSize = mouseX + toolWidth;
|
|
23
|
+
// 工具栏超出画布右侧可视区域,进行位置修正
|
|
24
|
+
if (toolSize > containerWidth) {
|
|
25
|
+
mouseX = containerWidth - toolWidth;
|
|
26
|
+
}
|
|
27
|
+
// 工具栏Y轴坐标
|
|
28
|
+
var 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: mouseX,
|
|
37
|
+
mouseY: 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,159 @@
|
|
|
1
|
+
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
|
2
|
+
import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
|
3
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
4
|
+
export var DrawArrow = /*#__PURE__*/ function() {
|
|
5
|
+
"use strict";
|
|
6
|
+
function DrawArrow() {
|
|
7
|
+
_class_call_check(this, DrawArrow);
|
|
8
|
+
// 起始点与结束点
|
|
9
|
+
_define_property(this, "beginPoint", {
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0
|
|
12
|
+
});
|
|
13
|
+
_define_property(this, "stopPoint", {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0
|
|
16
|
+
});
|
|
17
|
+
// 多边形的尺寸信息
|
|
18
|
+
_define_property(this, "polygonVertex", []);
|
|
19
|
+
// 起点与X轴之间的夹角角度值
|
|
20
|
+
_define_property(this, "angle", 0);
|
|
21
|
+
// 箭头信息
|
|
22
|
+
_define_property(this, "arrowInfo", {
|
|
23
|
+
edgeLen: 50,
|
|
24
|
+
angle: 30 // 箭头的头部角度
|
|
25
|
+
});
|
|
26
|
+
_define_property(this, "size", 1);
|
|
27
|
+
}
|
|
28
|
+
_create_class(DrawArrow, [
|
|
29
|
+
{
|
|
30
|
+
key: "draw",
|
|
31
|
+
value: /**
|
|
32
|
+
* 绘制箭头
|
|
33
|
+
* @param ctx 需要进行绘制的画布
|
|
34
|
+
* @param originX 鼠标按下时的x轴坐标
|
|
35
|
+
* @param originY 鼠标按下式的y轴坐标
|
|
36
|
+
* @param x 当前鼠标x轴坐标
|
|
37
|
+
* @param y 当前鼠标y轴坐标
|
|
38
|
+
* @param color 箭头颜色
|
|
39
|
+
* @param size 箭头尺寸
|
|
40
|
+
*/ function draw(ctx, originX, originY, x, y, color, size) {
|
|
41
|
+
this.beginPoint.x = originX;
|
|
42
|
+
this.beginPoint.y = originY;
|
|
43
|
+
this.stopPoint.x = x;
|
|
44
|
+
this.stopPoint.y = y;
|
|
45
|
+
this.arrowCord(this.beginPoint, this.stopPoint);
|
|
46
|
+
this.sideCord();
|
|
47
|
+
this.drawArrow(ctx, color);
|
|
48
|
+
switch(size){
|
|
49
|
+
case 2:
|
|
50
|
+
this.size = 1;
|
|
51
|
+
break;
|
|
52
|
+
case 5:
|
|
53
|
+
this.size = 1.3;
|
|
54
|
+
break;
|
|
55
|
+
case 10:
|
|
56
|
+
this.size = 1.7;
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
this.size = 1;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
key: "arrowCord",
|
|
66
|
+
value: // 计算箭头底边两个点位置信息
|
|
67
|
+
function arrowCord(beginPoint, stopPoint) {
|
|
68
|
+
this.polygonVertex[0] = beginPoint.x;
|
|
69
|
+
// 多边形的第一个顶点设为起点
|
|
70
|
+
this.polygonVertex[1] = beginPoint.y;
|
|
71
|
+
this.polygonVertex[6] = stopPoint.x;
|
|
72
|
+
// 第七个顶点设为终点
|
|
73
|
+
this.polygonVertex[7] = stopPoint.y;
|
|
74
|
+
// 计算夹角
|
|
75
|
+
this.getRadian(beginPoint, stopPoint);
|
|
76
|
+
// 使用三角函数计算出8、9顶点的坐标
|
|
77
|
+
this.polygonVertex[8] = stopPoint.x - this.arrowInfo.edgeLen * Math.cos(Math.PI / 180 * (this.angle + this.arrowInfo.angle));
|
|
78
|
+
this.polygonVertex[9] = stopPoint.y - this.arrowInfo.edgeLen * Math.sin(Math.PI / 180 * (this.angle + this.arrowInfo.angle));
|
|
79
|
+
// 使用三角函数计算出4、5顶点的坐标
|
|
80
|
+
this.polygonVertex[4] = stopPoint.x - this.arrowInfo.edgeLen * Math.cos(Math.PI / 180 * (this.angle - this.arrowInfo.angle));
|
|
81
|
+
this.polygonVertex[5] = stopPoint.y - this.arrowInfo.edgeLen * Math.sin(Math.PI / 180 * (this.angle - this.arrowInfo.angle));
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
key: "getRadian",
|
|
86
|
+
value: // 计算两个点之间的夹角
|
|
87
|
+
function getRadian(beginPoint, stopPoint) {
|
|
88
|
+
// 使用atan2算出夹角(弧度),并将其转换为角度值(弧度 / 180)
|
|
89
|
+
this.angle = Math.atan2(stopPoint.y - beginPoint.y, stopPoint.x - beginPoint.x) / Math.PI * 180;
|
|
90
|
+
this.setArrowInfo(50 * this.size, 30 * this.size);
|
|
91
|
+
this.dynArrowSize();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
key: "sideCord",
|
|
96
|
+
value: // 计算另两个底边侧面点
|
|
97
|
+
function sideCord() {
|
|
98
|
+
var midpoint = {
|
|
99
|
+
x: 0,
|
|
100
|
+
y: 0
|
|
101
|
+
};
|
|
102
|
+
midpoint.x = (this.polygonVertex[4] + this.polygonVertex[8]) / 2;
|
|
103
|
+
// 通过求出第5个顶点和第9个顶点的横纵坐标的平均值,得到多边形的中心点坐标,
|
|
104
|
+
midpoint.y = (this.polygonVertex[5] + this.polygonVertex[9]) / 2;
|
|
105
|
+
this.polygonVertex[2] = (this.polygonVertex[4] + midpoint.x) / 2;
|
|
106
|
+
this.polygonVertex[3] = (this.polygonVertex[5] + midpoint.y) / 2;
|
|
107
|
+
this.polygonVertex[10] = (this.polygonVertex[8] + midpoint.x) / 2;
|
|
108
|
+
this.polygonVertex[11] = (this.polygonVertex[9] + midpoint.y) / 2;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
key: "setArrowInfo",
|
|
113
|
+
value: /**
|
|
114
|
+
* 设置箭头的相关绘制信息
|
|
115
|
+
* @param edgeLen 长度
|
|
116
|
+
* @param angle 角度
|
|
117
|
+
* @private
|
|
118
|
+
*/ function setArrowInfo(edgeLen, angle) {
|
|
119
|
+
this.arrowInfo.edgeLen = edgeLen;
|
|
120
|
+
this.arrowInfo.angle = angle;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: "dynArrowSize",
|
|
125
|
+
value: // 计算箭头尺寸
|
|
126
|
+
function dynArrowSize() {
|
|
127
|
+
var x = this.stopPoint.x - this.beginPoint.x;
|
|
128
|
+
var y = this.stopPoint.y - this.beginPoint.y;
|
|
129
|
+
// 计算两点之间的直线距离
|
|
130
|
+
var length = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
|
|
131
|
+
// 根据箭头始点和终点之间的距离自适应地调整箭头大小。
|
|
132
|
+
if (length < 50) {
|
|
133
|
+
this.arrowInfo.edgeLen = length / 2;
|
|
134
|
+
} else if (length < 250) {
|
|
135
|
+
this.arrowInfo.edgeLen /= 2;
|
|
136
|
+
} else if (length < 500) {
|
|
137
|
+
this.arrowInfo.edgeLen = this.arrowInfo.edgeLen * length / 500;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
key: "drawArrow",
|
|
143
|
+
value: // 在画布上画出递增变粗的箭头
|
|
144
|
+
function drawArrow(ctx, color) {
|
|
145
|
+
ctx.fillStyle = color;
|
|
146
|
+
ctx.beginPath();
|
|
147
|
+
ctx.moveTo(this.polygonVertex[0], this.polygonVertex[1]);
|
|
148
|
+
ctx.lineTo(this.polygonVertex[2], this.polygonVertex[3]);
|
|
149
|
+
ctx.lineTo(this.polygonVertex[4], this.polygonVertex[5]);
|
|
150
|
+
ctx.lineTo(this.polygonVertex[6], this.polygonVertex[7]);
|
|
151
|
+
ctx.lineTo(this.polygonVertex[8], this.polygonVertex[9]);
|
|
152
|
+
ctx.lineTo(this.polygonVertex[10], this.polygonVertex[11]);
|
|
153
|
+
ctx.closePath();
|
|
154
|
+
ctx.fill();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
]);
|
|
158
|
+
return DrawArrow;
|
|
159
|
+
}();
|
|
@@ -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
|
+
var startX = mouseX < mouseStartX ? mouseX : mouseStartX;
|
|
13
|
+
var startY = mouseY < mouseStartY ? mouseY : mouseStartY;
|
|
14
|
+
var endX = mouseX >= mouseStartX ? mouseX : mouseStartX;
|
|
15
|
+
var endY = mouseY >= mouseStartY ? mouseY : mouseStartY;
|
|
16
|
+
// 计算圆的半径
|
|
17
|
+
var radiusX = (endX - startX) * 0.5;
|
|
18
|
+
var radiusY = (endY - startY) * 0.5;
|
|
19
|
+
// 计算圆心的x、y坐标
|
|
20
|
+
var centerX = startX + radiusX;
|
|
21
|
+
var 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
|
+
}
|