-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
SetToAngle.js
34 lines (30 loc) · 934 Bytes
/
SetToAngle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Set a line to a given position, angle and length.
*
* @function Phaser.Geom.Line.SetToAngle
* @since 3.0.0
*
* @generic {Phaser.Geom.Line} O - [line,$return]
*
* @param {Phaser.Geom.Line} line - The line to set.
* @param {number} x - The horizontal start position of the line.
* @param {number} y - The vertical start position of the line.
* @param {number} angle - The angle of the line in radians.
* @param {number} length - The length of the line.
*
* @return {Phaser.Geom.Line} The updated line.
*/
var SetToAngle = function (line, x, y, angle, length)
{
line.x1 = x;
line.y1 = y;
line.x2 = x + (Math.cos(angle) * length);
line.y2 = y + (Math.sin(angle) * length);
return line;
};
module.exports = SetToAngle;