How to use the paper.Segment 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 / pages / editor / scripts / paper / gesture / hover / HoverSegmentsCurvesGesture.ts View on Github external
segment1: { point: p1, handleIn: in1, handleOut: out1 },
        segment2: { point: p2, handleIn: in2, handleOut: out2 },
      });
      return;
    }

    // Draw an 'extend path' preview curve if one of its end points
    // is selected and the path is still open.
    const singleSelectedSegmentIndex = this.findSingleSelectedEndSegmentIndex(editPath);
    if (singleSelectedSegmentIndex !== undefined) {
      this.ps.setCursorType(CursorType.PenAdd);
      const vpStartSegment = this.localToVpSegment(
        editPath,
        editPath.segments[singleSelectedSegmentIndex],
      );
      const vpEndSegment = new paper.Segment(this.pl.globalToLocal(event.point));
      const { pathData } = new paper.Path([vpStartSegment, vpEndSegment]);
      this.ps.setCreatePathInfo({
        pathData,
        strokeColor: '#979797',
      });
    }
  }
github alexjlockwood / ShapeShifter / src / app / pages / editor / scripts / paper / item / PaperLayer.ts View on Github external
function newSplitCurveItem(info: SplitCurveInfo, cssScaling: number) {
  const group = new paper.Group();
  group.guide = true;

  const { splitPoint, segment1, segment2 } = info;
  const point1 = new paper.Point(segment1.point);
  const handleIn1 = new paper.Point(segment1.handleIn);
  const handleOut1 = new paper.Point(segment1.handleOut);
  const point2 = new paper.Point(segment2.point);
  const handleIn2 = new paper.Point(segment2.handleIn);
  const handleOut2 = new paper.Point(segment2.handleOut);
  const highlightedCurve = new paper.Path([
    new paper.Segment(point1, handleIn1, handleOut1),
    new paper.Segment(point2, handleIn2, handleOut2),
  ]);
  highlightedCurve.guide = true;
  highlightedCurve.strokeColor = '#3466A9';
  highlightedCurve.strokeScaling = false;
  highlightedCurve.strokeWidth = 2 / paper.view.zoom;
  group.addChild(highlightedCurve);

  const highlightedPoint = new paper.Path.Circle(
    new paper.Point(splitPoint),
    4 / paper.view.zoom / cssScaling,
  );
  highlightedPoint.guide = true;
  highlightedPoint.fillColor = '#3466A9';
  group.addChild(highlightedPoint);
github alexjlockwood / ShapeShifter / src / app / pages / editor / scripts / paper / gesture / hover / HoverSegmentsCurvesGesture.ts View on Github external
private localToVpSegment(localItem: paper.Item, localSegment: paper.Segment) {
    return new paper.Segment(
      this.localToVpPoint(localItem, localSegment.point),
      this.localToVpHandle(localItem, localSegment.point, localSegment.handleIn),
      this.localToVpHandle(localItem, localSegment.point, localSegment.handleOut),
    );
  }
github alexjlockwood / ShapeShifter / src / app / modules / editor / scripts / paper / item / PaperLayer.ts View on Github external
function newSplitCurveItem(info: SplitCurveInfo, cssScaling: number) {
  const group = new paper.Group();
  group.guide = true;

  const { splitPoint, segment1, segment2 } = info;
  const point1 = new paper.Point(segment1.point);
  const handleIn1 = new paper.Point(segment1.handleIn);
  const handleOut1 = new paper.Point(segment1.handleOut);
  const point2 = new paper.Point(segment2.point);
  const handleIn2 = new paper.Point(segment2.handleIn);
  const handleOut2 = new paper.Point(segment2.handleOut);
  const highlightedCurve = new paper.Path([
    new paper.Segment(point1, handleIn1, handleOut1),
    new paper.Segment(point2, handleIn2, handleOut2),
  ]);
  highlightedCurve.guide = true;
  highlightedCurve.strokeColor = '#3466A9';
  highlightedCurve.strokeScaling = false;
  highlightedCurve.strokeWidth = 2 / paper.view.zoom;
  group.addChild(highlightedCurve);

  const highlightedPoint = new paper.Path.Circle(
    new paper.Point(splitPoint),
    4 / paper.view.zoom / cssScaling,
  );
  highlightedPoint.guide = true;
  highlightedPoint.fillColor = '#3466A9';
  group.addChild(highlightedPoint);
github fponticelli / tempo / demo / paper / src / path_simplification / app.ts View on Github external
onMouseDrag: (_, event: MouseEvent) =>
        Action.addSegment(new Segment(event.point!))
    }),
github fponticelli / tempo / demo / paper / src / path_simplification / sample.ts View on Github external
tool.onMouseDrag = (event: MouseEvent) => {
              const segment = new Segment(event.point!)
              store.process(Action.addSegment(segment))
            }
            return tool
github alexjlockwood / ShapeShifter / src / app / modules / editor / scripts / paper / gesture / hover / HoverSegmentsCurvesGesture.ts View on Github external
private localToVpSegment(localItem: paper.Item, localSegment: paper.Segment) {
    return new paper.Segment(
      this.localToVpPoint(localItem, localSegment.point),
      this.localToVpHandle(localItem, localSegment.point, localSegment.handleIn),
      this.localToVpHandle(localItem, localSegment.point, localSegment.handleOut),
    );
  }
github alexjlockwood / ShapeShifter / src / app / modules / editor / scripts / paper / item / PaperLayer.ts View on Github external
function newSplitCurveItem(info: SplitCurveInfo, cssScaling: number) {
  const group = new paper.Group();
  group.guide = true;

  const { splitPoint, segment1, segment2 } = info;
  const point1 = new paper.Point(segment1.point);
  const handleIn1 = new paper.Point(segment1.handleIn);
  const handleOut1 = new paper.Point(segment1.handleOut);
  const point2 = new paper.Point(segment2.point);
  const handleIn2 = new paper.Point(segment2.handleIn);
  const handleOut2 = new paper.Point(segment2.handleOut);
  const highlightedCurve = new paper.Path([
    new paper.Segment(point1, handleIn1, handleOut1),
    new paper.Segment(point2, handleIn2, handleOut2),
  ]);
  highlightedCurve.guide = true;
  highlightedCurve.strokeColor = '#3466A9';
  highlightedCurve.strokeScaling = false;
  highlightedCurve.strokeWidth = 2 / paper.view.zoom;
  group.addChild(highlightedCurve);

  const highlightedPoint = new paper.Path.Circle(
    new paper.Point(splitPoint),
    4 / paper.view.zoom / cssScaling,
  );
  highlightedPoint.guide = true;
  highlightedPoint.fillColor = '#3466A9';
  group.addChild(highlightedPoint);

  return group;