2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2017-01-04 23:53:27 +00:00
|
|
|
var Point = require('../point/Point');
|
|
|
|
|
2017-10-13 13:11:54 +00:00
|
|
|
/**
|
2018-06-21 17:13:46 +00:00
|
|
|
* Get the midpoint of the given line.
|
2017-10-13 13:11:54 +00:00
|
|
|
*
|
|
|
|
* @function Phaser.Geom.Line.GetMidPoint
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-27 13:27:08 +00:00
|
|
|
* @generic {Phaser.Geom.Point} O - [out,$return]
|
|
|
|
*
|
2018-06-21 17:13:46 +00:00
|
|
|
* @param {Phaser.Geom.Line} line - The line to get the midpoint of.
|
|
|
|
* @param {(Phaser.Geom.Point|object)} [out] - An optional point object to store the midpoint in.
|
2017-10-13 13:11:54 +00:00
|
|
|
*
|
2018-06-21 17:13:46 +00:00
|
|
|
* @return {(Phaser.Geom.Point|object)} The midpoint of the Line.
|
2017-10-13 13:11:54 +00:00
|
|
|
*/
|
2017-01-04 23:53:27 +00:00
|
|
|
var GetMidPoint = function (line, out)
|
|
|
|
{
|
|
|
|
if (out === undefined) { out = new Point(); }
|
|
|
|
|
|
|
|
out.x = (line.x1 + line.x2) / 2;
|
|
|
|
out.y = (line.y1 + line.y2) / 2;
|
|
|
|
|
|
|
|
return out;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = GetMidPoint;
|