figureone
    Preparing search index...

    Object representing a Line.

    Contains methods that makes it conventient to use lines in calculations.

    // get Line from Fig
    const { Line } = Fig;

    // define a line from [0, 0] to [1, 0]
    const l = new Line([0, 0], [1, 0]);

    // find the length of the line
    const len = l.length();

    // get the point at length 0.2 along the line
    const p = l.pointAtLength(0.2);

    // find the intersect with another line
    const i = l.intersectsWith([[0.5, 0.5], [0.5, -0.5]]);
    Index

    Constructors

    Methods

    • Return the distance between p1 and p2. Note, for infinite lines this will still return the distance between p1 and p2 that defines the line.

      Returns number

    • Create a line that is offset by some distance from this line.

      'left', 'right', 'top' and 'bottom' are relative to cartesian coordinates.

      'positive' to the right of a vertical line defined from bottom to top and above a horizontal line defined from right to left. Another way to think of it is if lines are used to create a polygon in the positive rotation direction (CCW), the the 'positive' side will be on the outside of the polygon.

      'negative' is then the inside of the same polygon.

      Parameters

      Returns Line

    • Create a line that is offset by some distance from this line.

      'left', 'right', 'top' and 'bottom' are relative to cartesian coordinates.

      'positive' to the right of a vertical line defined from bottom to top and above a horizontal line defined from right to left. Another way to think of it is if lines are used to create a polygon in the positive rotation direction (CCW), the the 'positive' side will be on the outside of the polygon.

      'negative' is then the inside of the same polygon.

      Parameters

      • direction: "left" | "right" | "top" | "bottom" | "positive" | "negative"
      • dist: number

      Returns Line

    • The intersection between this line and line2.

      The returned result is an Intersect object with the keys intersect, offLine and colinear.

      If no intersect exists, then intersect will be undefined.

      If an intersect exists, and the intersect is within both lines, then offLine will be true. If at least one of the lines needs to be extended to reach the intersect point, then offLine will be false.

      If the lines are collinear but do not overlap, then the intersect point will be the midpoint between the two closest ends. offLine will be true and collinear will be true.

      If the lines are collinear and overlap fully (or are equal), then the intersect will be p1 of the calling line, offLine will be false and collinear will be true.

      If either line has zero length, then an exception will be thrown.

      Parameters

      Returns OBJ_LineIntersect

    • Clip a point to be on a line.

      If point is not along line, then it will be projected onto it.

      If point is not on line, then the closest line end will be returned.

      Parameters

      Returns Point

      clipped point