Enable scaling the selection via hotkeys

This commit is contained in:
Quincy Morgan
2020-09-21 14:02:41 -04:00
parent 28ea082892
commit 45decdb54c
8 changed files with 190 additions and 5 deletions
+1
View File
@@ -30,6 +30,7 @@ export { actionRestrictTurn } from './restrict_turn';
export { actionReverse } from './reverse';
export { actionRevert } from './revert';
export { actionRotate } from './rotate';
export { actionScale } from './scale';
export { actionSplit } from './split';
export { actionStraightenNodes } from './straighten_nodes';
export { actionStraightenWay } from './straighten_way';
+24
View File
@@ -0,0 +1,24 @@
import { utilGetAllNodes } from '../util';
export function actionScale(ids, pivotLoc, scaleFactor, projection) {
return function(graph) {
return graph.update(function(graph) {
let point, radial;
utilGetAllNodes(ids, graph).forEach(function(node) {
point = projection(node.loc);
radial = [
point[0] - pivotLoc[0],
point[1] - pivotLoc[1]
];
point = [
pivotLoc[0] + (scaleFactor * radial[0]),
pivotLoc[1] + (scaleFactor * radial[1])
];
graph = graph.replace(node.move(projection.invert(point)));
});
});
};
}