UNPKG

@gorpacrate/core-graphics

Version:

A core library for creating shape-based graphic editors

28 lines 1.35 kB
"use strict"; exports.__esModule = true; var bounding_box_1 = require("./bounding-box"); function getShapesSelectedWithRubberBand(payload) { var pStart = payload.pStart, pEnd = payload.pEnd, shapesData = payload.shapesData, shapesDeclarations = payload.shapesDeclarations; var indexedBoundingBoxes = shapesData.map(function (shapeData) { var id = shapeData.id, type = shapeData.type; return { id: id, bb: shapesDeclarations[type].getBoundingBox(shapeData) }; }); var rubberBandBB = bounding_box_1.getBoundingBoxFromTwoPoints(pStart, pEnd); return indexedBoundingBoxes.filter(function (_a) { var bb = _a.bb; return bounding_box_1.doBoundingBoxesCollide(rubberBandBB, bb); }).map(function (_a) { var id = _a.id; return id; }); } exports.getShapesSelectedWithRubberBand = getShapesSelectedWithRubberBand; function getResultingRubberBandSelectedShapes(payload) { if (!payload) { return []; } var _a = payload.newlySelectedShapes, newlySelectedShapes = _a === void 0 ? [] : _a, _b = payload.previouslySelectedShapes, previouslySelectedShapes = _b === void 0 ? [] : _b; return previouslySelectedShapes.concat(newlySelectedShapes); } exports.getResultingRubberBandSelectedShapes = getResultingRubberBandSelectedShapes; //# sourceMappingURL=rubber-band.js.map