react-image-annotate-master-custom 0.0.1 → 0.0.3
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.
|
@@ -502,7 +502,7 @@ export default (function (state, action) {
|
|
|
502
502
|
|
|
503
503
|
case "MOUSE_DOWN":
|
|
504
504
|
{
|
|
505
|
-
var _getIn$regions;
|
|
505
|
+
var _getIn$regions, _getIn$regions2;
|
|
506
506
|
|
|
507
507
|
if (!activeImage) return state;
|
|
508
508
|
var _x = action.x,
|
|
@@ -763,14 +763,17 @@ export default (function (state, action) {
|
|
|
763
763
|
|
|
764
764
|
default:
|
|
765
765
|
break;
|
|
766
|
-
}
|
|
766
|
+
} // customize create only one annotation
|
|
767
|
+
|
|
767
768
|
|
|
768
|
-
if (
|
|
769
|
-
(_getIn$regions = getIn(state, pathToActiveImage).regions[getIn(state, pathToActiveImage).regions.length - 1]) === null || _getIn$regions === void 0 ? void 0 : _getIn$regions.isNew) {
|
|
769
|
+
if (((_getIn$regions = getIn(state, pathToActiveImage).regions) === null || _getIn$regions === void 0 ? void 0 : _getIn$regions.length) > 0 && ((_getIn$regions2 = getIn(state, pathToActiveImage).regions[getIn(state, pathToActiveImage).regions.length - 1]) === null || _getIn$regions2 === void 0 ? void 0 : _getIn$regions2.isNew)) {
|
|
770
770
|
var _regions = _toConsumableArray(getIn(state, pathToActiveImage).regions || []);
|
|
771
771
|
|
|
772
|
+
console.log(state, "state");
|
|
773
|
+
console.log(getIn(state, pathToActiveImage), "pathToActiveImage");
|
|
772
774
|
return setIn(state, [].concat(_toConsumableArray(pathToActiveImage), ["regions"]), _regions);
|
|
773
775
|
} else {
|
|
776
|
+
console.log(3333333333333);
|
|
774
777
|
state.onCreateAnno(newRegion); // customize
|
|
775
778
|
|
|
776
779
|
var _regions2 = _toConsumableArray(getIn(state, pathToActiveImage).regions || []).map(function (r) {
|
package/HighlightBox/index.js
CHANGED
|
@@ -14,26 +14,26 @@ var useStyles = makeStyles(function (theme) {
|
|
|
14
14
|
strokeDashoffset: 100
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
highlightLight: {
|
|
18
18
|
zIndex: 2,
|
|
19
19
|
transition: "opacity 500ms",
|
|
20
20
|
"&.highlighted": {
|
|
21
|
-
zIndex:
|
|
21
|
+
zIndex: 1,
|
|
22
22
|
filter: "invert(40%) sepia(50%) saturate(1928%) hue-rotate(350deg) brightness(94%) contrast(89%)" //customize
|
|
23
23
|
|
|
24
24
|
},
|
|
25
25
|
"&:not(.highlighted)": {
|
|
26
26
|
opacity: 0
|
|
27
27
|
},
|
|
28
|
-
"&:not(.highlighted):hover": {
|
|
29
|
-
|
|
30
|
-
},
|
|
28
|
+
// "&:not(.highlighted):hover": {
|
|
29
|
+
// opacity: 0.6,
|
|
30
|
+
// },
|
|
31
31
|
"& path": {
|
|
32
32
|
vectorEffect: "non-scaling-stroke",
|
|
33
33
|
strokeWidth: 2,
|
|
34
34
|
stroke: "#FFF",
|
|
35
35
|
fill: "none",
|
|
36
|
-
strokeDasharray:
|
|
36
|
+
strokeDasharray: "none",
|
|
37
37
|
animationName: "$borderDance",
|
|
38
38
|
animationDuration: "4s",
|
|
39
39
|
animationTimingFunction: "linear",
|
|
@@ -68,12 +68,34 @@ export var HighlightBox = function HighlightBox(_ref) {
|
|
|
68
68
|
height: pbox.h + 10
|
|
69
69
|
};
|
|
70
70
|
var pathD = r.type === "point" ? "M5,5 L".concat(styleCoords.width - 5, " 5L").concat(styleCoords.width - 5, " ").concat(styleCoords.height - 5, "L5 ").concat(styleCoords.height - 5, "Z") : "M5,5 L".concat(pbox.w + 5, ",5 L").concat(pbox.w + 5, ",").concat(pbox.h + 5, " L5,").concat(pbox.h + 5, " Z");
|
|
71
|
+
var styleCoordsHorizontal = r.type === "point" ? {
|
|
72
|
+
top: pbox.y + pbox.h - 12,
|
|
73
|
+
width: 600000000,
|
|
74
|
+
height: 3
|
|
75
|
+
} : {
|
|
76
|
+
left: pbox.x - 5,
|
|
77
|
+
top: pbox.y - 5,
|
|
78
|
+
width: pbox.w + 10,
|
|
79
|
+
height: pbox.h + 10
|
|
80
|
+
};
|
|
81
|
+
var styleCoordsVertical = r.type === "point" ? {
|
|
82
|
+
left: pbox.x + pbox.w - 15,
|
|
83
|
+
width: 20,
|
|
84
|
+
height: 60000000
|
|
85
|
+
} : {
|
|
86
|
+
left: pbox.x - 5,
|
|
87
|
+
top: pbox.y - 5,
|
|
88
|
+
width: pbox.w + 10,
|
|
89
|
+
height: pbox.h + 10
|
|
90
|
+
};
|
|
91
|
+
var pathDHorizontal = r.type === "point" ? "M1,2 H".concat(styleCoordsHorizontal.width - 5, " Z") : "M5,5 L".concat(pbox.w + 5, ",5 L").concat(pbox.w + 5, ",").concat(pbox.h + 5, " L5,").concat(pbox.h + 5, " Z");
|
|
92
|
+
var pathDVertical = r.type === "point" ? "M1,1 V".concat(styleCoordsVertical.height - 5, " Z") : "M5,5 L".concat(pbox.w + 5, ",5 L").concat(pbox.w + 5, ",").concat(pbox.h + 5, " L5,").concat(pbox.h + 5, " Z");
|
|
71
93
|
return React.createElement(ThemeProvider, {
|
|
72
94
|
theme: theme
|
|
73
95
|
}, React.createElement("svg", Object.assign({
|
|
74
|
-
key: r.id,
|
|
75
|
-
id: r.id,
|
|
76
|
-
className: classnames(classes.
|
|
96
|
+
key: "".concat(r.id, "-box"),
|
|
97
|
+
id: "".concat(r.id, "-box"),
|
|
98
|
+
className: classnames(classes.highlightLight, {
|
|
77
99
|
highlighted: r.highlighted
|
|
78
100
|
})
|
|
79
101
|
}, mouseEvents, !zoomWithPrimary && !dragWithPrimary ? {
|
|
@@ -99,7 +121,70 @@ export var HighlightBox = function HighlightBox(_ref) {
|
|
|
99
121
|
position: "absolute"
|
|
100
122
|
}, styleCoords)
|
|
101
123
|
}), React.createElement("path", {
|
|
102
|
-
d: pathD
|
|
124
|
+
d: pathD,
|
|
125
|
+
style: {
|
|
126
|
+
strokeDasharray: 5
|
|
127
|
+
}
|
|
128
|
+
})), React.createElement("svg", Object.assign({
|
|
129
|
+
key: "".concat(r.id, "-horizontal"),
|
|
130
|
+
id: "".concat(r.id, "-horizontal"),
|
|
131
|
+
className: classnames(classes.highlightLight, {
|
|
132
|
+
highlighted: r.highlighted
|
|
133
|
+
})
|
|
134
|
+
}, mouseEvents, !zoomWithPrimary && !dragWithPrimary ? {
|
|
135
|
+
onMouseDown: function onMouseDown(e) {
|
|
136
|
+
if (!r.locked && r.type === "point" && r.highlighted && e.button === 0) {
|
|
137
|
+
return onBeginMovePoint(r);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (e.button === 0 && !createWithPrimary) {
|
|
141
|
+
return onSelectRegion(r);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
onSelectRegion(r); //mouseEvents.onMouseDown(e)
|
|
145
|
+
}
|
|
146
|
+
} : {}, {
|
|
147
|
+
style: _objectSpread({}, r.highlighted ? {
|
|
148
|
+
pointerEvents: r.type !== "point" ? "none" : undefined,
|
|
149
|
+
cursor: "grab"
|
|
150
|
+
} : {
|
|
151
|
+
cursor: !(zoomWithPrimary || dragWithPrimary || createWithPrimary) ? "pointer" : undefined,
|
|
152
|
+
pointerEvents: zoomWithPrimary || dragWithPrimary || createWithPrimary && !r.highlighted ? "none" : undefined
|
|
153
|
+
}, {
|
|
154
|
+
position: "absolute"
|
|
155
|
+
}, styleCoordsHorizontal)
|
|
156
|
+
}), React.createElement("path", {
|
|
157
|
+
d: pathDHorizontal
|
|
158
|
+
})), React.createElement("svg", Object.assign({
|
|
159
|
+
key: "".concat(r.id, "-vertical"),
|
|
160
|
+
id: "".concat(r.id, "-vertical"),
|
|
161
|
+
className: classnames(classes.highlightLight, {
|
|
162
|
+
highlighted: r.highlighted
|
|
163
|
+
})
|
|
164
|
+
}, mouseEvents, !zoomWithPrimary && !dragWithPrimary ? {
|
|
165
|
+
onMouseDown: function onMouseDown(e) {
|
|
166
|
+
if (!r.locked && r.type === "point" && r.highlighted && e.button === 0) {
|
|
167
|
+
return onBeginMovePoint(r);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (e.button === 0 && !createWithPrimary) {
|
|
171
|
+
return onSelectRegion(r);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
onSelectRegion(r); //mouseEvents.onMouseDown(e)
|
|
175
|
+
}
|
|
176
|
+
} : {}, {
|
|
177
|
+
style: _objectSpread({}, r.highlighted ? {
|
|
178
|
+
pointerEvents: r.type !== "point" ? "none" : undefined,
|
|
179
|
+
cursor: "grab"
|
|
180
|
+
} : {
|
|
181
|
+
cursor: !(zoomWithPrimary || dragWithPrimary || createWithPrimary) ? "pointer" : undefined,
|
|
182
|
+
pointerEvents: zoomWithPrimary || dragWithPrimary || createWithPrimary && !r.highlighted ? "none" : undefined
|
|
183
|
+
}, {
|
|
184
|
+
position: "absolute"
|
|
185
|
+
}, styleCoordsVertical)
|
|
186
|
+
}), React.createElement("path", {
|
|
187
|
+
d: pathDVertical
|
|
103
188
|
})));
|
|
104
189
|
};
|
|
105
190
|
export default HighlightBox;
|
package/ImageCanvas/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import VideoOrImageCanvasBackground from "../VideoOrImageCanvasBackground";
|
|
|
22
22
|
import useEventCallback from "use-event-callback";
|
|
23
23
|
import RegionShapes from "../RegionShapes";
|
|
24
24
|
import useWasdMode from "./use-wasd-mode";
|
|
25
|
+
import { useSettings } from "../SettingsProvider";
|
|
25
26
|
var theme = createTheme();
|
|
26
27
|
var useStyles = makeStyles(function (theme) {
|
|
27
28
|
return styles;
|
|
@@ -137,6 +138,7 @@ export var ImageCanvas = function ImageCanvas(_ref2) {
|
|
|
137
138
|
|
|
138
139
|
var maskImages = useRef({});
|
|
139
140
|
var windowSize = useWindowSize();
|
|
141
|
+
var settings = useSettings();
|
|
140
142
|
var getLatestMat = useEventCallback(function () {
|
|
141
143
|
return mat;
|
|
142
144
|
});
|
|
@@ -303,7 +305,13 @@ export var ImageCanvas = function ImageCanvas(_ref2) {
|
|
|
303
305
|
position: "relative",
|
|
304
306
|
overflow: "hidden",
|
|
305
307
|
cursor: createWithPrimary ? "crosshair" : dragging ? "grabbing" : dragWithPrimary ? "grab" : zoomWithPrimary ? mat.a < 1 ? "zoom-out" : "zoom-in" : undefined
|
|
306
|
-
}
|
|
308
|
+
} // onMouseLeave={()=> {
|
|
309
|
+
// settings.changeSetting("showCrosshairs" , false)
|
|
310
|
+
// }}
|
|
311
|
+
// onMouseEnter={()=> {
|
|
312
|
+
// settings.changeSetting("showCrosshairs", true)
|
|
313
|
+
// }}
|
|
314
|
+
|
|
307
315
|
}, showCrosshairs && React.createElement(Crosshairs, {
|
|
308
316
|
key: "crossHairs",
|
|
309
317
|
mousePosition: mousePosition
|