Skip to content

Commit

Permalink
rename function, move it to Math class
Browse files Browse the repository at this point in the history
  • Loading branch information
GregDevProjects committed Oct 10, 2021
1 parent 1d009f8 commit e5af0a0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
29 changes: 29 additions & 0 deletions src/math/LinearXY.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @author Greg McLean <GregDevProjects>
* @copyright 2021 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/

/**
* Interpolates two given Vectors and returns a new Vector between them.
*
* Does not modify either of the passed Vectors.
*
* @method Phaser.Math.LinearXY
* @since 3.6.0
*
* @param {Phaser.Math.Vector2} vector1 - Starting vector
* @param {Phaser.Math.Vector2} vector2 - Ending vector
* @param {number} [t=0] - The percentage between vector1 and vector2 to return, represented as a number between 0 and 1.
* @return {Phaser.Math.Vector2} Value of the interpolation
*/
var LinearXY = function (vector1, vector2, t)
{
if (t === undefined)
{
t = 0;
}
return vector1.clone().lerp(vector2, t);
};

module.exports = LinearXY;
19 changes: 0 additions & 19 deletions src/math/Vector2.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,23 +767,4 @@ Vector2.DOWN = new Vector2(0, 1);
*/
Vector2.ONE = new Vector2(1, 1);

/**
* Interpolates two given Vectors and returns a new Vector.
*
* Does not modify either of the passed Vectors.
*
* @method Phaser.Math.Vector2
* @since 3.6.0
*
* @param {Phaser.Math.Vector2} vector1 - Starting vector
* @param {Phaser.Math.Vector2} vector2 - Ending vector
* @param {number} [t=0] - The interpolation percentage, between 0 and 1.
* @return {Phaser.Math.Vector2} Value of the interpolation
*/
Vector2.Lerp = function (vector1, vector2, t)
{
if (t === undefined) { t = 0; }
return vector1.clone().lerp(vector2, t);
};

module.exports = Vector2;
1 change: 1 addition & 0 deletions src/math/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var PhaserMath = {
IsEven: require('./IsEven'),
IsEvenStrict: require('./IsEvenStrict'),
Linear: require('./Linear'),
LinearXY: require('./LinearXY'),
MaxAdd: require('./MaxAdd'),
Median: require('./Median'),
MinSub: require('./MinSub'),
Expand Down

0 comments on commit e5af0a0

Please sign in to comment.