next-element-vue 0.3.6 → 0.3.7
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.css +1 -1
- package/dist/index.js +217 -54
- package/dist/index.min.js +3 -3
- package/dist/index.umd.js +216 -54
- package/dist/index.umd.min.js +3 -3
- package/dist/packages/components/labelimg/src/config.d.ts +11 -0
- package/dist/packages/components/labelimg/src/hooks/canvas-context-hook.d.ts +4 -40
- package/dist/packages/components/labelimg/src/hooks/canvas-drag-zoom.d.ts +57 -0
- package/dist/packages/components/labelimg/src/widgets/draggable-rect.d.ts +2 -2
- package/dist/packages/components/labelme/src/hooks/canvas-drag-zoom.d.ts +31 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 作 者:huangteng
|
|
4
4
|
* 邮 箱:htengweb@163.com
|
|
5
|
-
* 当前版本:0.3.
|
|
6
|
-
* 发布日期:2024-09-
|
|
5
|
+
* 当前版本:0.3.7 v
|
|
6
|
+
* 发布日期:2024-09-21
|
|
7
7
|
* 地 址:https://www.npmjs.com/package/next-element-vue
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -5781,7 +5781,7 @@
|
|
|
5781
5781
|
},
|
|
5782
5782
|
emits: [ "fullscreen", "save" ],
|
|
5783
5783
|
setup(props, {emit: emit}) {
|
|
5784
|
-
const _ns = vue.inject("ns", {}), {t: t} = useLocale(), switchFillscreen = val => {
|
|
5784
|
+
const _ns = vue.inject("ns", {}), scaleTranslateManager = vue.inject("scaleTranslateManager", {}), scaleTranslate = scaleTranslateManager.scaleTranslate, {t: t} = useLocale(), switchFillscreen = val => {
|
|
5785
5785
|
emit("fullscreen", val), document.body.style.overflow = val ? "hidden" : "auto";
|
|
5786
5786
|
};
|
|
5787
5787
|
return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(vue.Fragment, null, [ vue.createVNode("ul", {
|
|
@@ -5808,7 +5808,28 @@
|
|
|
5808
5808
|
style: "padding-left: 3px"
|
|
5809
5809
|
}, [ t("next.labelimg.saveLabel") ]) ]) ]), vue.createVNode("ul", {
|
|
5810
5810
|
class: [ _ns.be("header", "tool") ]
|
|
5811
|
-
}, [
|
|
5811
|
+
}, [ vue.createVNode("li", {
|
|
5812
|
+
class: "hover",
|
|
5813
|
+
onClick: () => scaleTranslateManager.onResetScaleTranslate()
|
|
5814
|
+
}, [ vue.createVNode("svg", {
|
|
5815
|
+
t: "1725840994827",
|
|
5816
|
+
class: "icon",
|
|
5817
|
+
viewBox: "0 0 1024 1024",
|
|
5818
|
+
version: "1.1",
|
|
5819
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5820
|
+
"p-id": "6051",
|
|
5821
|
+
width: "18",
|
|
5822
|
+
height: "18"
|
|
5823
|
+
}, [ vue.createVNode("path", {
|
|
5824
|
+
d: "M322.794667 445.205333a34.133333 34.133333 0 0 1 2.218666 45.824l-2.218666 2.432a34.133333 34.133333 0 0 1-45.824 2.218667l-2.432-2.218667-149.333334-149.333333a34.133333 34.133333 0 0 1-2.218666-45.824l2.218666-2.432 149.333334-149.333333a34.133333 34.133333 0 0 1 50.474666 45.824l-2.218666 2.432-91.050667 91.050666L640 285.866667c160.234667 0 290.133333 129.898667 290.133333 290.133333 0 158.016-126.314667 286.506667-283.477333 290.048L640 866.133333H234.666667a34.133333 34.133333 0 0 1-3.114667-68.117333L234.666667 797.866667h405.333333c122.538667 0 221.866667-99.328 221.866667-221.866667 0-120.533333-96.106667-218.602667-215.850667-221.781333L640 354.133333l-408.256-0.021333 91.050667 91.093333z",
|
|
5825
|
+
"p-id": "6052"
|
|
5826
|
+
}, null) ]), vue.createVNode("span", {
|
|
5827
|
+
style: "padding-left: 3px"
|
|
5828
|
+
}, [ t("next.labelimg.zoomRestore") ]) ]), vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("缩放比例") ]), vue.createVNode("span", null, [ parseInt((100 * scaleTranslate.value.scale).toString()), vue.createTextVNode("%") ]), vue.createVNode("span", {
|
|
5829
|
+
style: "padding: 0 10px;"
|
|
5830
|
+
}, [ vue.createTextVNode("偏移量") ]), vue.createVNode("span", {
|
|
5831
|
+
style: "min-width: 120px; text-align: left;"
|
|
5832
|
+
}, [ vue.createTextVNode("X: "), scaleTranslate.value.x, vue.createTextVNode(", Y: "), scaleTranslate.value.y ]) ]), props.imageLength ? vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("第 "), props.imageIndex + 1, vue.createTextVNode(" 张") ]), vue.createVNode("em", {
|
|
5812
5833
|
style: "padding: 0 5px;"
|
|
5813
5834
|
}, [ vue.createTextVNode("/") ]), vue.createVNode("span", null, [ vue.createTextVNode("共 "), props.imageLength, vue.createTextVNode(" 张") ]) ]) : null, vue.createVNode("li", {
|
|
5814
5835
|
style: "margin-right: 30px;",
|
|
@@ -5829,7 +5850,7 @@
|
|
|
5829
5850
|
}) ]),
|
|
5830
5851
|
default: () => vue.createVNode("ul", {
|
|
5831
5852
|
style: "font-size: 12px;white-space: nowrap;"
|
|
5832
|
-
}, [ vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("W:") ]), vue.createVNode("span", null, [ vue.createTextVNode("鼠标移入图片中,长按W键,鼠标按下左键,移动鼠标开始绘制,鼠标抬起结束绘制") ]) ]), vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("A:") ]), vue.createVNode("span", null, [ vue.createTextVNode("A键进入上一张图片进行标注") ]) ]), vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("D:") ]), vue.createVNode("span", null, [ vue.createTextVNode("D键进入下一张图片进行标注") ]) ]) ])
|
|
5853
|
+
}, [ vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("W:") ]), vue.createVNode("span", null, [ vue.createTextVNode("鼠标移入图片中,长按W键,鼠标按下左键,移动鼠标开始绘制,鼠标抬起结束绘制") ]) ]), vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("A:") ]), vue.createVNode("span", null, [ vue.createTextVNode("A键进入上一张图片进行标注") ]) ]), vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("D:") ]), vue.createVNode("span", null, [ vue.createTextVNode("D键进入下一张图片进行标注") ]) ]), vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("Ctrl+鼠标滚轮:") ]), vue.createVNode("span", null, [ vue.createTextVNode("长按Ctrl+鼠标滚轮对图片进行缩放") ]) ]), vue.createVNode("li", null, [ vue.createVNode("span", null, [ vue.createTextVNode("Ctrl+鼠标左键:") ]), vue.createVNode("span", null, [ vue.createTextVNode("长按Ctrl+鼠标左键对图片进行拖拽移动") ]) ]) ])
|
|
5833
5854
|
}) ]), props.isFullscreen ? vue.createVNode("li", {
|
|
5834
5855
|
class: "hover",
|
|
5835
5856
|
onClick: () => switchFillscreen(!1)
|
|
@@ -5974,6 +5995,100 @@
|
|
|
5974
5995
|
return () => vue.createVNode(vue.Fragment, null, [ renderContent() ]);
|
|
5975
5996
|
}
|
|
5976
5997
|
});
|
|
5998
|
+
class CanvasSceneDragZoom {
|
|
5999
|
+
canvas;
|
|
6000
|
+
canvasWidth;
|
|
6001
|
+
canvasHeight;
|
|
6002
|
+
ctx;
|
|
6003
|
+
scaleFactor=1;
|
|
6004
|
+
preScaleFactor=1;
|
|
6005
|
+
offset={
|
|
6006
|
+
x: 0,
|
|
6007
|
+
y: 0
|
|
6008
|
+
};
|
|
6009
|
+
preOffset={
|
|
6010
|
+
x: 0,
|
|
6011
|
+
y: 0
|
|
6012
|
+
};
|
|
6013
|
+
mousePositioin={
|
|
6014
|
+
x: 0,
|
|
6015
|
+
y: 0
|
|
6016
|
+
};
|
|
6017
|
+
maxScale=8;
|
|
6018
|
+
minScale=.5;
|
|
6019
|
+
scaleStep=.1;
|
|
6020
|
+
clickX=0;
|
|
6021
|
+
clickY=0;
|
|
6022
|
+
observers=[];
|
|
6023
|
+
constructor(canvas) {
|
|
6024
|
+
this.canvas = canvas, this.canvasWidth = canvas.width, this.canvasHeight = canvas.height,
|
|
6025
|
+
this.ctx = canvas.getContext("2d"), this.canvasMousedown = this.canvasMousedown.bind(this),
|
|
6026
|
+
this.canvasMousemove = this.canvasMousemove.bind(this), this.canvasMouseup = this.canvasMouseup.bind(this),
|
|
6027
|
+
this.canvas.addEventListener("mousedown", this.canvasMousedown), this.canvas.addEventListener("wheel", this.canvasMousewheel, {
|
|
6028
|
+
passive: !1
|
|
6029
|
+
}), window.addEventListener("wheel", this.onWindowWheel, {
|
|
6030
|
+
passive: !1
|
|
6031
|
+
});
|
|
6032
|
+
}
|
|
6033
|
+
notifyObservers(scale, offset) {
|
|
6034
|
+
this.observers.forEach((listener => {
|
|
6035
|
+
listener({
|
|
6036
|
+
scale: scale,
|
|
6037
|
+
...offset
|
|
6038
|
+
});
|
|
6039
|
+
}));
|
|
6040
|
+
}
|
|
6041
|
+
changeZoom(callback) {
|
|
6042
|
+
this.observers.push(callback);
|
|
6043
|
+
}
|
|
6044
|
+
reset() {
|
|
6045
|
+
this.scaleFactor = 1, this.preScaleFactor = 1, this.offset = {
|
|
6046
|
+
x: 0,
|
|
6047
|
+
y: 0
|
|
6048
|
+
}, this.preOffset = {
|
|
6049
|
+
x: 0,
|
|
6050
|
+
y: 0
|
|
6051
|
+
}, this.mousePositioin = {
|
|
6052
|
+
x: 0,
|
|
6053
|
+
y: 0
|
|
6054
|
+
}, this.zoom();
|
|
6055
|
+
}
|
|
6056
|
+
render() {
|
|
6057
|
+
this.canvas.width = this.canvasWidth, this.notifyObservers(this.scaleFactor, this.offset);
|
|
6058
|
+
}
|
|
6059
|
+
zoom() {
|
|
6060
|
+
const offset_x = this.mousePositioin.x - (this.mousePositioin.x - this.offset.x) * this.scaleFactor / this.preScaleFactor, offset_y = this.mousePositioin.y - (this.mousePositioin.y - this.offset.y) * this.scaleFactor / this.preScaleFactor;
|
|
6061
|
+
this.offset.x = Math.ceil(offset_x), this.offset.y = Math.ceil(offset_y), this.render(),
|
|
6062
|
+
this.preScaleFactor = this.scaleFactor, this.preOffset.x = this.offset.x, this.preOffset.y = this.offset.y;
|
|
6063
|
+
}
|
|
6064
|
+
onWindowWheel=e => {
|
|
6065
|
+
e.ctrlKey && e.preventDefault();
|
|
6066
|
+
};
|
|
6067
|
+
canvasMousewheel=event => {
|
|
6068
|
+
event.preventDefault(), event.ctrlKey && (this.mousePositioin.x = event.offsetX,
|
|
6069
|
+
this.mousePositioin.y = event.offsetY, event.deltaY > 0 ? (this.scaleFactor = parseFloat((this.scaleFactor + this.scaleStep).toFixed(1)),
|
|
6070
|
+
this.scaleFactor > this.maxScale && (this.scaleFactor = this.maxScale)) : (this.scaleFactor = parseFloat((this.scaleFactor - this.scaleStep).toFixed(1)),
|
|
6071
|
+
this.scaleFactor < this.minScale && (this.scaleFactor = this.minScale)), this.zoom());
|
|
6072
|
+
};
|
|
6073
|
+
canvasMousedown(event) {
|
|
6074
|
+
event.preventDefault(), 0 === event.button && event.ctrlKey && (this.clickX = event.offsetX,
|
|
6075
|
+
this.clickY = event.offsetY, this.canvas.addEventListener("mousemove", this.canvasMousemove),
|
|
6076
|
+
this.canvas.addEventListener("mouseup", this.canvasMouseup));
|
|
6077
|
+
}
|
|
6078
|
+
canvasMousemove(event) {
|
|
6079
|
+
event.preventDefault(), event.ctrlKey && (this.offset.x = Math.ceil(this.preOffset.x + (event.offsetX - this.clickX)),
|
|
6080
|
+
this.offset.y = Math.ceil(this.preOffset.y + (event.offsetY - this.clickY)), this.render());
|
|
6081
|
+
}
|
|
6082
|
+
canvasMouseup(event) {
|
|
6083
|
+
event.preventDefault(), event.ctrlKey && (this.preOffset.x = this.offset.x, this.preOffset.y = this.offset.y,
|
|
6084
|
+
this.canvas.removeEventListener("mousemove", this.canvasMousemove), this.canvas.removeEventListener("mouseup", this.canvasMouseup));
|
|
6085
|
+
}
|
|
6086
|
+
destroy() {
|
|
6087
|
+
this.canvas.removeEventListener("mousedown", this.canvasMousedown), this.canvas.removeEventListener("mousemove", this.canvasMousemove),
|
|
6088
|
+
this.canvas.removeEventListener("mouseup", this.canvasMouseup), this.canvas.removeEventListener("wheel", this.canvasMousewheel),
|
|
6089
|
+
window.removeEventListener("wheel", this.onWindowWheel);
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
5977
6092
|
const {hexToRgb: hexToRgb} = useChangeColor();
|
|
5978
6093
|
var DraggableRect = vue.defineComponent({
|
|
5979
6094
|
props: {
|
|
@@ -5992,7 +6107,7 @@
|
|
|
5992
6107
|
},
|
|
5993
6108
|
emits: [ "draggle-resize", "contextmenu" ],
|
|
5994
6109
|
setup(props, {emit: emit}) {
|
|
5995
|
-
const isDraggle = vue.ref(!1), isResizeCorner = vue.ref({
|
|
6110
|
+
const scaleTranslate = vue.inject("scaleTranslateManager", {}).scaleTranslate, isDraggle = vue.ref(!1), isResizeCorner = vue.ref({
|
|
5996
6111
|
topLeft: !1,
|
|
5997
6112
|
topCenter: !1,
|
|
5998
6113
|
topRight: !1,
|
|
@@ -6012,66 +6127,68 @@
|
|
|
6012
6127
|
isResizeCorner.value.rightCenter = !1, isResizeCorner.value.bottomLeft = !1, isResizeCorner.value.bottomCenter = !1,
|
|
6013
6128
|
isResizeCorner.value.bottomRight = !1, emit("draggle-resize", rect.value);
|
|
6014
6129
|
}, onMousemove = e => {
|
|
6130
|
+
const {scale: scale, x: x, y: y} = scaleTranslate.value, min_size = 30 / scale, startX = Math.ceil(rect.value.startX * scale + x), startY = Math.ceil(rect.value.startY * scale + y);
|
|
6015
6131
|
if (isDraggle.value) {
|
|
6016
|
-
const newLeft = e.clientX - parentRect.left - draggleOffset.value.diff_x, newTop = e.clientY - parentRect.top - draggleOffset.value.diff_y;
|
|
6017
|
-
rect.value.startX = Math.max(0, Math.min(
|
|
6018
|
-
rect.value.startY = Math.max(0, Math.min(
|
|
6132
|
+
const newLeft = e.clientX - parentRect.left - draggleOffset.value.diff_x, newTop = e.clientY - parentRect.top - draggleOffset.value.diff_y, offsetX = Math.ceil((newLeft - x) / scale), offsetY = Math.ceil((newTop - y) / scale);
|
|
6133
|
+
rect.value.startX = Math.max(0, Math.min(offsetX, parentRect.width - rect.value.rectWidth)),
|
|
6134
|
+
rect.value.startY = Math.max(0, Math.min(offsetY, parentRect.height - rect.value.rectHeight));
|
|
6019
6135
|
}
|
|
6020
6136
|
if (isResizeCorner.value.bottomCenter) {
|
|
6021
|
-
let newHeight = e.clientY - parentRect.top -
|
|
6022
|
-
newHeight <
|
|
6137
|
+
let newHeight = Math.floor((e.clientY - parentRect.top - startY) / scale);
|
|
6138
|
+
newHeight < min_size && (newHeight = min_size), newHeight + rect.value.startY > parentRect.height && (newHeight = parentRect.height - rect.value.startY),
|
|
6023
6139
|
rect.value.rectHeight = newHeight;
|
|
6024
6140
|
}
|
|
6025
6141
|
if (isResizeCorner.value.topCenter) {
|
|
6026
|
-
let newTop = e.clientY - parentRect.top, newHeight = rect.value.startY - newTop + rect.value.rectHeight;
|
|
6142
|
+
let newTop = Math.floor((e.clientY - parentRect.top - y) / scale), newHeight = rect.value.startY - newTop + rect.value.rectHeight;
|
|
6027
6143
|
if (newTop < 0) return;
|
|
6028
|
-
if (newHeight <
|
|
6144
|
+
if (newHeight < min_size) return;
|
|
6029
6145
|
rect.value.rectHeight = newHeight, rect.value.startY = Math.max(0, Math.min(newTop, parentRect.height - rect.value.rectHeight));
|
|
6030
6146
|
}
|
|
6031
6147
|
if (isResizeCorner.value.leftCenter) {
|
|
6032
|
-
let newLeft = e.clientX - parentRect.left, newWidth = rect.value.startX - newLeft + rect.value.rectWidth;
|
|
6148
|
+
let newLeft = Math.floor((e.clientX - parentRect.left - x) / scale), newWidth = rect.value.startX - newLeft + rect.value.rectWidth;
|
|
6033
6149
|
if (newLeft < 0) return;
|
|
6034
|
-
if (newWidth <
|
|
6150
|
+
if (newWidth < min_size) return;
|
|
6035
6151
|
rect.value.startX = Math.max(0, Math.min(newLeft, parentRect.width - rect.value.rectWidth)),
|
|
6036
6152
|
rect.value.rectWidth = newWidth;
|
|
6037
6153
|
}
|
|
6038
6154
|
if (isResizeCorner.value.rightCenter) {
|
|
6039
|
-
let newWidth = e.clientX - parentRect.left -
|
|
6040
|
-
newWidth <
|
|
6155
|
+
let newWidth = Math.floor((e.clientX - parentRect.left - startX) / scale);
|
|
6156
|
+
newWidth < min_size && (newWidth = min_size), newWidth + rect.value.startX > parentRect.width && (newWidth = parentRect.width - rect.value.startX),
|
|
6041
6157
|
rect.value.rectWidth = newWidth;
|
|
6042
6158
|
}
|
|
6043
6159
|
if (isResizeCorner.value.bottomRight) {
|
|
6044
|
-
let newWidth = e.clientX - parentRect.left -
|
|
6045
|
-
newWidth <
|
|
6160
|
+
let newWidth = Math.floor((e.clientX - parentRect.left - startX) / scale), newHeight = Math.floor((e.clientY - parentRect.top - startY) / scale);
|
|
6161
|
+
newWidth < min_size && (newWidth = min_size), newHeight < min_size && (newHeight = min_size),
|
|
6162
|
+
newWidth + rect.value.startX > parentRect.width && (newWidth = parentRect.width - rect.value.startX),
|
|
6046
6163
|
newHeight + rect.value.startY > parentRect.height && (newHeight = parentRect.height - rect.value.startY),
|
|
6047
6164
|
rect.value.rectWidth = newWidth, rect.value.rectHeight = newHeight;
|
|
6048
6165
|
}
|
|
6049
6166
|
if (isResizeCorner.value.bottomLeft) {
|
|
6050
|
-
let newLeft = e.clientX - parentRect.left, newWidth = rect.value.startX - newLeft + rect.value.rectWidth, newHeight = e.clientY - parentRect.top -
|
|
6167
|
+
let newLeft = Math.floor((e.clientX - parentRect.left - x) / scale), newWidth = rect.value.startX - newLeft + rect.value.rectWidth, newHeight = Math.floor((e.clientY - parentRect.top - startY) / scale);
|
|
6051
6168
|
if (newLeft < 0) return;
|
|
6052
|
-
if (newWidth <
|
|
6053
|
-
newHeight <
|
|
6169
|
+
if (newWidth < min_size) return;
|
|
6170
|
+
newHeight < min_size && (newHeight = min_size), newHeight + rect.value.startY > parentRect.height && (newHeight = parentRect.height - rect.value.startY),
|
|
6054
6171
|
rect.value.startX = Math.max(0, Math.min(newLeft, parentRect.width - rect.value.rectWidth)),
|
|
6055
6172
|
rect.value.rectWidth = newWidth, rect.value.rectHeight = newHeight;
|
|
6056
6173
|
}
|
|
6057
6174
|
if (isResizeCorner.value.topLeft) {
|
|
6058
|
-
let newTop = e.clientY - parentRect.top, newHeight = rect.value.startY - newTop + rect.value.rectHeight;
|
|
6175
|
+
let newTop = Math.floor((e.clientY - parentRect.top - y) / scale), newHeight = rect.value.startY - newTop + rect.value.rectHeight;
|
|
6059
6176
|
if (newTop < 0) return;
|
|
6060
|
-
if (newHeight <
|
|
6177
|
+
if (newHeight < min_size) return;
|
|
6061
6178
|
rect.value.rectHeight = newHeight, rect.value.startY = Math.max(0, Math.min(newTop, parentRect.height - rect.value.rectHeight));
|
|
6062
|
-
let newLeft = e.clientX - parentRect.left, newWidth = rect.value.startX - newLeft + rect.value.rectWidth;
|
|
6179
|
+
let newLeft = Math.floor((e.clientX - parentRect.left - x) / scale), newWidth = rect.value.startX - newLeft + rect.value.rectWidth;
|
|
6063
6180
|
if (newLeft < 0) return;
|
|
6064
|
-
if (newWidth <
|
|
6181
|
+
if (newWidth < min_size) return;
|
|
6065
6182
|
rect.value.startX = Math.max(0, Math.min(newLeft, parentRect.width - rect.value.rectWidth)),
|
|
6066
6183
|
rect.value.rectWidth = newWidth;
|
|
6067
6184
|
}
|
|
6068
6185
|
if (isResizeCorner.value.topRight) {
|
|
6069
|
-
let newTop = e.clientY - parentRect.top, newHeight = rect.value.startY - newTop + rect.value.rectHeight;
|
|
6186
|
+
let newTop = Math.floor((e.clientY - parentRect.top - y) / scale), newHeight = rect.value.startY - newTop + rect.value.rectHeight;
|
|
6070
6187
|
if (newTop < 0) return;
|
|
6071
|
-
if (newHeight <
|
|
6188
|
+
if (newHeight < min_size) return;
|
|
6072
6189
|
rect.value.rectHeight = newHeight, rect.value.startY = Math.max(0, Math.min(newTop, parentRect.height - rect.value.rectHeight));
|
|
6073
|
-
let newWidth = e.clientX - parentRect.left -
|
|
6074
|
-
newWidth <
|
|
6190
|
+
let newWidth = Math.floor((e.clientX - parentRect.left - startX) / scale);
|
|
6191
|
+
newWidth < min_size && (newWidth = min_size), newWidth + rect.value.startX > parentRect.width && (newWidth = parentRect.width - rect.value.startX),
|
|
6075
6192
|
rect.value.rectWidth = newWidth;
|
|
6076
6193
|
}
|
|
6077
6194
|
};
|
|
@@ -6096,11 +6213,23 @@
|
|
|
6096
6213
|
};
|
|
6097
6214
|
},
|
|
6098
6215
|
render() {
|
|
6099
|
-
const _ns = vue.inject("ns", {}), props = this.$props;
|
|
6216
|
+
const _ns = vue.inject("ns", {}), scaleTranslate = vue.inject("scaleTranslateManager", {}).scaleTranslate, props = this.$props;
|
|
6100
6217
|
return vue.createVNode("div", {
|
|
6101
6218
|
class: [ _ns.b("draggable-rect") ],
|
|
6102
6219
|
style: (() => {
|
|
6103
|
-
const {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight} =
|
|
6220
|
+
const {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight} = ((rect, scaleOffset) => {
|
|
6221
|
+
const {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight} = rect, {scale: scale, x: x, y: y} = scaleOffset;
|
|
6222
|
+
return {
|
|
6223
|
+
startX: Math.ceil(startX * scale + x),
|
|
6224
|
+
startY: Math.ceil(startY * scale + y),
|
|
6225
|
+
rectWidth: Math.ceil(rectWidth * scale),
|
|
6226
|
+
rectHeight: Math.ceil(rectHeight * scale),
|
|
6227
|
+
canvasWidth: rect.canvasWidth,
|
|
6228
|
+
canvasHeight: rect.canvasHeight,
|
|
6229
|
+
originWidth: rect.originWidth,
|
|
6230
|
+
originHeight: rect.originHeight
|
|
6231
|
+
};
|
|
6232
|
+
})(this.rect, scaleTranslate.value), style = {
|
|
6104
6233
|
top: startY + "px",
|
|
6105
6234
|
left: startX + "px",
|
|
6106
6235
|
width: rectWidth + "px",
|
|
@@ -6161,7 +6290,7 @@
|
|
|
6161
6290
|
},
|
|
6162
6291
|
emits: [ "change" ],
|
|
6163
6292
|
setup(props, {emit: emit, expose: expose}) {
|
|
6164
|
-
const ns = vue.inject("ns", {}), _emit = vue.inject("_emit", null), mainBasaeRef = vue.ref(), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), canvasRectRef = vue.ref(), labels = vue.ref([]), drawBaseCanvas = vue.ref({}), formatLabelsType = () => {
|
|
6293
|
+
const ns = vue.inject("ns", {}), _emit = vue.inject("_emit", null), scaleTranslateManager = vue.inject("scaleTranslateManager", {}), mainBasaeRef = vue.ref(), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), canvasRectRef = vue.ref(), labels = vue.ref([]), drawBaseCanvas = vue.ref({}), canvasDragZoom = vue.ref(), formatLabelsType = () => {
|
|
6165
6294
|
const _labels = deepClone(labels.value);
|
|
6166
6295
|
let yolo_label = [];
|
|
6167
6296
|
return {
|
|
@@ -6223,9 +6352,9 @@
|
|
|
6223
6352
|
return scale_rects;
|
|
6224
6353
|
})(labels.value, canvasHeight);
|
|
6225
6354
|
const {updateLabels: updateLabels, addDrawRect: addDrawRect, hitCanvasLabel: hitCanvasLabel} = (options => {
|
|
6226
|
-
const {canvas: canvas, ctx: ctx, labels: labels, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight} = options, updateLabels =
|
|
6227
|
-
|
|
6228
|
-
ctx.scale(scaleOffset.scale, scaleOffset.scale)), ctx.clearRect(0, 0, canvasWidth, canvasHeight),
|
|
6355
|
+
const {canvas: canvas, ctx: ctx, labels: labels, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight, scaleOffset: scaleOffset} = options, updateLabels = () => {
|
|
6356
|
+
canvas.width = canvasWidth, scaleOffset.value && (ctx.save(), ctx.translate(scaleOffset.value.x, scaleOffset.value.y),
|
|
6357
|
+
ctx.scale(scaleOffset.value.scale, scaleOffset.value.scale)), ctx.clearRect(0, 0, canvasWidth, canvasHeight),
|
|
6229
6358
|
ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
|
|
6230
6359
|
for (let i = 0; i < labels.length; i++) {
|
|
6231
6360
|
const rect = labels[i], {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight, type: type} = rect, color = colors$1[type % colors$1.length];
|
|
@@ -6265,7 +6394,8 @@
|
|
|
6265
6394
|
canvasWidth: canvasWidth,
|
|
6266
6395
|
canvasHeight: canvasHeight,
|
|
6267
6396
|
labels: labels.value,
|
|
6268
|
-
scaleFactor: scaleFactor
|
|
6397
|
+
scaleFactor: scaleFactor,
|
|
6398
|
+
scaleOffset: scaleTranslateManager.scaleTranslate
|
|
6269
6399
|
});
|
|
6270
6400
|
drawBaseCanvas.value.updateLabels = updateLabels, drawBaseCanvas.value.addDrawRect = addDrawRect,
|
|
6271
6401
|
drawBaseCanvas.value.hitCanvasLabel = hitCanvasLabel;
|
|
@@ -6332,30 +6462,45 @@
|
|
|
6332
6462
|
originWidth: originWidth,
|
|
6333
6463
|
originHeight: originHeight
|
|
6334
6464
|
}, ((rect, {endX: endX, endY: endY}) => {
|
|
6335
|
-
activate_add_label.value = rect
|
|
6465
|
+
activate_add_label.value = rect;
|
|
6466
|
+
const newRect = ((rect, scaleOffset) => {
|
|
6467
|
+
const {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight} = rect, {scale: scale, x: x, y: y} = scaleOffset;
|
|
6468
|
+
return {
|
|
6469
|
+
startX: Math.ceil((startX - x) / scale),
|
|
6470
|
+
startY: Math.ceil((startY - y) / scale),
|
|
6471
|
+
rectWidth: Math.ceil(rectWidth / scale),
|
|
6472
|
+
rectHeight: Math.ceil(rectHeight / scale),
|
|
6473
|
+
canvasWidth: rect.canvasWidth,
|
|
6474
|
+
canvasHeight: rect.canvasHeight,
|
|
6475
|
+
originWidth: rect.originWidth,
|
|
6476
|
+
originHeight: rect.originHeight
|
|
6477
|
+
};
|
|
6478
|
+
})(rect, scaleTranslateManager.scaleTranslate.value);
|
|
6479
|
+
drawBaseCanvas.value.addDrawRect(newRect), updateContextmenuLabelFixed(endX, endY, newRect);
|
|
6336
6480
|
}), (() => {
|
|
6337
6481
|
onCloseDraggableRectFixed();
|
|
6338
6482
|
}));
|
|
6339
|
-
drawBaseCanvas.value.clearCanvasRect = clearCanvas, drawBaseCanvas.value.removeEventAll = removeEventAll
|
|
6483
|
+
drawBaseCanvas.value.clearCanvasRect = clearCanvas, drawBaseCanvas.value.removeEventAll = removeEventAll,
|
|
6484
|
+
canvasDragZoom.value = new CanvasSceneDragZoom(canvasBaseRef.value), canvasDragZoom.value.changeZoom((scaleOffset => {
|
|
6485
|
+
scaleTranslateManager.onChangeScaleTranslate(scaleOffset), drawBaseCanvas.value.updateLabels();
|
|
6486
|
+
}));
|
|
6340
6487
|
}, image.onerror = () => {
|
|
6341
6488
|
loadingImage.value = !1;
|
|
6342
6489
|
};
|
|
6343
6490
|
}
|
|
6344
6491
|
canvasBaseRef.value.addEventListener("contextmenu", (e => {
|
|
6345
6492
|
e.preventDefault();
|
|
6346
|
-
const
|
|
6493
|
+
const offsetX = e.offsetX, offsetY = e.offsetY, {scale: scale, x: x, y: y} = scaleTranslateManager.scaleTranslate.value, new_x = Math.floor((offsetX - x) / scale), new_y = Math.floor((offsetY - y) / scale), {hit_rect: hit_rect} = drawBaseCanvas.value.hitCanvasLabel(new_x, new_y);
|
|
6347
6494
|
onCloseContentmenuLabel(), onCloseDraggableRectFixed(), hit_rect && vue.nextTick((() => {
|
|
6348
|
-
updateContextmenuLabelFixed(
|
|
6495
|
+
updateContextmenuLabelFixed(offsetX, offsetY, hit_rect);
|
|
6349
6496
|
}));
|
|
6350
6497
|
})), canvasBaseRef.value.addEventListener("click", (e => {
|
|
6351
6498
|
if (e.ctrlKey) return;
|
|
6352
|
-
const
|
|
6499
|
+
const offsetX = e.offsetX, offsetY = e.offsetY, {scale: scale, x: x, y: y} = scaleTranslateManager.scaleTranslate.value, new_x = Math.floor((offsetX - x) / scale), new_y = Math.floor((offsetY - y) / scale), {hit_rect: hit_rect, hit_index: hit_index, color: color} = drawBaseCanvas.value.hitCanvasLabel(new_x, new_y);
|
|
6353
6500
|
onCloseDraggableRectFixed(), onCloseContentmenuLabel(), hit_rect && vue.nextTick((() => {
|
|
6354
|
-
updateDraggableRectFixed(
|
|
6501
|
+
updateDraggableRectFixed(offsetX, offsetY, hit_rect, hit_index, color);
|
|
6355
6502
|
}));
|
|
6356
6503
|
}));
|
|
6357
|
-
}, onWindowWheel = e => {
|
|
6358
|
-
e.ctrlKey && e.preventDefault();
|
|
6359
6504
|
};
|
|
6360
6505
|
vue.onMounted((() => {
|
|
6361
6506
|
vue.watch((() => props.rowInfo), (info => {
|
|
@@ -6373,11 +6518,9 @@
|
|
|
6373
6518
|
const rowInfo = vue.toRaw(props.rowInfo);
|
|
6374
6519
|
renderImageLabel(rowInfo);
|
|
6375
6520
|
}
|
|
6376
|
-
}))
|
|
6377
|
-
passive: !1
|
|
6378
|
-
});
|
|
6521
|
+
}));
|
|
6379
6522
|
})), vue.onUnmounted((() => {
|
|
6380
|
-
drawBaseCanvas.value.removeEventAll?.(),
|
|
6523
|
+
drawBaseCanvas.value.removeEventAll?.(), canvasDragZoom.value.destroy();
|
|
6381
6524
|
}));
|
|
6382
6525
|
const contextmenuLabelFixed = vue.ref({
|
|
6383
6526
|
show: !1,
|
|
@@ -6464,6 +6607,9 @@
|
|
|
6464
6607
|
const rowInfo = vue.toRaw(props.rowInfo);
|
|
6465
6608
|
renderImageLabel(rowInfo);
|
|
6466
6609
|
}));
|
|
6610
|
+
},
|
|
6611
|
+
resetScaleOffset: () => {
|
|
6612
|
+
canvasDragZoom.value.reset();
|
|
6467
6613
|
}
|
|
6468
6614
|
});
|
|
6469
6615
|
return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(NextSpinLoading, {
|
|
@@ -6663,7 +6809,11 @@
|
|
|
6663
6809
|
label_txt: label_txt
|
|
6664
6810
|
}, (imageItem => {
|
|
6665
6811
|
labelImages.value[activateNodeIndex.value] = imageItem || node, activateNodeIndex.value = index,
|
|
6666
|
-
loading.value = !1
|
|
6812
|
+
loading.value = !1, scaleTranslate.value = {
|
|
6813
|
+
scale: 1,
|
|
6814
|
+
x: 0,
|
|
6815
|
+
y: 0
|
|
6816
|
+
};
|
|
6667
6817
|
}), (() => {
|
|
6668
6818
|
loading.value = !1;
|
|
6669
6819
|
})), !0);
|
|
@@ -6696,8 +6846,20 @@
|
|
|
6696
6846
|
isFullscreen.value = val, updateMainContentHeight(), vue.nextTick((() => {
|
|
6697
6847
|
canvasContextRef.value.rerenderImage();
|
|
6698
6848
|
}));
|
|
6699
|
-
}
|
|
6700
|
-
|
|
6849
|
+
}, scaleTranslate = vue.ref({
|
|
6850
|
+
scale: 1,
|
|
6851
|
+
x: 0,
|
|
6852
|
+
y: 0
|
|
6853
|
+
});
|
|
6854
|
+
vue.provide("scaleTranslateManager", {
|
|
6855
|
+
scaleTranslate: scaleTranslate,
|
|
6856
|
+
onChangeScaleTranslate: val => {
|
|
6857
|
+
scaleTranslate.value = val;
|
|
6858
|
+
},
|
|
6859
|
+
onResetScaleTranslate: () => {
|
|
6860
|
+
canvasContextRef.value.resetScaleOffset();
|
|
6861
|
+
}
|
|
6862
|
+
}), expose({
|
|
6701
6863
|
convertToLabel: convertToLabel,
|
|
6702
6864
|
canvertToCanvas: canvertToCanvas
|
|
6703
6865
|
});
|
|
@@ -7647,7 +7809,7 @@
|
|
|
7647
7809
|
})(app);
|
|
7648
7810
|
};
|
|
7649
7811
|
var index = {
|
|
7650
|
-
version: "0.3.
|
|
7812
|
+
version: "0.3.7",
|
|
7651
7813
|
install: install
|
|
7652
7814
|
};
|
|
7653
7815
|
exports.NextContainer = NextContainer, exports.NextCrudTable = NextCrudTable, exports.NextCrudTableVirtualized = NextCrudTableVirtualized,
|
|
@@ -7694,7 +7856,7 @@
|
|
|
7694
7856
|
}), exports.useGetDerivedNamespace = useGetDerivedNamespace, exports.useLanguage = (locale, lang) => {
|
|
7695
7857
|
const localeRef = vue.isRef(locale) ? locale : vue.ref(locale), nextLang = localeLang[lang] || localeLang["zh-cn"];
|
|
7696
7858
|
localeRef.value.name = lang, localeRef.value.next = nextLang.next;
|
|
7697
|
-
}, exports.useLocale = useLocale, exports.useNamespace = useNamespace, exports.version = "0.3.
|
|
7859
|
+
}, exports.useLocale = useLocale, exports.useNamespace = useNamespace, exports.version = "0.3.7",
|
|
7698
7860
|
Object.defineProperty(exports, "__esModule", {
|
|
7699
7861
|
value: !0
|
|
7700
7862
|
});
|