Skip to content

Commit bf695ee

Browse files
committed
Added PlaceOnCircle and PlaceOnLine Actions.
1 parent 18fa629 commit bf695ee

6 files changed

Lines changed: 56 additions & 5 deletions

File tree

v3/src/actions/PlaceOnCircle.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var PlaceOnCircle = function (items, circle, startAngle, endAngle)
2+
{
3+
if (startAngle === undefined) { startAngle = 0; }
4+
if (endAngle === undefined) { endAngle = 6.28; }
5+
6+
var angle = startAngle;
7+
var angleStep = (endAngle - startAngle) / items.length;
8+
9+
for (var i = 0; i < items.length; i++)
10+
{
11+
items[i].x = circle.x + (circle.radius * Math.cos(angle));
12+
items[i].y = circle.y + (circle.radius * Math.sin(angle));
13+
14+
angle += angleStep;
15+
}
16+
17+
return items;
18+
};
19+
20+
module.exports = PlaceOnCircle;

v3/src/actions/PlaceOnLine.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var GetPointsOnLine = require('../geom/line/GetPointsOnLine');
2+
3+
var PlaceOnLine = function (items, line)
4+
{
5+
var points = GetPointsOnLine(line);
6+
var step = points.length / items.length;
7+
var p = 0;
8+
9+
for (var i = 0; i < items.length; i++)
10+
{
11+
var item = items[i];
12+
var point = points[Math.floor(p)];
13+
14+
item.x = point[0];
15+
item.y = point[1];
16+
17+
p += step;
18+
}
19+
20+
return items;
21+
};
22+
23+
module.exports = PlaceOnLine;

v3/src/actions/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module.exports = {
99
IncX: require('./IncX'),
1010
IncXY: require('./IncXY'),
1111
IncY: require('./IncY'),
12-
PositionAroundCircle: require('./PositionAroundCircle'),
12+
PlaceOnCircle: require('./PlaceOnCircle'),
13+
PlaceOnLine: require('./PlaceOnLine'),
1314
RandomCircle: require('./RandomCircle'),
1415
RandomEllipse: require('./RandomEllipse'),
1516
RandomLine: require('./RandomLine'),

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '02229ca0-1488-11e7-8e2a-13177b968951'
2+
build: 'b43cf770-1490-11e7-8aea-037f4d5a79de'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/layer/Layer.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,16 @@ var Layer = new Class({
217217
return this;
218218
},
219219

220-
positionAroundCircle: function (circle, startAngle, endAngle)
220+
placeOnCircle: function (circle, startAngle, endAngle)
221221
{
222-
Actions.PositionAroundCircle(this.children.entries, circle, startAngle, endAngle);
222+
Actions.PlaceOnCircle(this.children.entries, circle, startAngle, endAngle);
223+
224+
return this;
225+
},
226+
227+
placeOnLine: function (line)
228+
{
229+
Actions.PlaceOnLine(this.children.entries, line);
223230

224231
return this;
225232
},

v3/src/geom/rectangle/PerimeterPoint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var MATH_CONST = require('../../math/const');
22

3-
// deg = degrees
3+
// deg = degrees (0-360)
44

55
var PerimeterPoint = function (rect, deg, out)
66
{

0 commit comments

Comments
 (0)