Move to new fog snapping with guides and vertex snapping

This commit is contained in:
Mitchell McCaffrey
2021-02-11 19:57:34 +11:00
parent 547a214149
commit 85270859bb
6 changed files with 604 additions and 105 deletions

View File

@@ -27,6 +27,7 @@ function MapMeasure({ map, active }) {
gridCellNormalizedSize,
gridStrokeWidth,
gridCellPixelSize,
gridOffset,
} = useGrid();
const mapStageRef = useMapStage();
const [drawingShapeData, setDrawingShapeData] = useState(null);
@@ -73,14 +74,20 @@ function MapMeasure({ map, active }) {
gridCellNormalizedSize
);
// Convert back to pixel values
const a = Vector2.multiply(points[0], {
x: mapImage.width(),
y: mapImage.height(),
});
const b = Vector2.multiply(points[1], {
x: mapImage.width(),
y: mapImage.height(),
});
const a = Vector2.subtract(
Vector2.multiply(points[0], {
x: mapImage.width(),
y: mapImage.height(),
}),
gridOffset
);
const b = Vector2.subtract(
Vector2.multiply(points[1], {
x: mapImage.width(),
y: mapImage.height(),
}),
gridOffset
);
const length = gridDistance(grid, a, b, gridCellPixelSize);
setDrawingShapeData({
length,