phaser/src/geom/line/Rotate.js

31 lines
771 B
JavaScript
Raw Normal View History

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
*/
var RotateAroundXY = require('./RotateAroundXY');
2017-10-13 13:11:54 +00:00
/**
* Rotate a line around its midpoint by the given angle in radians.
2017-10-13 13:11:54 +00:00
*
* @function Phaser.Geom.Line.Rotate
* @since 3.0.0
*
2018-03-27 13:27:08 +00:00
* @generic {Phaser.Geom.Line} O - [line,$return]
*
* @param {Phaser.Geom.Line} line - The line to rotate.
* @param {number} angle - The angle of rotation in radians.
2017-10-13 13:11:54 +00:00
*
* @return {Phaser.Geom.Line} The rotated line.
2017-10-13 13:11:54 +00:00
*/
var Rotate = function (line, angle)
{
var x = (line.x1 + line.x2) / 2;
var y = (line.y1 + line.y2) / 2;
return RotateAroundXY(line, x, y, angle);
};
module.exports = Rotate;