mirror of
https://github.com/photonstorm/phaser
synced 2025-01-05 09:48:49 +00:00
Few bug fixes for Ellipse methods.
This commit is contained in:
parent
b17744df61
commit
ca24bce499
3 changed files with 9 additions and 9 deletions
|
@ -10,8 +10,8 @@
|
||||||
*/
|
*/
|
||||||
var Circumference = function (ellipse)
|
var Circumference = function (ellipse)
|
||||||
{
|
{
|
||||||
var rx = ellipse.width;
|
var rx = ellipse.width / 2;
|
||||||
var ry = ellipse.height;
|
var ry = ellipse.height / 2;
|
||||||
var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2);
|
var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2);
|
||||||
|
|
||||||
return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h)))));
|
return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h)))));
|
||||||
|
|
|
@ -16,14 +16,14 @@ var Contains = function (ellipse, x, y)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize the coords to an ellipse with center 0,0 and a radius of 0.5
|
// Normalize the coords to an ellipse with center 0,0 and a radius of 0.5
|
||||||
var normx = ((x - ellipse.x) / ellipse.width) - 0.5;
|
var normx = ((x - ellipse.x) / ellipse.width);
|
||||||
var normy = ((y - ellipse.y) / ellipse.height) - 0.5;
|
var normy = ((y - ellipse.y) / ellipse.height);
|
||||||
|
|
||||||
normx *= normx;
|
normx *= normx;
|
||||||
normy *= normy;
|
normy *= normy;
|
||||||
|
|
||||||
return (normx + normy < 0.25);
|
return (normx + normy < 0.25);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ var GetBounds = function (ellipse, out)
|
||||||
{
|
{
|
||||||
if (out === undefined) { out = new Rectangle(); }
|
if (out === undefined) { out = new Rectangle(); }
|
||||||
|
|
||||||
out.x = ellipse.x - ellipse.width;
|
out.x = ellipse.left;
|
||||||
out.y = ellipse.y - ellipse.height;
|
out.y = ellipse.top;
|
||||||
out.width = ellipse.width;
|
out.width = ellipse.width;
|
||||||
out.height = ellipse.height;
|
out.height = ellipse.height;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue