mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 05:58:30 +00:00
JSDocs added.
This commit is contained in:
parent
c22668d53d
commit
23f201660d
146 changed files with 1560 additions and 67 deletions
|
@ -5,6 +5,7 @@
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Circle} circle - The Circle to get the area of.
|
||||
*
|
||||
* @return {number} The area of the Circle.
|
||||
*/
|
||||
var Area = function (circle)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Circle} circle - The Circle to get the circumference of.
|
||||
*
|
||||
* @return {number} The circumference of the Circle.
|
||||
*/
|
||||
var Circumference = function (circle)
|
||||
|
|
|
@ -10,7 +10,8 @@ var Point = require('../point/Point');
|
|||
*
|
||||
* @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on.
|
||||
* @param {number} angle - [description]
|
||||
* @param {Phaser.Geom.Point|object} out - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var CircumferencePoint = function (circle, angle, out)
|
||||
|
|
|
@ -7,6 +7,7 @@ var Circle = require('./Circle');
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Circle} source - The Circle to be cloned.
|
||||
*
|
||||
* @return {Phaser.Geom.Circle} A clone of the source Circle.
|
||||
*/
|
||||
var Clone = function (source)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var Contains = function (circle, x, y)
|
||||
|
|
|
@ -8,6 +8,7 @@ var Contains = require('./Contains');
|
|||
*
|
||||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {Phaser.Geom.Point|object} point - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var ContainsPoint = function (circle, point)
|
||||
|
|
|
@ -8,6 +8,7 @@ var Contains = require('./Contains');
|
|||
*
|
||||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {Phaser.Geom.Rectangle|object} rect - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var ContainsRect = function (circle, rect)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* @param {Phaser.Geom.Circle} source - The source Circle to copy the values from.
|
||||
* @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values in to.
|
||||
*
|
||||
* @return {Phaser.Geom.Circle} The dest Circle.
|
||||
*/
|
||||
var CopyFrom = function (source, dest)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* @param {Phaser.Geom.Circle} circle - The first Circle to compare.
|
||||
* @param {Phaser.Geom.Circle} toCompare - The second Circle to compare.
|
||||
*
|
||||
* @return {boolean} `true` if the two Circles equal each other, otherwise `false`.
|
||||
*/
|
||||
var Equals = function (circle, toCompare)
|
||||
|
|
|
@ -8,6 +8,7 @@ var Rectangle = require('../rectangle/Rectangle');
|
|||
*
|
||||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {Phaser.Geom.Rectangle|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle|object} [description]
|
||||
*/
|
||||
var GetBounds = function (circle, out)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Circle} [description]
|
||||
*/
|
||||
var Offset = function (circle, x, y)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*
|
||||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {Phaser.Geom.Point|object} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Circle} [description]
|
||||
*/
|
||||
var OffsetPoint = function (circle, point)
|
||||
|
|
|
@ -8,6 +8,7 @@ var Point = require('../point/Point');
|
|||
*
|
||||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var Random = function (circle, out)
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.Area
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Area = function (ellipse)
|
||||
{
|
||||
if (ellipse.isEmpty())
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
var Point = require('../point/Point');
|
||||
|
||||
/**
|
||||
* Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle.
|
||||
*/
|
||||
* Given an angle this will returna Point object containing the coordinates of the point
|
||||
* on the circumference of the ellipse.
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.CircumferencePoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {float} angle - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var CircumferencePoint = function (ellipse, angle, out)
|
||||
{
|
||||
if (out === undefined) { out = { x: 0, y: 0 }; }
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
||||
var a = ellipse.width / 2;
|
||||
var b = ellipse.height / 2;
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
var Ellipse = require('./Ellipse');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.Clone
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} source - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Ellipse} [description]
|
||||
*/
|
||||
var Clone = function (source)
|
||||
{
|
||||
return new Ellipse(source.x, source.y, source.width, source.height);
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.Contains
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var Contains = function (ellipse, x, y)
|
||||
{
|
||||
if (ellipse.width <= 0 || ellipse.height <= 0)
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Contains = require('./Contains');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.ContainsPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {Phaser.Geom.Point|object} point - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var ContainsPoint = function (ellipse, point)
|
||||
{
|
||||
return Contains(ellipse, point.x, point.y);
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Contains = require('./Contains');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.ContainsRect
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {Phaser.Geom.Rectangle|object} rect - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var ContainsRect = function (ellipse, rect)
|
||||
{
|
||||
return (
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.CopyFrom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} source - [description]
|
||||
* @param {Phaser.Geom.Ellipse} dest - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Ellipse} [description]
|
||||
*/
|
||||
var CopyFrom = function (source, dest)
|
||||
{
|
||||
return dest.setTo(source.x, source.y, source.width, source.height);
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.Equals
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {Phaser.Geom.Ellipse} toCompare - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var Equals = function (ellipse, toCompare)
|
||||
{
|
||||
return (
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Rectangle = require('../rectangle/Rectangle');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.GetBounds
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {Phaser.Geom.Rectangle|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle} [description]
|
||||
*/
|
||||
var GetBounds = function (ellipse, out)
|
||||
{
|
||||
if (out === undefined) { out = new Rectangle(); }
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.Offset
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Ellipse} [description]
|
||||
*/
|
||||
var Offset = function (ellipse, x, y)
|
||||
{
|
||||
ellipse.x += x;
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.OffsetPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {Phaser.Geom.Point|object} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Ellipse} [description]
|
||||
*/
|
||||
var OffsetPoint = function (ellipse, point)
|
||||
{
|
||||
ellipse.x += point.x;
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Point = require('../point/Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Ellipse.Random
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Ellipse} ellipse - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var Random = function (ellipse, out)
|
||||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var DistanceBetween = require('../../math/distance/DistanceBetween');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.CircleToCircle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Circle} circleA - [description]
|
||||
* @param {Phaser.Geom.Circle} circleB - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var CircleToCircle = function (circleA, circleB)
|
||||
{
|
||||
return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius));
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.CircleToRectangle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {Phaser.Geom.Rectangle} rect - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var CircleToRectangle = function (circle, rect)
|
||||
{
|
||||
var halfWidth = rect.width / 2;
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
var Rectangle = require('../rectangle/Rectangle');
|
||||
var RectangleToRectangle = require('./RectangleToRectangle');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.GetRectangleIntersection
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rectA - [description]
|
||||
* @param {Phaser.Geom.Rectangle} rectB - [description]
|
||||
* @param {Phaser.Geom.Rectangle} [output] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle} [description]
|
||||
*/
|
||||
var GetRectangleIntersection = function (rectA, rectB, output)
|
||||
{
|
||||
if (output === undefined) { output = new Rectangle(); }
|
||||
|
|
|
@ -2,9 +2,22 @@
|
|||
// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md
|
||||
|
||||
var Contains = require('../circle/Contains');
|
||||
var Point = require('../point/Point');
|
||||
|
||||
var tmp = { x: 0, y: 0 };
|
||||
var tmp = new Point();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.LineToCircle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
* @param {Phaser.Geom.Point} [nearest] - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var LineToCircle = function (line, circle, nearest)
|
||||
{
|
||||
if (nearest === undefined) { nearest = tmp; }
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
var Point = require('../point/Point');
|
||||
|
||||
// This is based off an explanation and expanded math presented by Paul Bourke:
|
||||
// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.LineToLine
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line1 - [description]
|
||||
* @param {Phaser.Geom.Line} line2 - [description]
|
||||
* @param {Phaser.Geom.Point} [out] - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var LineToLine = function (line1, line2, out)
|
||||
{
|
||||
if (out === undefined) { out = { x: 0, y: 0 }; }
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
||||
var x1 = line1.x1;
|
||||
var y1 = line1.y1;
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
/**
|
||||
* Checks for intersection between the Line and a Rectangle shape, or a rectangle-like
|
||||
* object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body.
|
||||
*
|
||||
* An intersection is considered valid if:
|
||||
*
|
||||
* The line starts within, or ends within, the Rectangle.
|
||||
* The line segment intersects one of the 4 rectangle edges.
|
||||
*
|
||||
* The for the purposes of this function rectangles are considered 'solid'.
|
||||
*/
|
||||
* Checks for intersection between the Line and a Rectangle shape, or a rectangle-like
|
||||
* object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body.
|
||||
*
|
||||
* An intersection is considered valid if:
|
||||
*
|
||||
* The line starts within, or ends within, the Rectangle.
|
||||
* The line segment intersects one of the 4 rectangle edges.
|
||||
*
|
||||
* The for the purposes of this function rectangles are considered 'solid'.
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.LineToRectangle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {Phaser.Geom.Rectangle|object} rect - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var LineToRectangle = function (line, rect)
|
||||
{
|
||||
var x1 = line.x1;
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.PointToLine
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var PointToLine = function (point, line)
|
||||
{
|
||||
return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1));
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var PointToLine = require('./PointToLine');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.PointToLineSegment
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var PointToLineSegment = function (point, line)
|
||||
{
|
||||
if (!PointToLine(point, line))
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.RectangleToRectangle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rectA - [description]
|
||||
* @param {Phaser.Geom.Rectangle} rectB - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var RectangleToRectangle = function (rectA, rectB)
|
||||
{
|
||||
if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0)
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
|
||||
var LineToLine = require('./LineToLine');
|
||||
var Contains = require('../rectangle/Contains');
|
||||
var ContainsArray = require('../triangle/ContainsArray');
|
||||
var Decompose = require('../rectangle/Decompose');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.RectangleToTriangle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rect - [description]
|
||||
* @param {Phaser.Geom.Triangle} triangle - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var RectangleToTriangle = function (rect, triangle)
|
||||
{
|
||||
// First the cheapest ones:
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.RectangleToValues
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rect - [description]
|
||||
* @param {number} left - [description]
|
||||
* @param {number} right - [description]
|
||||
* @param {number} top - [description]
|
||||
* @param {number} bottom - [description]
|
||||
* @param {float} [tolerance=0] - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var RectangleToValues = function (rect, left, right, top, bottom, tolerance)
|
||||
{
|
||||
if (tolerance === undefined) { tolerance = 0; }
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
|
||||
var LineToCircle = require('./LineToCircle');
|
||||
var Contains = require('../triangle/Contains');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.TriangleToCircle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Triangle} triangle - [description]
|
||||
* @param {Phaser.Geom.Circle} circle - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var TriangleToCircle = function (triangle, circle)
|
||||
{
|
||||
// First the cheapest ones:
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
|
||||
var LineToLine = require('./LineToLine');
|
||||
var Contains = require('../triangle/Contains');
|
||||
var LineToLine = require('./LineToLine');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.TriangleToLine
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Triangle} triangle - [description]
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var TriangleToLine = function (triangle, line)
|
||||
{
|
||||
// If the Triangle contains either the start or end point of the line, it intersects
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
|
||||
var LineToLine = require('./LineToLine');
|
||||
var ContainsArray = require('../triangle/ContainsArray');
|
||||
var Decompose = require('../triangle/Decompose');
|
||||
var LineToLine = require('./LineToLine');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Intersects.TriangleToTriangle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Triangle} triangleA - [description]
|
||||
* @param {Phaser.Geom.Triangle} triangleB - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var TriangleToTriangle = function (triangleA, triangleB)
|
||||
{
|
||||
// First the cheapest ones:
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Angle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Angle = function (line)
|
||||
{
|
||||
return Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.CenterOn
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Line} [description]
|
||||
*/
|
||||
var CenterOn = function (line, x, y)
|
||||
{
|
||||
var tx = x - ((line.x1 + line.x2) / 2);
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
var Line = require('./Line');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Clone
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} source - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Line} [description]
|
||||
*/
|
||||
var Clone = function (source)
|
||||
{
|
||||
return new Line(source.x1, source.y1, source.x2, source.y2);
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.CopyFrom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} source - [description]
|
||||
* @param {Phaser.Geom.Line} dest - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Line} [description]
|
||||
*/
|
||||
var CopyFrom = function (source, dest)
|
||||
{
|
||||
return dest.setTo(source.x1, source.y1, source.x2, source.y2);
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Equals
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {Phaser.Geom.Line} toCompare - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var Equals = function (line, toCompare)
|
||||
{
|
||||
return (
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Point = require('../point/Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.GetMidPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var GetMidPoint = function (line, out)
|
||||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
|
|
@ -2,6 +2,17 @@ var MATH_CONST = require('../../math/const');
|
|||
var Angle = require('./Angle');
|
||||
var Point = require('../point/Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.GetNormal
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var GetNormal = function (line, out)
|
||||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
|
|
@ -1,12 +1,28 @@
|
|||
var Point = require('../point/Point');
|
||||
|
||||
// Get a point on the given line 'progress' percentage along its length.
|
||||
// progress is a value between 0 and 1.
|
||||
|
||||
var GetPoint = function (line, progress)
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.GetPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {float} progress - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var GetPoint = function (line, progress, out)
|
||||
{
|
||||
var x = line.x1 + (line.x2 - line.x1) * progress;
|
||||
var y = line.y1 + (line.y2 - line.y1) * progress;
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
||||
return { x: x, y: y };
|
||||
out.x = line.x1 + (line.x2 - line.x1) * progress;
|
||||
out.y = line.y1 + (line.y2 - line.y1) * progress;
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
module.exports = GetPoint;
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
/**
|
||||
* Using Bresenham's line algorithm this will return an array of all coordinates on this line.
|
||||
* The start and end points are rounded before this runs as the algorithm works on integers.
|
||||
*/
|
||||
* Using Bresenham's line algorithm this will return an array of all coordinates on this line.
|
||||
* The start and end points are rounded before this runs as the algorithm works on integers.
|
||||
*
|
||||
* @function Phaser.Geom.Line.GetPointsOnLine
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {integer} [stepRate=1] - [description]
|
||||
* @param {array} [results] - [description]
|
||||
*
|
||||
* @return {array} [description]
|
||||
*/
|
||||
var GetPointsOnLine = function (line, stepRate, results)
|
||||
{
|
||||
if (stepRate === undefined) { stepRate = 1; }
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Height
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Height = function (line)
|
||||
{
|
||||
return Math.abs(line.y1 - line.y2);
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Length
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Length = function (line)
|
||||
{
|
||||
return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1));
|
||||
|
|
|
@ -2,6 +2,16 @@ var MATH_CONST = require('../../math/const');
|
|||
var Wrap = require('../../math/Wrap');
|
||||
var Angle = require('./Angle');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.NormalAngle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var NormalAngle = function (line)
|
||||
{
|
||||
var angle = Angle(line) - MATH_CONST.TAU;
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
var MATH_CONST = require('../../math/const');
|
||||
var Angle = require('./Angle');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.NormalX
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var NormalX = function (line)
|
||||
{
|
||||
return Math.cos(Angle(line) - MATH_CONST.TAU);
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
var MATH_CONST = require('../../math/const');
|
||||
var Angle = require('./Angle');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.NormalY
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var NormalY = function (line)
|
||||
{
|
||||
return Math.sin(Angle(line) - MATH_CONST.TAU);
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Offset
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Line} [description]
|
||||
*/
|
||||
var Offset = function (line, x, y)
|
||||
{
|
||||
line.x1 += x;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.PerpSlope
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var PerpSlope = function (line)
|
||||
{
|
||||
return -((line.x2 - line.x1) / (line.y2 - line.y1));
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Point = require('../point/Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Random
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var Random = function (line, out)
|
||||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
|
|
@ -5,6 +5,17 @@ var NormalAngle = require('./NormalAngle');
|
|||
* Returns the reflected angle between two lines.
|
||||
* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2.
|
||||
*/
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.ReflectAngle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} lineA - [description]
|
||||
* @param {Phaser.Geom.Line} lineB - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var ReflectAngle = function (lineA, lineB)
|
||||
{
|
||||
return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA));
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var RotateAroundXY = require('./RotateAroundXY');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Rotate
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {number} angle - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Line} [description]
|
||||
*/
|
||||
var Rotate = function (line, angle)
|
||||
{
|
||||
var x = (line.x1 + line.x2) / 2;
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
var RotateAroundXY = require('./RotateAroundXY');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.RotateAroundPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {Phaser.Geom.Point|object} point - [description]
|
||||
* @param {number} angle - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Line} [description]
|
||||
*/
|
||||
var RotateAroundPoint = function (line, point, angle)
|
||||
{
|
||||
return RotateAroundXY(line, point.x, point.y, angle);
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.RotateAroundXY
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {number} angle - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Line} [description]
|
||||
*/
|
||||
var RotateAroundXY = function (line, x, y, angle)
|
||||
{
|
||||
var c = Math.cos(angle);
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.SetToAngle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {number} angle - [description]
|
||||
* @param {number} length - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Line} [description]
|
||||
*/
|
||||
var SetToAngle = function (line, x, y, angle, length)
|
||||
{
|
||||
line.x1 = x;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Slope
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Slope = function (line)
|
||||
{
|
||||
return (line.y2 - line.y1) / (line.x2 - line.x1);
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Line.Width
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Line} line - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Width = function (line)
|
||||
{
|
||||
return Math.abs(line.x1 - line.x2);
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Add
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Add = function (point, x, y)
|
||||
{
|
||||
point.x += x;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Ceil
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Ceil = function (point)
|
||||
{
|
||||
return point.setTo(Math.ceil(point.x), Math.ceil(point.y));
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
var Point = require('./Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Clone
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} source - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Clone = function (source)
|
||||
{
|
||||
return new Point(source.x, source.y);
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
/**
|
||||
* Copies the x, y and diameter properties from any given object to this Circle.
|
||||
* @method Phaser.Circle#copyFrom
|
||||
* @param {any} source - The object to copy from.
|
||||
* @return {Circle} This Circle object.
|
||||
*/
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.CopyFrom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} source - [description]
|
||||
* @param {Phaser.Geom.Point} dest - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var CopyFrom = function (source, dest)
|
||||
{
|
||||
return dest.setTo(source.x, source.y);
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Cross
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} pointA - [description]
|
||||
* @param {Phaser.Geom.Point} pointB - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Cross = function (pointA, pointB)
|
||||
{
|
||||
return ((pointA.x * pointB.y) - (pointA.y * pointB.x));
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Divide
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Divide = function (point, x, y)
|
||||
{
|
||||
point.x /= x;
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Dot
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} pointA - [description]
|
||||
* @param {Phaser.Geom.Point} pointB - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Dot = function (pointA, pointB)
|
||||
{
|
||||
return ((pointA.x * pointB.x) + (pointA.y * pointB.y));
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Equals
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {Phaser.Geom.Point} toCompare - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var Equals = function (point, toCompare)
|
||||
{
|
||||
return (point.x === toCompare.x && point.y === toCompare.y);
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Floor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Floor = function (point)
|
||||
{
|
||||
return point.setTo(Math.floor(point.x), Math.floor(point.y));
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Point = require('./Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.GetCentroid
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point[]} points - [description]
|
||||
* @param {Phaser.Geom.Point} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var GetCentroid = function (points, out)
|
||||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.GetMagnitude
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var GetMagnitude = function (point)
|
||||
{
|
||||
return Math.sqrt((point.x * point.x) + (point.y * point.y));
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.GetMagnitudeSq
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var GetMagnitudeSq = function (point)
|
||||
{
|
||||
return (point.x * point.x) + (point.y * point.y);
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
var Rectangle = require('../rectangle/Rectangle');
|
||||
|
||||
// Calculates the Axis Aligned Bounding Box (or aabb) from an array of points.
|
||||
|
||||
/**
|
||||
* Calculates the Axis Aligned Bounding Box (or aabb) from an array of points.
|
||||
*/
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.GetRectangleFromPoints
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point[]} points - [description]
|
||||
* @param {Phaser.Geom.Rectangle} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle} [description]
|
||||
*/
|
||||
var GetRectangleFromPoints = function (points, out)
|
||||
{
|
||||
if (out === undefined) { out = new Rectangle(); }
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
var Point = require('./Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Interpolate
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} pointA - [description]
|
||||
* @param {Phaser.Geom.Point} pointB - [description]
|
||||
* @param {float} [t=0] - [description]
|
||||
* @param {Phaser.Geom.Point|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point|object} [description]
|
||||
*/
|
||||
var Interpolate = function (pointA, pointB, t, out)
|
||||
{
|
||||
if (t === undefined) { t = 0; }
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Invert
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Invert = function (point)
|
||||
{
|
||||
return point.setTo(point.y, point.x);
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Multiply
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Multiply = function (point, x, y)
|
||||
{
|
||||
point.x *= x;
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Point = require('./Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Negative
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {Phaser.Geom.Point} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Negative = function (point, out)
|
||||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
var GetMagnitude = require('./GetMagnitude');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Normalize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Normalize = function (point)
|
||||
{
|
||||
if (point.x !== 0 && point.y !== 0)
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.NormalizeRightHand
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var NormalizeRightHand = function (point)
|
||||
{
|
||||
return point.setTo(point.y * -1, point.x);
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Perp
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Perp = function (point)
|
||||
{
|
||||
return point.setTo(-point.y, point.x);
|
||||
|
|
|
@ -2,6 +2,18 @@ var Dot = require('./Dot');
|
|||
var Point = require('./Point');
|
||||
var GetMagnitudeSq = require('./GetMagnitudeSq');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Project
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} pointA - [description]
|
||||
* @param {Phaser.Geom.Point} pointB - [description]
|
||||
* @param {Phaser.Geom.Point} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Project = function (pointA, pointB, out)
|
||||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
var Dot = require('./Dot');
|
||||
var Point = require('./Point');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.ProjectUnit
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} pointA - [description]
|
||||
* @param {Phaser.Geom.Point} pointB - [description]
|
||||
* @param {Phaser.Geom.Point} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var ProjectUnit = function (pointA, pointB, out)
|
||||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.RPerp
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var RPerp = function (point)
|
||||
{
|
||||
return point.setTo(point.y, -point.x);
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
var Normalize = require('./Normalize');
|
||||
var Multiply = require('./Multiply');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.SetMagnitude
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {number} magnitude - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var SetMagnitude = function (point, magnitude)
|
||||
{
|
||||
Normalize(point);
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Point.Subtract
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Point} [description]
|
||||
*/
|
||||
var Subtract = function (point, x, y)
|
||||
{
|
||||
point.x -= x;
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
var Polygon = require('./Polygon');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Polygon.Clone
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Polygon} polygon - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Polygon} [description]
|
||||
*/
|
||||
var Clone = function (polygon)
|
||||
{
|
||||
return new Polygon(polygon.points);
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
// Checks whether the x and y coordinates are contained within this polygon.
|
||||
// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva
|
||||
|
||||
/**
|
||||
* Checks whether the x and y coordinates are contained within this polygon.
|
||||
*/
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Polygon.Contains
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Polygon} polygon - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var Contains = function (polygon, x, y)
|
||||
{
|
||||
// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva
|
||||
|
||||
var inside = false;
|
||||
|
||||
for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i)
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
var Contains = require('./Contains');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Polygon.ContainsPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Polygon} polygon - [description]
|
||||
* @param {Phaser.Geom.Point} point - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var ContainsPoint = function (polygon, point)
|
||||
{
|
||||
return Contains(polygon, point.x, point.y);
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
var Rectangle = require('../rectangle/Rectangle');
|
||||
|
||||
var GetAABB = function (polygon)
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Polygon.GetAABB
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Polygon} polygon - [description]
|
||||
* @param {Phaser.Geom.Rectangle|object} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle|object} [description]
|
||||
*/
|
||||
var GetAABB = function (polygon, out)
|
||||
{
|
||||
if (out === undefined) { out = new Rectangle(); }
|
||||
|
||||
var minX = Infinity;
|
||||
var minY = Infinity;
|
||||
var maxX = -minX;
|
||||
|
@ -17,12 +31,12 @@ var GetAABB = function (polygon)
|
|||
maxY = Math.max(maxY, p.y);
|
||||
}
|
||||
|
||||
return {
|
||||
x: minX,
|
||||
y: minY,
|
||||
width: maxX - minX,
|
||||
height: maxY - minY
|
||||
};
|
||||
out.x = minX;
|
||||
out.y = minY;
|
||||
out.width = maxX - minX;
|
||||
out.height = maxY - minY;
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
module.exports = GetAABB;
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ]
|
||||
|
||||
/**
|
||||
* Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ]
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Polygon.GetNumberArray
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Polygon} polygon - [description]
|
||||
* @param {array} [output] - [description]
|
||||
*
|
||||
* @return {number[]} [description]
|
||||
*/
|
||||
var GetNumberArray = function (polygon, output)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Polygon.Reverse
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Polygon} polygon - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Polygon} [description]
|
||||
*/
|
||||
var Reverse = function (polygon)
|
||||
{
|
||||
polygon.points.reverse();
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Rectangle.Area
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rect - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var Area = function (rect)
|
||||
{
|
||||
return rect.width * rect.height;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Rectangle.Ceil
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rect - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle} [description]
|
||||
*/
|
||||
var Ceil = function (rect)
|
||||
{
|
||||
rect.x = Math.ceil(rect.x);
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Rectangle.CeilAll
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rect - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle} [description]
|
||||
*/
|
||||
var CeilAll = function (rect)
|
||||
{
|
||||
rect.x = Math.ceil(rect.x);
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
// Centers this Rectangle so that the center coordinates match the given x and y values.
|
||||
|
||||
/**
|
||||
* Centers this Rectangle so that the center coordinates match the given x and y values.
|
||||
*/
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Rectangle.CenterOn
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rect - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle} [description]
|
||||
*/
|
||||
var CenterOn = function (rect, x, y)
|
||||
{
|
||||
rect.x = x - (rect.width / 2);
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
var Rectangle = require('./Rectangle');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Rectangle.Clone
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} source - [description]
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle} [description]
|
||||
*/
|
||||
var Clone = function (source)
|
||||
{
|
||||
return new Rectangle(source.x, source.y, source.width, source.height);
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Geom.Rectangle.Contains
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} rect - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
var Contains = function (rect, x, y)
|
||||
{
|
||||
if (rect.width <= 0 || rect.height <= 0)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue