MCPcopy Create free account
hub / github.com/phaserjs/phaser / GetLineToRectangle

Function GetLineToRectangle

src/geom/intersects/GetLineToRectangle.js:25–55  ·  view source on GitHub ↗
(line, rect, out)

Source from the content-addressed store, hash-verified

23 * @return {Phaser.Math.Vector2[]} An array with the points of intersection if objects intersect, otherwise an empty array.
24 */
25var GetLineToRectangle = function (line, rect, out)
26{
27 if (out === undefined) { out = []; }
28
29 if (LineToRectangle(line, rect))
30 {
31 var lineA = rect.getLineA();
32 var lineB = rect.getLineB();
33 var lineC = rect.getLineC();
34 var lineD = rect.getLineD();
35
36 var output = [ new Vector2(), new Vector2(), new Vector2(), new Vector2() ];
37
38 var result = [
39 LineToLine(lineA, line, output[0]),
40 LineToLine(lineB, line, output[1]),
41 LineToLine(lineC, line, output[2]),
42 LineToLine(lineD, line, output[3])
43 ];
44
45 for (var i = 0; i < 4; i++)
46 {
47 if (result[i])
48 {
49 out.push(output[i]);
50 }
51 }
52 }
53
54 return out;
55};
56
57module.exports = GetLineToRectangle;

Callers 3

GetRectangleToRectangleFunction · 0.85
GetRectangleToTriangleFunction · 0.85

Calls 2

LineToRectangleFunction · 0.85
LineToLineFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…