mirror of
https://github.com/photonstorm/phaser
synced 2024-12-17 16:43:30 +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 rx = ellipse.width;
|
||||
var ry = ellipse.height;
|
||||
var rx = ellipse.width / 2;
|
||||
var ry = ellipse.height / 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)))));
|
||||
|
|
|
@ -16,14 +16,14 @@ var Contains = function (ellipse, x, y)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 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 normy = ((y - ellipse.y) / ellipse.height) - 0.5;
|
||||
|
||||
var normx = ((x - ellipse.x) / ellipse.width);
|
||||
var normy = ((y - ellipse.y) / ellipse.height);
|
||||
|
||||
normx *= normx;
|
||||
normy *= normy;
|
||||
|
||||
|
||||
return (normx + normy < 0.25);
|
||||
};
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ var GetBounds = function (ellipse, out)
|
|||
{
|
||||
if (out === undefined) { out = new Rectangle(); }
|
||||
|
||||
out.x = ellipse.x - ellipse.width;
|
||||
out.y = ellipse.y - ellipse.height;
|
||||
out.x = ellipse.left;
|
||||
out.y = ellipse.top;
|
||||
out.width = ellipse.width;
|
||||
out.height = ellipse.height;
|
||||
|
||||
|
|
Loading…
Reference in a new issue