phaser - v4.0.0-rc.4
    Preparing search index...

    A LineCurve is a "curve" comprising exactly two points (a line segment).

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    active: boolean

    For a curve on a Path, false means the Path will ignore this curve.

    arcLengthDivisions: number

    The quantity of arc length divisions within the curve.

    cacheArcLengths: number[]

    An array of cached arc length values.

    defaultDivisions: number

    The default number of divisions within the curve.

    needsUpdate: boolean

    Does the data of this curve need updating?

    The first endpoint.

    The second endpoint.

    type: string

    String based identifier for the type of curve.

    Methods

    • Draws this curve on the given Graphics object.

      The curve is drawn using Graphics.lineBetween so will be drawn at whatever the present Graphics line color is. The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it.

      Type Parameters

      Parameters

      • graphics: G

        The Graphics instance onto which this curve will be drawn.

      Returns G

    • Returns a Rectangle where the position and dimensions match the bounds of this Curve.

      Type Parameters

      Parameters

      • Optionalout: O

        A Rectangle object to store the bounds in. If not given a new Rectangle will be created.

      Returns O

    • Returns an array of points, spaced out X distance pixels apart. The smaller the distance, the larger the array will be.

      Parameters

      • distance: number

        The distance, in pixels, between each point along the curve.

      Returns Math.Vector2[]

    • Get a list of cumulative segment lengths.

      These lengths are

      • [0] 0
      • [1] The first segment
      • [2] The first and second segment
      • ...
      • [divisions] All segments

      Parameters

      • Optionaldivisions: number

        The number of divisions or segments.

      Returns number[]

    • Get point at relative position in curve according to length.

      Type Parameters

      Parameters

      • t: number

        The position along the curve to return. Where 0 is the start and 1 is the end.

      • Optionalout: O

        A Vector2 object to store the result in. If not given will be created.

      Returns O

    • Gets a point at a given position on the line.

      Type Parameters

      Parameters

      • u: number

        The position along the curve to return. Where 0 is the start and 1 is the end.

      • Optionalout: O

        A Vector2 object to store the result in. If not given will be created.

      Returns O

    • Get a sequence of evenly spaced points from the curve.

      You can pass divisions, stepRate, or neither.

      The number of divisions will be

      1. divisions, if divisions > 0; or
      2. this.getLength / stepRate, if stepRate > 0; or
      3. this.defaultDivisions

      1 + divisions points will be returned.

      Type Parameters

      Parameters

      • Optionaldivisions: number

        The number of divisions to make.

      • OptionalstepRate: number

        The curve distance between points, implying divisions.

      • Optionalout: O

        An optional array to store the points in.

      Returns O

    • Gets the resolution of the line.

      Parameters

      • Optionaldivisions: number

        The number of divisions to consider. Default 1.

      Returns number

    • Get a sequence of equally spaced points (by arc distance) from the curve.

      1 + divisions points will be returned.

      Parameters

      • Optionaldivisions: number

        The number of divisions to make. Default this.defaultDivisions.

      • OptionalstepRate: number

        Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.

      • Optionalout: Math.Vector2[]

        An optional array to store the points in.

      Returns Math.Vector2[]

    • Gets the slope of the line as a unit vector.

      Type Parameters

      Parameters

      • Optionalt: number

        The relative position on the line, [0..1].

      • Optionalout: O

        A vector to store the result in.

      Returns O

    • Get a unit vector tangent at a relative position on the curve, by arc length.

      Type Parameters

      Parameters

      • u: number

        The relative position on the curve, [0..1].

      • Optionalout: O

        A vector to store the result in.

      Returns O

    • Given a distance in pixels, get a t to find p.

      Parameters

      • distance: number

        The distance, in pixels.

      • Optionaldivisions: number

        Optional amount of divisions.

      Returns number

    • Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant.

      Parameters

      • u: number

        A float between 0 and 1.

      • distance: number

        The distance, in pixels.

      • Optionaldivisions: number

        Optional amount of divisions.

      Returns number