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

    A Base Curve class, which all other curve types extend.

    Based on the three.js Curve classes created by zz85

    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?

    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.strokePoints so will be drawn at whatever the present Graphics stroke 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.

      • OptionalpointsTotal: number

        The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance. Default 32.

      Returns G

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

      You can control the accuracy of the bounds. The value given is used to work out how many points to plot across the curve. Higher values are more accurate at the cost of calculation speed.

      Parameters

      • Optionalout: Geom.Rectangle

        The Rectangle to store the bounds in. If falsey a new object will be created.

      • Optionalaccuracy: number

        The accuracy of the bounds calculations. Default 16.

      Returns Geom.Rectangle

    • 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 a point at a relative position on the curve, by arc length.

      Type Parameters

      Parameters

      • u: number

        The relative position, [0..1].

      • Optionalout: O

        A point to store the result in.

      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

    • 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[]

    • Get a unit vector tangent at a relative position on the curve. In case any sub curve does not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation

      Type Parameters

      Parameters

      • t: number

        The relative position on the curve, [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