How to use the paper.Rectangle function in paper

To help you get started, we’ve selected a few paper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexjlockwood / ShapeShifter / src / app / modules / editor / scripts / paper / gesture / edit / BatchSelectSegmentsGesture.ts View on Github external
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);
  }
github alexjlockwood / ShapeShifter / src / app / pages / editor / scripts / paper / gesture / edit / BatchSelectSegmentsGesture.ts View on Github external
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);
  }
github alexjlockwood / ShapeShifter / src / app / modules / editor / scripts / paper / gesture / edit / SelectDragDrawSegmentsGesture.ts View on Github external
).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 = [
github alexjlockwood / ShapeShifter / src / app / scripts / paper / util / Guides.ts View on Github external
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));
}
github alexjlockwood / ShapeShifter / src / app / pages / editor / scripts / paper / gesture / select / BatchSelectItemsGesture.ts View on Github external
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)));
    }
  }
}
github alexjlockwood / ShapeShifter / src / app / modules / editor / scripts / paper / util / PaperUtil.ts View on Github external
export function transformRectangle(rect: paper.Rectangle, m: paper.Matrix) {
  return new paper.Rectangle(rect.topLeft.transform(m), rect.bottomRight.transform(m));
}
github alexjlockwood / ShapeShifter / src / app / modules / editor / scripts / paper / gesture / select / BatchSelectItemsGesture.ts View on Github external
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)));
    }
  }
}
github mydraft-cc / ui / src / core / utils / paper-helper.ts View on Github external
export function vec2Rectangle(vec: Vec2): paper.Rectangle {
        return new paper.Rectangle(0, 0, vec.x, vec.y);
    }