@glodon-aiot/dataset-annotation 3.10.0-alpha.22 → 3.10.0-alpha.23
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.
|
@@ -23,7 +23,7 @@ const z = {
|
|
|
23
23
|
active: !1
|
|
24
24
|
};
|
|
25
25
|
class M {
|
|
26
|
-
constructor(i, s,
|
|
26
|
+
constructor(i, s, a) {
|
|
27
27
|
d(this, "config");
|
|
28
28
|
d(this, "color");
|
|
29
29
|
d(this, "_active", !1);
|
|
@@ -31,7 +31,7 @@ class M {
|
|
|
31
31
|
d(this, "_label", null);
|
|
32
32
|
d(this, "_hover", !1);
|
|
33
33
|
d(this, "_strokeRect");
|
|
34
|
-
this._canvas = s, this.handlers =
|
|
34
|
+
this._canvas = s, this.handlers = a, 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;
|
|
@@ -47,8 +47,8 @@ class M {
|
|
|
47
47
|
return this._hover;
|
|
48
48
|
}
|
|
49
49
|
set hover(i) {
|
|
50
|
-
var s,
|
|
51
|
-
this._hover = i, i ? (s = this._fabricRect) == null || s.set(this.hoverStyle) : this.active || (
|
|
50
|
+
var s, a;
|
|
51
|
+
this._hover = i, i ? (s = this._fabricRect) == null || s.set(this.hoverStyle) : this.active || (a = this._fabricRect) == null || a.set(this.normalStyle), this.canvas.requestRenderAll();
|
|
52
52
|
}
|
|
53
53
|
get canvas() {
|
|
54
54
|
return this._canvas;
|
|
@@ -83,7 +83,7 @@ class M {
|
|
|
83
83
|
cornerStrokeColor: "#84868C",
|
|
84
84
|
cornerColor: "#FFFFFF",
|
|
85
85
|
transparentCorners: !1
|
|
86
|
-
}, s = 0,
|
|
86
|
+
}, s = 0, a = 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],
|
|
@@ -95,19 +95,19 @@ class M {
|
|
|
95
95
|
lockScalingFlip: !0
|
|
96
96
|
})
|
|
97
97
|
);
|
|
98
|
-
|
|
98
|
+
a.setControlsVisibility({
|
|
99
99
|
mtr: !1
|
|
100
100
|
});
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
this.canvas.off("after:render",
|
|
101
|
+
const c = () => {
|
|
102
|
+
if (a.canvas !== this.canvas) {
|
|
103
|
+
this.canvas.off("after:render", c);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
this.canvas.contextContainer.strokeStyle = `rgb(${this.color[0]},${this.color[1]}, ${this.color[2]})`;
|
|
107
|
-
const o =
|
|
107
|
+
const o = a.getBoundingRect();
|
|
108
108
|
this._strokeRect = this.canvas.contextContainer.strokeRect(o.left + 0.5, o.top + 0.5, o.width, o.height);
|
|
109
109
|
};
|
|
110
|
-
return this.canvas.on("after:render",
|
|
110
|
+
return this.canvas.on("after:render", c), a;
|
|
111
111
|
}
|
|
112
112
|
scaledNumber(i) {
|
|
113
113
|
return i / this.canvas.getZoom();
|
|
@@ -133,25 +133,28 @@ class M {
|
|
|
133
133
|
// });
|
|
134
134
|
// }
|
|
135
135
|
createLabelName() {
|
|
136
|
-
const [i, s,
|
|
136
|
+
const [i, s, a] = this.color, c = new g.Text(this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name, {
|
|
137
137
|
fill: "#FFFFFF",
|
|
138
138
|
fontSize: 12,
|
|
139
139
|
selectable: !1,
|
|
140
|
+
evented: !1,
|
|
140
141
|
top: 4,
|
|
141
142
|
left: 8
|
|
142
143
|
}), o = new g.Rect({
|
|
143
144
|
selectable: !1,
|
|
145
|
+
evented: !1,
|
|
144
146
|
strokeWidth: 0,
|
|
145
|
-
fill: `rgb(${i},${s},${
|
|
147
|
+
fill: `rgb(${i},${s},${a})`,
|
|
146
148
|
rx: 2,
|
|
147
149
|
ry: 2,
|
|
148
|
-
width: (
|
|
149
|
-
height: (
|
|
150
|
+
width: (c.width || 0) + 16,
|
|
151
|
+
height: (c.height || 0) + 8,
|
|
150
152
|
left: 0,
|
|
151
153
|
top: 0
|
|
152
154
|
});
|
|
153
|
-
return new g.Group([o,
|
|
155
|
+
return new g.Group([o, c], {
|
|
154
156
|
selectable: !1,
|
|
157
|
+
evented: !1,
|
|
155
158
|
// lockScalingX: false,
|
|
156
159
|
// lockScalingY: false,
|
|
157
160
|
scaleX: 1 / this.canvas.getZoom(),
|
|
@@ -162,19 +165,19 @@ class M {
|
|
|
162
165
|
var i, s;
|
|
163
166
|
if (this._fabricRect) {
|
|
164
167
|
if (this._label || (this._label = this.createLabelName(), this.setLabelPosition()), this._label.canvas === this.canvas) {
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
+
const a = this._label.getObjects().find((o) => o.type === "rect"), c = this._label.getObjects().find((o) => o.type === "text");
|
|
169
|
+
if (c) {
|
|
170
|
+
c.set({
|
|
168
171
|
text: this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name,
|
|
169
172
|
left: 8
|
|
170
173
|
// fontSize: this.scaledNumber(12),
|
|
171
174
|
});
|
|
172
|
-
const o = (
|
|
173
|
-
|
|
175
|
+
const o = (c.getBoundingRect().width || 0) + 16;
|
|
176
|
+
a == null || a.set({
|
|
174
177
|
fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`,
|
|
175
178
|
width: o,
|
|
176
179
|
left: -o / 2
|
|
177
|
-
}),
|
|
180
|
+
}), c.set({
|
|
178
181
|
left: -o / 2 + 8
|
|
179
182
|
});
|
|
180
183
|
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;
|
|
@@ -195,12 +198,12 @@ class M {
|
|
|
195
198
|
const i = this._label.getObjects().find((b) => b.type === "rect");
|
|
196
199
|
if (!i)
|
|
197
200
|
return;
|
|
198
|
-
const s = i.height ? i.height : void 0,
|
|
201
|
+
const s = i.height ? i.height : void 0, a = i.width ? i.width : void 0, c = ((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;
|
|
199
202
|
this._label.set({
|
|
200
|
-
top:
|
|
203
|
+
top: c,
|
|
201
204
|
left: o,
|
|
202
205
|
height: s,
|
|
203
|
-
width:
|
|
206
|
+
width: a,
|
|
204
207
|
scaleX: 1 / this.canvas.getZoom(),
|
|
205
208
|
scaleY: 1 / this.canvas.getZoom()
|
|
206
209
|
}), this.config = f({}, this.config);
|
|
@@ -222,7 +225,7 @@ class M {
|
|
|
222
225
|
this.canvas.on("selection:created", s), this.canvas.on("selection:updated", s), this.canvas.on("selection:cleared", (o) => {
|
|
223
226
|
this.active && (this.active = !1);
|
|
224
227
|
});
|
|
225
|
-
const
|
|
228
|
+
const a = (o) => {
|
|
226
229
|
var b, y, x, S, $, L;
|
|
227
230
|
const r = o.transform.action;
|
|
228
231
|
o.transform.corner;
|
|
@@ -276,10 +279,10 @@ class M {
|
|
|
276
279
|
});
|
|
277
280
|
}
|
|
278
281
|
this.canvas.renderAll();
|
|
279
|
-
},
|
|
280
|
-
|
|
282
|
+
}, c = (o) => {
|
|
283
|
+
a(o), this.setLabelPosition();
|
|
281
284
|
};
|
|
282
|
-
this._fabricRect.on("moving",
|
|
285
|
+
this._fabricRect.on("moving", c), this._fabricRect.on("scaling", c), this._fabricRect.on("rotating", c), this._fabricRect.on("skewing", c), this._fabricRect.on("resizing", c), this.canvas.on("object:removed", (o) => {
|
|
283
286
|
o.target === this._fabricRect && this.destroy();
|
|
284
287
|
}), this.canvas.on("object:modified", (o) => {
|
|
285
288
|
o.target === this._fabricRect && (this.setLabelPosition(), this.handlers.onChange && this.handlers.onChange(this));
|