Function interpolate

Calculates a point in-between a line's start and end points.

Interpolation amount

Line, or first point

Second point (if needed) or allowOverflow.

If true, interpolation amount is permitted to exceed 0..1, extending the line.

  • Calculates a point in-between a and b.

    If an interpolation amount below 0 or above 1 is given, and allowOverflow_ is true, a point will be returned that is extended past line`. This is useful for easing functions which might briefly go past the limits.

    import { Lines } from 'https://unpkg.com/ixfx/dist/geometry.js'

    // Get {x,y} at 50% along line
    Lines.interpolate(0.5, line);

    // Get {x,y} at 80% between point A and B
    Lines.interpolate(0.8, ptA, ptB);

    Parameters

    • amount: number

      Relative position, 0 being at a, 0.5 being halfway, 1 being at b

    • a: Point

      Start

    • pointB: Point

      End

    • OptionalallowOverflow: boolean

    Returns Point

    Point between a and b

  • Calculates a point in-between line's start and end points.

    import { Lines } from 'https://unpkg.com/ixfx/dist/geometry.js'

    // Get {x, y } at 50% along line
    Lines.interpolate(0.5, line);

    Any additional properties from b are returned on the result as well.

    Parameters

    • amount: number

      0..1

    • line: Line

      Line

    • OptionalallowOverflow: boolean

      If true, interpolation amount is permitted to exceed 0..1, extending the line

    Returns Point