Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private processToolEvent(event: paper.ToolEvent) {
// Calculate the bounding rectangle to use to select segments in
// the edit path's local coordinate space.
const editPath = this.pl.findItemByLayerId(this.editPathId) as paper.Path;
const rectangle = new paper.Rectangle(
editPath.globalToLocal(event.downPoint),
editPath.globalToLocal(event.point),
);
this.updatedSelectedSegments = new Set(
_.flatMap(editPath.segments, ({ point }, segmentIndex) => {
return rectangle.contains(point) ? [segmentIndex] : [];
}),
);
this.updateCurrentSelection(event.modifiers.command || event.modifiers.shift);
}
private processToolEvent(event: paper.ToolEvent) {
// Calculate the bounding rectangle to use to select segments in
// the edit path's local coordinate space.
const editPath = this.pl.findItemByLayerId(this.editPathId) as paper.Path;
const rectangle = new paper.Rectangle(
editPath.globalToLocal(event.downPoint),
editPath.globalToLocal(event.point),
);
this.updatedSelectedSegments = new Set(
_.flatMap(editPath.segments, ({ point }, segmentIndex) => {
return rectangle.contains(point) ? [segmentIndex] : [];
}),
);
this.updateCurrentSelection(event.modifiers.command || event.modifiers.shift);
}
).reduce((rect: paper.Rectangle, p: paper.Point) => {
p = editPath.localToGlobal(p);
return rect ? rect.include(p) : new paper.Rectangle(p, new paper.Size(0, 0));
}, undefined);
const siblingSnapPointsTable = [
function createSelectionBoxRect(from: paper.Point, to: paper.Point) {
const half = new paper.Point(0.5 / paper.view.zoom, 0.5 / paper.view.zoom);
return new paper.Rectangle(from.add(half), to.add(half));
}
private selectItemsInSelectionBox(includePartialOverlaps: boolean) {
const box = this.ps.getSelectionBox();
if (box) {
const from = new paper.Point(box.from);
const to = new paper.Point(box.to);
const selectedItems = this.pl.findItemsInBounds(
new paper.Rectangle(from, to),
includePartialOverlaps,
);
this.ps.setSelectedLayerIds(new Set(selectedItems.map(i => i.data.id)));
}
}
}
export function transformRectangle(rect: paper.Rectangle, m: paper.Matrix) {
return new paper.Rectangle(rect.topLeft.transform(m), rect.bottomRight.transform(m));
}
private selectItemsInSelectionBox(includePartialOverlaps: boolean) {
const box = this.ps.getSelectionBox();
if (box) {
const from = new paper.Point(box.from);
const to = new paper.Point(box.to);
const selectedItems = this.pl.findItemsInBounds(
new paper.Rectangle(from, to),
includePartialOverlaps,
);
this.ps.setSelectedLayerIds(new Set(selectedItems.map(i => i.data.id)));
}
}
}
export function vec2Rectangle(vec: Vec2): paper.Rectangle {
return new paper.Rectangle(0, 0, vec.x, vec.y);
}