phaser/src/geom/line/GetMidPoint.js

33 lines
769 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Point = require('../point/Point');
2017-10-13 13:11:54 +00:00
/**
* [description]
*
* @function Phaser.Geom.Line.GetMidPoint
* @since 3.0.0
*
2018-03-27 13:27:08 +00:00
* @generic {Phaser.Geom.Point} O - [out,$return]
*
2017-10-13 13:11:54 +00:00
* @param {Phaser.Geom.Line} line - [description]
2018-03-20 15:01:08 +00:00
* @param {(Phaser.Geom.Point|object)} [out] - [description]
2017-10-13 13:11:54 +00:00
*
2018-03-20 15:01:08 +00:00
* @return {(Phaser.Geom.Point|object)} [description]
2017-10-13 13:11:54 +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;