mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 13:45:25 +03:00
limit interpolated coordinates and use crosshair cursor
This commit is contained in:
parent
083ca94c48
commit
565629871b
@ -222,6 +222,27 @@ export function PolygonCanvas({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleStageMouseOver = (
|
||||||
|
e: Konva.KonvaEventObject<MouseEvent | TouchEvent>,
|
||||||
|
) => {
|
||||||
|
if (activePolygonIndex === undefined || !polygons) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedPolygons = [...polygons];
|
||||||
|
const activePolygon = updatedPolygons[activePolygonIndex];
|
||||||
|
|
||||||
|
if (activePolygon.isFinished) return;
|
||||||
|
e.target.getStage()!.container().style.cursor = "crosshair";
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStageMouseOut = (
|
||||||
|
e: Konva.KonvaEventObject<MouseEvent | TouchEvent>,
|
||||||
|
) => {
|
||||||
|
if (!e.target) return;
|
||||||
|
e.target.getStage()!.container().style.cursor = "default";
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stage
|
<Stage
|
||||||
ref={stageRef}
|
ref={stageRef}
|
||||||
@ -229,6 +250,8 @@ export function PolygonCanvas({
|
|||||||
height={height}
|
height={height}
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
onTouchStart={handleMouseDown}
|
onTouchStart={handleMouseDown}
|
||||||
|
onMouseOver={handleStageMouseOver}
|
||||||
|
onMouseOut={handleStageMouseOut}
|
||||||
>
|
>
|
||||||
<Layer>
|
<Layer>
|
||||||
<Image
|
<Image
|
||||||
|
|||||||
@ -56,8 +56,8 @@ export const interpolatePoints = (
|
|||||||
const newPoints: number[][] = [];
|
const newPoints: number[][] = [];
|
||||||
|
|
||||||
for (const [x, y] of points) {
|
for (const [x, y] of points) {
|
||||||
const newX = +((x * newWidth) / width).toFixed(3);
|
const newX = Math.min(+((x * newWidth) / width).toFixed(3), newWidth);
|
||||||
const newY = +((y * newHeight) / height).toFixed(3);
|
const newY = Math.min(+((y * newHeight) / height).toFixed(3), newHeight);
|
||||||
newPoints.push([newX, newY]);
|
newPoints.push([newX, newY]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user