Skip to content

Commit e554307

Browse files
committed
Renamed GetPointsOnLine as it conflicts with the new GetPoints function.
1 parent 2f5da71 commit e554307

4 files changed

Lines changed: 14 additions & 17 deletions

File tree

v3/src/actions/PlaceOnLine.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var GetPointsOnLine = require('../geom/line/GetPointsOnLine');
1+
var GetPoints = require('../geom/line/GetPoints');
22

33
/**
44
* [description]
@@ -13,19 +13,15 @@ var GetPointsOnLine = require('../geom/line/GetPointsOnLine');
1313
*/
1414
var PlaceOnLine = function (items, line)
1515
{
16-
var points = GetPointsOnLine(line);
17-
var step = points.length / items.length;
18-
var p = 0;
16+
var points = GetPoints(line, items.length);
1917

2018
for (var i = 0; i < items.length; i++)
2119
{
2220
var item = items[i];
23-
var point = points[Math.floor(p)];
21+
var point = points[i];
2422

25-
item.x = point[0];
26-
item.y = point[1];
27-
28-
p += step;
23+
item.x = point.x;
24+
item.y = point.y;
2925
}
3026

3127
return items;

v3/src/actions/PlaceOnTriangle.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var GetPointsOnLine = require('../geom/line/GetPointsOnLine');
1+
// var GetPointsOnLine = require('../geom/line/GetPointsOnLine');
2+
var BresenhamPoints = require('../geom/line/BresenhamPoints');
23

34
/**
45
* [description]
@@ -14,9 +15,9 @@ var GetPointsOnLine = require('../geom/line/GetPointsOnLine');
1415
*/
1516
var PlaceOnTriangle = function (items, triangle, stepRate)
1617
{
17-
var p1 = GetPointsOnLine({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate);
18-
var p2 = GetPointsOnLine({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate);
19-
var p3 = GetPointsOnLine({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate);
18+
var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate);
19+
var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate);
20+
var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate);
2021

2122
// Remove overlaps
2223
p1.pop();
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Using Bresenham's line algorithm this will return an array of all coordinates on this line.
33
* The start and end points are rounded before this runs as the algorithm works on integers.
44
*
5-
* @function Phaser.Geom.Line.GetPointsOnLine
5+
* @function Phaser.Geom.Line.BresenhamPoints
66
* @since 3.0.0
77
*
88
* @param {Phaser.Geom.Line} line - [description]
@@ -11,7 +11,7 @@
1111
*
1212
* @return {array} [description]
1313
*/
14-
var GetPointsOnLine = function (line, stepRate, results)
14+
var BresenhamPoints = function (line, stepRate, results)
1515
{
1616
if (stepRate === undefined) { stepRate = 1; }
1717
if (results === undefined) { results = []; }
@@ -58,4 +58,4 @@ var GetPointsOnLine = function (line, stepRate, results)
5858
return results;
5959
};
6060

61-
module.exports = GetPointsOnLine;
61+
module.exports = BresenhamPoints;

v3/src/geom/line/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var Line = require('./Line');
44

55
Line.Angle = require('./Angle');
6+
Line.BresenhamPoints = require('./BresenhamPoints');
67
Line.CenterOn = require('./CenterOn');
78
Line.Clone = require('./Clone');
89
Line.CopyFrom = require('./CopyFrom');
@@ -11,7 +12,6 @@ Line.GetMidPoint = require('./GetMidPoint');
1112
Line.GetNormal = require('./GetNormal');
1213
Line.GetPoint = require('./GetPoint');
1314
Line.GetPoints = require('./GetPoints');
14-
Line.GetPointsOnLine = require('./GetPointsOnLine');
1515
Line.Height = require('./Height');
1616
Line.Length = require('./Length');
1717
Line.NormalAngle = require('./NormalAngle');

0 commit comments

Comments
 (0)