mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Point.interpolate - Interpolates the two given Points, based on the f
value (between 0 and 1) and returns a new Point.
This commit is contained in:
parent
8dd67ea6ec
commit
6e5415fc31
2 changed files with 19 additions and 0 deletions
|
@ -112,6 +112,7 @@ Version 2.0.4 - "Mos Shirare" - in development
|
|||
* Point.projectUnit - Project two Points onto a Point of unit length.
|
||||
* Point.multiplyAdd - Adds two 2D Points together and multiplies the result by the given scalar.
|
||||
* Point.negative - Creates a negative Point.
|
||||
* Point.interpolate - Interpolates the two given Points, based on the `f` value (between 0 and 1) and returns a new Point.
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
|
|
@ -623,6 +623,24 @@ Phaser.Point.multiplyAdd = function (a, b, s, out) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Interpolates the two given Points, based on the `f` value (between 0 and 1) and returns a new Point.
|
||||
*
|
||||
* @method Phaser.Point.interpolate
|
||||
* @param {Phaser.Point} a - The first Point object.
|
||||
* @param {Phaser.Point} b - The second Point object.
|
||||
* @param {number} f - The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.
|
||||
* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
|
||||
* @return {Phaser.Point} The new Point object.
|
||||
*/
|
||||
Phaser.Point.interpolate = function (a, b, f, out) {
|
||||
|
||||
if (typeof out === "undefined") { out = new Phaser.Point(); }
|
||||
|
||||
return out.setTo(a.x + (b.x - a.x) * f, a.y + (b.y - a.y) * f);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a perpendicular vector (90 degrees rotation)
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue