Added PlaceOnEllipse action and added to Group

This commit is contained in:
Richard Davey 2017-08-02 01:24:54 +01:00
parent 5f04a659e0
commit 9eb723cfc2
4 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,23 @@
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;

View file

@ -11,6 +11,7 @@ module.exports = {
IncXY: require('./IncXY'),
IncY: require('./IncY'),
PlaceOnCircle: require('./PlaceOnCircle'),
PlaceOnEllipse: require('./PlaceOnEllipse'),
PlaceOnLine: require('./PlaceOnLine'),
PlaceOnRectangle: require('./PlaceOnRectangle'),
PlaceOnTriangle: require('./PlaceOnTriangle'),

View file

@ -1,4 +1,4 @@
var CHECKSUM = {
build: '5d97e130-7716-11e7-8b1c-25a8a89333fb'
build: '9aad2b50-7718-11e7-a802-eddafadf9983'
};
module.exports = CHECKSUM;

View file

@ -284,6 +284,13 @@ var Group = new Class({
return this;
},
placeOnEllipse: function (ellipse, startAngle, endAngle)
{
Actions.PlaceOnEllipse(this.children.entries, ellipse, startAngle, endAngle);
return this;
},
placeOnLine: function (line)
{
Actions.PlaceOnLine(this.children.entries, line);