mirror of
https://github.com/photonstorm/phaser
synced 2025-01-11 20:58:56 +00:00
23 lines
580 B
JavaScript
23 lines
580 B
JavaScript
var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle)
|
|
{
|
|
if (startAngle === undefined) { startAngle = 0; }
|
|
if (endAngle === undefined) { endAngle = 6.28; }
|
|
|
|
var angle = startAngle;
|
|
var angleStep = (endAngle - startAngle) / items.length;
|
|
|
|
var a = ellipse.width / 2;
|
|
var b = ellipse.height / 2;
|
|
|
|
for (var i = 0; i < items.length; i++)
|
|
{
|
|
items[i].x = ellipse.x + a * Math.cos(angle);
|
|
items[i].y = ellipse.y + b * Math.sin(angle);
|
|
|
|
angle += angleStep;
|
|
}
|
|
|
|
return items;
|
|
};
|
|
|
|
module.exports = PlaceOnEllipse;
|