@glodon-aiot/dataset-annotation 3.10.0-alpha.20 → 3.10.0-alpha.22
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/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +12 -12
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +122 -97
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +197 -162
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +75 -34
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +159 -131
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +59 -48
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +158 -154
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +1 -2
- package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +13 -14
- package/dist/es/index.mjs +1 -1
- package/dist/lib/index.js +4 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +2 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function X(e, n) {
|
|
2
2
|
T(e);
|
|
3
3
|
let h = -1, s = -1, p = 0, m = 0, w = !1;
|
|
4
4
|
e.on("mouse:down:before", (d) => {
|
|
5
5
|
const f = d.target, u = e.getActiveObject();
|
|
6
|
-
if (f && f !== e.backgroundImage
|
|
7
|
-
e.skipTargetFind = !1;
|
|
6
|
+
if (f && f !== e.backgroundImage) {
|
|
7
|
+
u !== f && (e.setActiveObject(f), e.requestRenderAll()), e.skipTargetFind = !1;
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
u && (e.discardActiveObject(), e.renderAll()), e.skipTargetFind = !0;
|
|
@@ -20,20 +20,20 @@ function Y(e, n) {
|
|
|
20
20
|
const f = e.getZoom(), u = d.e.offsetX > e.getWidth() ? e.getWidth() / f : d.e.offsetX / f, b = d.e.offsetY > e.getHeight() ? e.getHeight() / f : d.e.offsetY / f;
|
|
21
21
|
if (p = Math.abs(u - s), m = Math.abs(b - h), p === 0 || m === 0)
|
|
22
22
|
return;
|
|
23
|
-
const y = e.viewportTransform ? e.viewportTransform[4] / f : 0,
|
|
23
|
+
const y = e.viewportTransform ? e.viewportTransform[4] / f : 0, A = e.viewportTransform ? e.viewportTransform[5] / f : 0;
|
|
24
24
|
let r = h > b ? b : h, i = s > u ? u : s, l = p, g = m;
|
|
25
|
-
r = r -
|
|
26
|
-
const
|
|
25
|
+
r = r - A, i = i - y;
|
|
26
|
+
const F = () => {
|
|
27
27
|
var o, k;
|
|
28
28
|
const t = e.backgroundImage;
|
|
29
29
|
t && typeof t != "string" && ((o = t.aCoords) != null && o.tl.x, (k = t.aCoords) != null && k.tl.y), t && typeof t != "string" && t.top !== void 0 && t.height !== void 0 && t.left !== void 0 && t.width !== void 0 && (r < t.top && (g = g - (t.top - r), r = t.top), r + g > t.top + t.height && (g = t.top + t.height - r + g - g, r = t.height + t.top - g), i < t.left && (l = l - (t.left - i), i = t.left), i + l > t.left + t.width && (l = t.left + t.width - i + l - l, i = t.width + t.left - l));
|
|
30
|
-
},
|
|
30
|
+
}, I = (t) => {
|
|
31
31
|
const o = e.backgroundImage;
|
|
32
32
|
return !(o && typeof o != "string" && o.top !== void 0 && o.height !== void 0 && o.left !== void 0 && o.width !== void 0 && (t[0] < o.left || t[1] < o.top || t[0] > o.left + o.width || t[1] > o.top + o.height));
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
F();
|
|
35
35
|
const c = [[i, r], [i + l, r], [i + l, r + g], [i, r + g]];
|
|
36
|
-
n && c.every((t) =>
|
|
36
|
+
n && c.every((t) => I(t)) && n({
|
|
37
37
|
id: "",
|
|
38
38
|
color: "#cccccc",
|
|
39
39
|
label: "未知",
|
|
@@ -44,11 +44,11 @@ function Y(e, n) {
|
|
|
44
44
|
const T = (e) => {
|
|
45
45
|
e.off("mouse:down"), e.off("mouse:down:before"), e.off("mouse:up"), e.skipTargetFind = !1;
|
|
46
46
|
};
|
|
47
|
-
function
|
|
47
|
+
function Y(e, n, h) {
|
|
48
48
|
if (!h)
|
|
49
|
-
return
|
|
49
|
+
return X(e, n), e;
|
|
50
50
|
}
|
|
51
51
|
export {
|
|
52
|
-
|
|
52
|
+
Y as drawable,
|
|
53
53
|
T as stopDraw
|
|
54
54
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var s in
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var s of
|
|
10
|
-
|
|
1
|
+
var j = Object.defineProperty, A = Object.defineProperties;
|
|
2
|
+
var B = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var F = Object.getOwnPropertySymbols;
|
|
4
|
+
var T = Object.prototype.hasOwnProperty, I = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var w = (l, i, s) => i in l ? j(l, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : l[i] = s, f = (l, i) => {
|
|
6
|
+
for (var s in i || (i = {}))
|
|
7
|
+
T.call(i, s) && w(l, s, i[s]);
|
|
8
|
+
if (F)
|
|
9
|
+
for (var s of F(i))
|
|
10
|
+
I.call(i, s) && w(l, s, i[s]);
|
|
11
11
|
return l;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
import { fabric as
|
|
15
|
-
import
|
|
16
|
-
import { formatColorToArray as
|
|
17
|
-
const
|
|
12
|
+
}, C = (l, i) => A(l, B(i));
|
|
13
|
+
var d = (l, i, s) => (w(l, typeof i != "symbol" ? i + "" : i, s), s);
|
|
14
|
+
import { fabric as g } from "fabric";
|
|
15
|
+
import O from "./FabricCustomize.mjs";
|
|
16
|
+
import { formatColorToArray as X } from "../../../../utils/color.mjs";
|
|
17
|
+
const z = {
|
|
18
18
|
borderWidth: 2,
|
|
19
19
|
controls: ["TL", "BL", "TR", "BR"],
|
|
20
20
|
cornerStrokeColor: "#84868C",
|
|
@@ -22,16 +22,16 @@ const $ = {
|
|
|
22
22
|
visible: !0,
|
|
23
23
|
active: !1
|
|
24
24
|
};
|
|
25
|
-
class
|
|
26
|
-
constructor(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this._canvas = s, this.handlers =
|
|
25
|
+
class M {
|
|
26
|
+
constructor(i, s, c) {
|
|
27
|
+
d(this, "config");
|
|
28
|
+
d(this, "color");
|
|
29
|
+
d(this, "_active", !1);
|
|
30
|
+
d(this, "_fabricRect", null);
|
|
31
|
+
d(this, "_label", null);
|
|
32
|
+
d(this, "_hover", !1);
|
|
33
|
+
d(this, "_strokeRect");
|
|
34
|
+
this._canvas = s, this.handlers = c, g.Rect.prototype.cornerColor = "blue", this.config = f(f({}, z), i), this.color = X(i.color), this._active = this.config.active || !1, s && this.render(s);
|
|
35
35
|
}
|
|
36
36
|
get object() {
|
|
37
37
|
return this._fabricRect;
|
|
@@ -39,22 +39,22 @@ class F {
|
|
|
39
39
|
get active() {
|
|
40
40
|
return this._active;
|
|
41
41
|
}
|
|
42
|
-
set active(
|
|
42
|
+
set active(i) {
|
|
43
43
|
var s;
|
|
44
|
-
this._active =
|
|
44
|
+
this._active = i, (s = this._fabricRect) != null && s.canvas && (i && !this.config.hideDelete ? (this._fabricRect.set(this.activeStyle), this.canvas.setActiveObject(this._fabricRect)) : (this.canvas.discardActiveObject(), this.hover || this._fabricRect.set(this.normalStyle)), this.canvas.requestRenderAll());
|
|
45
45
|
}
|
|
46
46
|
get hover() {
|
|
47
47
|
return this._hover;
|
|
48
48
|
}
|
|
49
|
-
set hover(
|
|
50
|
-
var s,
|
|
51
|
-
this._hover =
|
|
49
|
+
set hover(i) {
|
|
50
|
+
var s, c;
|
|
51
|
+
this._hover = i, i ? (s = this._fabricRect) == null || s.set(this.hoverStyle) : this.active || (c = this._fabricRect) == null || c.set(this.normalStyle), this.canvas.requestRenderAll();
|
|
52
52
|
}
|
|
53
53
|
get canvas() {
|
|
54
54
|
return this._canvas;
|
|
55
55
|
}
|
|
56
|
-
set canvas(
|
|
57
|
-
this._canvas !==
|
|
56
|
+
set canvas(i) {
|
|
57
|
+
this._canvas !== i && (this._canvas = i, this.render(i));
|
|
58
58
|
}
|
|
59
59
|
get normalStyle() {
|
|
60
60
|
return {
|
|
@@ -68,7 +68,7 @@ class F {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
get activeStyle() {
|
|
71
|
-
return
|
|
71
|
+
return C(f({}, this.normalStyle), {
|
|
72
72
|
content: `<svg height="500" width="500"><text fill="#ffffff" font-size="45" x="50" y="86">${this.config.name}</text></svg>`,
|
|
73
73
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0.1)`
|
|
74
74
|
});
|
|
@@ -77,37 +77,40 @@ class F {
|
|
|
77
77
|
return this.activeStyle;
|
|
78
78
|
}
|
|
79
79
|
createRect() {
|
|
80
|
-
const
|
|
80
|
+
const i = {
|
|
81
81
|
hasBorders: !1,
|
|
82
82
|
cornerSize: 6,
|
|
83
83
|
cornerStrokeColor: "#84868C",
|
|
84
84
|
cornerColor: "#FFFFFF",
|
|
85
85
|
transparentCorners: !1
|
|
86
|
-
}, s = 0,
|
|
86
|
+
}, s = 0, c = new g.Rect(
|
|
87
87
|
// this.config.points?.map((p) => ({ x: p[0], y: p[1] })),
|
|
88
|
-
|
|
88
|
+
C(f(f({
|
|
89
89
|
left: this.config.points[0][0],
|
|
90
90
|
top: this.config.points[0][1],
|
|
91
91
|
width: this.config.points[2][0] - this.config.points[0][0] - s,
|
|
92
92
|
height: this.config.points[2][1] - this.config.points[0][1] - s
|
|
93
|
-
},
|
|
93
|
+
}, i), this.normalStyle), {
|
|
94
|
+
// 禁止缩放时翻转
|
|
95
|
+
lockScalingFlip: !0
|
|
96
|
+
})
|
|
94
97
|
);
|
|
95
|
-
|
|
98
|
+
c.setControlsVisibility({
|
|
96
99
|
mtr: !1
|
|
97
100
|
});
|
|
98
101
|
const a = () => {
|
|
99
|
-
if (
|
|
102
|
+
if (c.canvas !== this.canvas) {
|
|
100
103
|
this.canvas.off("after:render", a);
|
|
101
104
|
return;
|
|
102
105
|
}
|
|
103
106
|
this.canvas.contextContainer.strokeStyle = `rgb(${this.color[0]},${this.color[1]}, ${this.color[2]})`;
|
|
104
|
-
const o =
|
|
107
|
+
const o = c.getBoundingRect();
|
|
105
108
|
this._strokeRect = this.canvas.contextContainer.strokeRect(o.left + 0.5, o.top + 0.5, o.width, o.height);
|
|
106
109
|
};
|
|
107
|
-
return this.canvas.on("after:render", a),
|
|
110
|
+
return this.canvas.on("after:render", a), c;
|
|
108
111
|
}
|
|
109
|
-
scaledNumber(
|
|
110
|
-
return
|
|
112
|
+
scaledNumber(i) {
|
|
113
|
+
return i / this.canvas.getZoom();
|
|
111
114
|
}
|
|
112
115
|
// getPolyVertices(poly: fabric.Rect) {
|
|
113
116
|
// const points = poly.points,
|
|
@@ -130,16 +133,16 @@ class F {
|
|
|
130
133
|
// });
|
|
131
134
|
// }
|
|
132
135
|
createLabelName() {
|
|
133
|
-
const [
|
|
136
|
+
const [i, s, c] = this.color, a = new g.Text(this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name, {
|
|
134
137
|
fill: "#FFFFFF",
|
|
135
138
|
fontSize: 12,
|
|
136
139
|
selectable: !1,
|
|
137
140
|
top: 4,
|
|
138
141
|
left: 8
|
|
139
|
-
}), o = new
|
|
142
|
+
}), o = new g.Rect({
|
|
140
143
|
selectable: !1,
|
|
141
144
|
strokeWidth: 0,
|
|
142
|
-
fill: `rgb(${
|
|
145
|
+
fill: `rgb(${i},${s},${c})`,
|
|
143
146
|
rx: 2,
|
|
144
147
|
ry: 2,
|
|
145
148
|
width: (a.width || 0) + 16,
|
|
@@ -147,7 +150,7 @@ class F {
|
|
|
147
150
|
left: 0,
|
|
148
151
|
top: 0
|
|
149
152
|
});
|
|
150
|
-
return new
|
|
153
|
+
return new g.Group([o, a], {
|
|
151
154
|
selectable: !1,
|
|
152
155
|
// lockScalingX: false,
|
|
153
156
|
// lockScalingY: false,
|
|
@@ -156,10 +159,10 @@ class F {
|
|
|
156
159
|
});
|
|
157
160
|
}
|
|
158
161
|
renderLabel() {
|
|
159
|
-
var
|
|
162
|
+
var i, s;
|
|
160
163
|
if (this._fabricRect) {
|
|
161
164
|
if (this._label || (this._label = this.createLabelName(), this.setLabelPosition()), this._label.canvas === this.canvas) {
|
|
162
|
-
const
|
|
165
|
+
const c = this._label.getObjects().find((o) => o.type === "rect"), a = this._label.getObjects().find((o) => o.type === "text");
|
|
163
166
|
if (a) {
|
|
164
167
|
a.set({
|
|
165
168
|
text: this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name,
|
|
@@ -167,14 +170,14 @@ class F {
|
|
|
167
170
|
// fontSize: this.scaledNumber(12),
|
|
168
171
|
});
|
|
169
172
|
const o = (a.getBoundingRect().width || 0) + 16;
|
|
170
|
-
|
|
173
|
+
c == null || c.set({
|
|
171
174
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`,
|
|
172
175
|
width: o,
|
|
173
176
|
left: -o / 2
|
|
174
177
|
}), a.set({
|
|
175
178
|
left: -o / 2 + 8
|
|
176
179
|
});
|
|
177
|
-
const r = ((
|
|
180
|
+
const r = ((i = this._fabricRect.aCoords) == null ? void 0 : i.tl.x) !== void 0 ? (s = this._fabricRect.aCoords) == null ? void 0 : s.tl.x : void 0;
|
|
178
181
|
this._label.set({
|
|
179
182
|
left: r,
|
|
180
183
|
width: o
|
|
@@ -186,26 +189,26 @@ class F {
|
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
191
|
setLabelPosition() {
|
|
189
|
-
var r, t,
|
|
192
|
+
var r, t, e, h;
|
|
190
193
|
if (!this._fabricRect || !this._label)
|
|
191
194
|
return;
|
|
192
|
-
const
|
|
193
|
-
if (!
|
|
195
|
+
const i = this._label.getObjects().find((b) => b.type === "rect");
|
|
196
|
+
if (!i)
|
|
194
197
|
return;
|
|
195
|
-
const s =
|
|
198
|
+
const s = i.height ? i.height : void 0, c = i.width ? i.width : void 0, a = ((r = this._fabricRect.aCoords) == null ? void 0 : r.tl.y) !== void 0 && s !== void 0 && i.scaleY ? ((t = this._fabricRect.aCoords) == null ? void 0 : t.tl.y) - s / this.canvas.getZoom() : void 0, o = ((e = this._fabricRect.aCoords) == null ? void 0 : e.tl.x) !== void 0 ? (h = this._fabricRect.aCoords) == null ? void 0 : h.tl.x : void 0;
|
|
196
199
|
this._label.set({
|
|
197
200
|
top: a,
|
|
198
201
|
left: o,
|
|
199
202
|
height: s,
|
|
200
|
-
width:
|
|
203
|
+
width: c,
|
|
201
204
|
scaleX: 1 / this.canvas.getZoom(),
|
|
202
205
|
scaleY: 1 / this.canvas.getZoom()
|
|
203
|
-
}), this.config =
|
|
206
|
+
}), this.config = f({}, this.config);
|
|
204
207
|
}
|
|
205
|
-
addToCanvas(
|
|
208
|
+
addToCanvas(i) {
|
|
206
209
|
if (!this._fabricRect)
|
|
207
210
|
return;
|
|
208
|
-
this.canvas =
|
|
211
|
+
this.canvas = i, this.canvas.add(this._fabricRect), this._fabricRect.on("mouseover", (o) => {
|
|
209
212
|
this.hover = !0;
|
|
210
213
|
}), this._fabricRect.on("mouseout", (o) => {
|
|
211
214
|
this.hover = !1;
|
|
@@ -219,40 +222,62 @@ class F {
|
|
|
219
222
|
this.canvas.on("selection:created", s), this.canvas.on("selection:updated", s), this.canvas.on("selection:cleared", (o) => {
|
|
220
223
|
this.active && (this.active = !1);
|
|
221
224
|
});
|
|
222
|
-
const
|
|
225
|
+
const c = (o) => {
|
|
226
|
+
var b, y, x, S, $, L;
|
|
223
227
|
const r = o.transform.action;
|
|
224
228
|
o.transform.corner;
|
|
225
|
-
const t = o.transform.target,
|
|
226
|
-
|
|
227
|
-
top:
|
|
228
|
-
}), t.top + (t.height +
|
|
229
|
-
top:
|
|
230
|
-
}), t.left <
|
|
231
|
-
left:
|
|
232
|
-
}), t.left + (t.width +
|
|
233
|
-
left:
|
|
234
|
-
})), r === "scale" && (t.top + (t.height +
|
|
235
|
-
top: (t.height +
|
|
236
|
-
height: (t.height +
|
|
237
|
-
}), t.left + (t.width +
|
|
238
|
-
left:
|
|
239
|
-
})), r === "scaleX" && (t.left + (t.width +
|
|
240
|
-
left: t.left - (t.left + (t.width +
|
|
241
|
-
}), t.left <
|
|
242
|
-
left:
|
|
243
|
-
})), r === "scaleY" && (t.top + (t.height +
|
|
244
|
-
top: t.top - (t.top + (t.height +
|
|
245
|
-
}), t.top <
|
|
246
|
-
top:
|
|
247
|
-
})), (t.width +
|
|
248
|
-
left:
|
|
249
|
-
width: (
|
|
250
|
-
}), (t.height +
|
|
251
|
-
top:
|
|
252
|
-
height: (
|
|
253
|
-
})),
|
|
229
|
+
const t = o.transform.target, e = o.transform.target.canvas.backgroundImage, h = 0;
|
|
230
|
+
if (e && (r === "drag" && (t.top < e.top && t.set({
|
|
231
|
+
top: e.top
|
|
232
|
+
}), t.top + (t.height + h) * t.scaleY > e.top + e.height && t.set({
|
|
233
|
+
top: e.height + e.top - (t.height + h) * t.scaleY
|
|
234
|
+
}), t.left < e.left && t.set({
|
|
235
|
+
left: e.left
|
|
236
|
+
}), t.left + (t.width + h) * t.scaleX > e.left + e.width && t.set({
|
|
237
|
+
left: e.width + e.left - (t.width + h) * t.scaleX
|
|
238
|
+
})), r === "scale" && (t.top + (t.height + h) * t.scaleY > e.top + e.height && t.set({
|
|
239
|
+
top: (t.height + h) * t.scaleY > e.height ? e.top : e.top + e.height - (t.height + h) * t.scaleY,
|
|
240
|
+
height: (t.height + h) * t.scaleY > e.height ? e.height - h : t.height + h
|
|
241
|
+
}), t.left + (t.width + h) * t.scaleX > e.left + e.width && t.set({
|
|
242
|
+
left: e.width + e.left - (t.width + h) * t.scaleX
|
|
243
|
+
})), r === "scaleX" && (t.left + (t.width + h) * t.scaleX > e.left + e.width && t.set({
|
|
244
|
+
left: t.left - (t.left + (t.width + h) * t.scaleX - (e.left + e.width))
|
|
245
|
+
}), t.left < e.left && t.set({
|
|
246
|
+
left: e.left
|
|
247
|
+
})), r === "scaleY" && (t.top + (t.height + h) * t.scaleY > e.top + e.height && t.set({
|
|
248
|
+
top: t.top - (t.top + (t.height + h) * t.scaleY - (e.top + e.height))
|
|
249
|
+
}), t.top < e.top && t.set({
|
|
250
|
+
top: e.top
|
|
251
|
+
})), (t.width + h) * t.scaleX > e.width && t.set({
|
|
252
|
+
left: e.left,
|
|
253
|
+
width: (e.width - h) / t.scaleX
|
|
254
|
+
}), (t.height + h) * t.scaleY > e.height && t.set({
|
|
255
|
+
top: e.top,
|
|
256
|
+
height: (e.height - h) / t.scaleY
|
|
257
|
+
})), e) {
|
|
258
|
+
const v = t.getBoundingRect(!0), R = (b = e.left) != null ? b : 0, m = (y = e.top) != null ? y : 0, k = R + ((x = e.width) != null ? x : 0), Y = m + ((S = e.height) != null ? S : 0);
|
|
259
|
+
if (v.width > (($ = e.width) != null ? $ : v.width)) {
|
|
260
|
+
const u = (e.width - h) / Math.max(t.width, 1);
|
|
261
|
+
t.set({
|
|
262
|
+
scaleX: Math.min(t.scaleX, u)
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
if (v.height > ((L = e.height) != null ? L : v.height)) {
|
|
266
|
+
const u = (e.height - h) / Math.max(t.height, 1);
|
|
267
|
+
t.set({
|
|
268
|
+
scaleY: Math.min(t.scaleY, u)
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
const n = t.getBoundingRect(!0);
|
|
272
|
+
let _ = 0, p = 0;
|
|
273
|
+
n.left < R ? _ = R - n.left : n.left + n.width > k && (_ = k - (n.left + n.width)), n.top < m ? p = m - n.top : n.top + n.height > Y && (p = Y - (n.top + n.height)), (_ !== 0 || p !== 0) && t.set({
|
|
274
|
+
left: t.left + _,
|
|
275
|
+
top: t.top + p
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
this.canvas.renderAll();
|
|
254
279
|
}, a = (o) => {
|
|
255
|
-
|
|
280
|
+
c(o), this.setLabelPosition();
|
|
256
281
|
};
|
|
257
282
|
this._fabricRect.on("moving", a), this._fabricRect.on("scaling", a), this._fabricRect.on("rotating", a), this._fabricRect.on("skewing", a), this._fabricRect.on("resizing", a), this.canvas.on("object:removed", (o) => {
|
|
258
283
|
o.target === this._fabricRect && this.destroy();
|
|
@@ -260,24 +285,24 @@ class F {
|
|
|
260
285
|
o.target === this._fabricRect && (this.setLabelPosition(), this.handlers.onChange && this.handlers.onChange(this));
|
|
261
286
|
});
|
|
262
287
|
}
|
|
263
|
-
render(
|
|
264
|
-
|
|
288
|
+
render(i) {
|
|
289
|
+
O(g), this._fabricRect || (this._fabricRect = this.createRect()), this._fabricRect.canvas === this.canvas ? this._fabricRect.set({
|
|
265
290
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0)`,
|
|
266
291
|
stroke: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`
|
|
267
|
-
}) : this.addToCanvas(
|
|
292
|
+
}) : this.addToCanvas(i), this.renderLabel();
|
|
268
293
|
try {
|
|
269
294
|
this.canvas.renderAll();
|
|
270
295
|
} catch (s) {
|
|
271
296
|
console.log("render failed");
|
|
272
297
|
}
|
|
273
298
|
}
|
|
274
|
-
set labelConfig(
|
|
275
|
-
this.config =
|
|
299
|
+
set labelConfig(i) {
|
|
300
|
+
this.config = f(f({}, this.config), i), this.color = X(i.color), this.render(this.canvas), this.handlers.onChange && this.handlers.onChange(this);
|
|
276
301
|
}
|
|
277
302
|
destroy() {
|
|
278
303
|
this._fabricRect && this.canvas.remove(this._fabricRect), this._label && this.canvas.remove(this._label), this._label = null, this._fabricRect = null, this.canvas.requestRenderAll(), this.handlers.onDelete && this.handlers.onDelete(this);
|
|
279
304
|
}
|
|
280
305
|
}
|
|
281
306
|
export {
|
|
282
|
-
|
|
307
|
+
M as default
|
|
283
308
|
};
|