Function fromPivot

Creates a line from an origin point.

// Line of length 0.2 with middle at 0.5,0.5
fromPivot({ x:0.5, y:0.5 }, 0.2);
// Same line, but on an angle
fromPivot({ x:0.5, y:0.5 }, 0.2, degreesToRadian(45));

// ...now with pivot point at 20%, rather than center
fromPivot({ x:0.5, y:0.5 }, 0.2, degreesToRadian(45), 0.2);

Examples:

  • Angle of 0 (deg/rad) results in a horizontal line,
  • Angle of 90deg in a vertical line.
  • Angle of 45deg will be angled downwards.
  • Parameters

    • origin: Point = ...

      Origin to pivot around

    • length: number = 1

      Total length of line

    • angleRadian: number = 0

      Angle of line, in radians

    • balance: number = 0.5

      Percentage of where origin ought to be on line. Default: 0.5, meaning the middle of line

    Returns Readonly<{
        a: Point;
        b: Point;
    }>