-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
Decompose.js
29 lines (25 loc) · 908 Bytes
/
Decompose.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
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Decomposes a Triangle into an array of its points.
*
* @function Phaser.Geom.Triangle.Decompose
* @since 3.0.0
*
* @param {Phaser.Geom.Triangle} triangle - The Triangle to decompose.
* @param {array} [out] - An array to store the points into.
*
* @return {array} The provided `out` array, or a new array if none was provided, with three objects with `x` and `y` properties representing each point of the Triangle appended to it.
*/
var Decompose = function (triangle, out)
{
if (out === undefined) { out = []; }
out.push({ x: triangle.x1, y: triangle.y1 });
out.push({ x: triangle.x2, y: triangle.y2 });
out.push({ x: triangle.x3, y: triangle.y3 });
return out;
};
module.exports = Decompose;