phaser/src/geom/triangle/Decompose.js

30 lines
934 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.
2018-02-12 16:01:20 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
2017-10-13 13:11:54 +00:00
/**
2018-10-19 11:32:43 +00:00
* Decomposes a Triangle into an array of its points.
2017-10-13 13:11:54 +00:00
*
* @function Phaser.Geom.Triangle.Decompose
* @since 3.0.0
*
2018-10-19 11:32:43 +00:00
* @param {Phaser.Geom.Triangle} triangle - The Triangle to decompose.
* @param {array} [out] - An array to store the points into.
2017-10-13 13:11:54 +00:00
*
2018-10-19 11:32:43 +00:00
* @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.
2017-10-13 13:11:54 +00:00
*/
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;