mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 13:43:26 +00:00
Added Path.getBounds.
This commit is contained in:
parent
832c17b7c5
commit
f005380d67
1 changed files with 37 additions and 0 deletions
|
@ -6,6 +6,7 @@ var EllipseCurve = require('./curves/ellipse/EllipseCurve');
|
||||||
var GameObjectFactory = require('../scene/plugins/GameObjectFactory');
|
var GameObjectFactory = require('../scene/plugins/GameObjectFactory');
|
||||||
var LineCurve = require('./curves/line/LineCurve');
|
var LineCurve = require('./curves/line/LineCurve');
|
||||||
var MoveTo = require('./MoveTo');
|
var MoveTo = require('./MoveTo');
|
||||||
|
var Rectangle = require('../geom/rectangle/Rectangle');
|
||||||
var SplineCurve = require('./curves/spline/SplineCurve');
|
var SplineCurve = require('./curves/spline/SplineCurve');
|
||||||
var Vector2 = require('../math/Vector2');
|
var Vector2 = require('../math/Vector2');
|
||||||
|
|
||||||
|
@ -112,6 +113,42 @@ var Path = new Class({
|
||||||
return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation);
|
return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getBounds: function (out, accuracy)
|
||||||
|
{
|
||||||
|
if (out === undefined) { out = new Rectangle(); }
|
||||||
|
if (accuracy === undefined) { accuracy = 16; }
|
||||||
|
|
||||||
|
out.x = Number.MAX_SAFE_INTEGER;
|
||||||
|
out.y = Number.MAX_SAFE_INTEGER;
|
||||||
|
|
||||||
|
var bounds = new Rectangle();
|
||||||
|
var maxRight = Number.MIN_SAFE_INTEGER;
|
||||||
|
var maxBottom = Number.MIN_SAFE_INTEGER;
|
||||||
|
|
||||||
|
for (var i = 0; i < this.curves.length; i++)
|
||||||
|
{
|
||||||
|
var curve = this.curves[i];
|
||||||
|
|
||||||
|
if (!curve.active)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
curve.getBounds(bounds, accuracy);
|
||||||
|
|
||||||
|
out.x = Math.min(out.x, bounds.x);
|
||||||
|
out.y = Math.min(out.y, bounds.y);
|
||||||
|
|
||||||
|
maxRight = Math.max(maxRight, bounds.right);
|
||||||
|
maxBottom = Math.max(maxBottom, bounds.bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
out.right = maxRight;
|
||||||
|
out.bottom = maxBottom;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
},
|
||||||
|
|
||||||
toJSON: function ()
|
toJSON: function ()
|
||||||
{
|
{
|
||||||
var out = [];
|
var out = [];
|
||||||
|
|
Loading…
Reference in a new issue