phaser
Version:
A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers from the team at Phaser Studio Inc.
38 lines (32 loc) • 1.48 kB
JavaScript
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2026 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var CircumferencePoint = require('./CircumferencePoint');
var FromPercent = require('../../math/FromPercent');
var MATH_CONST = require('../../math/const');
var Vector2 = require('../../math/Vector2');
/**
* Returns a Vector2 object containing the coordinates of a point on the circumference of the Ellipse
* based on the given angle normalized to the range 0 to 1. i.e. a value of 0.5 will give the point
* at 180 degrees around the ellipse.
*
* @function Phaser.Geom.Ellipse.GetPoint
* @since 3.0.0
*
* @generic {Phaser.Math.Vector2} O - [out,$return]
*
* @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on.
* @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 degrees around the ellipse.
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the return values in. If not given a new Vector2 object will be created.
*
* @return {Phaser.Math.Vector2} A Vector2 object, containing the coordinates of the point around the ellipse.
*/
var GetPoint = function (ellipse, position, out)
{
if (out === undefined) { out = new Vector2(); }
var angle = FromPercent(position, 0, MATH_CONST.TAU);
return CircumferencePoint(ellipse, angle, out);
};
module.exports = GetPoint;