-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
Decompose.js
31 lines (27 loc) · 1016 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
30
31
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Create an array of points for each corner of a Rectangle
* If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created.
*
* @function Phaser.Geom.Rectangle.Decompose
* @since 3.0.0
*
* @param {Phaser.Geom.Rectangle} rect - The Rectangle object to be decomposed.
* @param {array} [out] - If provided, each point will be added to this array.
*
* @return {array} Will return the array you specified or a new array containing the points of the Rectangle.
*/
var Decompose = function (rect, out)
{
if (out === undefined) { out = []; }
out.push({ x: rect.x, y: rect.y });
out.push({ x: rect.right, y: rect.y });
out.push({ x: rect.right, y: rect.bottom });
out.push({ x: rect.x, y: rect.bottom });
return out;
};
module.exports = Decompose;