mirror of
https://github.com/photonstorm/phaser
synced 2024-12-21 02:23:29 +00:00
26 lines
472 B
JavaScript
26 lines
472 B
JavaScript
var Spread = function (items, property, min, max, inc)
|
|
{
|
|
if (inc === undefined) { inc = false; }
|
|
|
|
var step = Math.abs(max - min) / items.length;
|
|
var i;
|
|
|
|
if (inc)
|
|
{
|
|
for (i = 0; i < items.length; i++)
|
|
{
|
|
items[i][property] += i * step;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (i = 0; i < items.length; i++)
|
|
{
|
|
items[i][property] = i * step;
|
|
}
|
|
}
|
|
|
|
return items;
|
|
};
|
|
|
|
module.exports = Spread;
|