Skip to content

Commit 9cdd359

Browse files
committed
Constructors no longer call setTo and getPointAB return object properties updated to x/y
1 parent 7458574 commit 9cdd359

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

src/geom/line/Line.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ var Line = new Class({
1111

1212
function Line (x1, y1, x2, y2)
1313
{
14-
this.x1 = 0;
15-
this.y1 = 0;
16-
this.x2 = 0;
17-
this.y2 = 0;
14+
if (x1 === undefined) { x1 = 0; }
15+
if (y1 === undefined) { y1 = 0; }
16+
if (x2 === undefined) { x2 = 0; }
17+
if (y2 === undefined) { y2 = 0; }
1818

19-
this.setTo(x1, y1, x2, y2);
19+
this.x1 = x1;
20+
this.y1 = y1;
21+
22+
this.x2 = x2;
23+
this.y2 = y2;
2024
},
2125

2226
getPoint: function (position, output)
@@ -52,12 +56,12 @@ var Line = new Class({
5256

5357
getPointA: function ()
5458
{
55-
return { x1: this.x1, y1: this.y1 };
59+
return { x: this.x1, y: this.y1 };
5660
},
5761

5862
getPointB: function ()
5963
{
60-
return { x1: this.x2, y1: this.y2 };
64+
return { x: this.x2, y: this.y2 };
6165
},
6266

6367
left: {

src/geom/triangle/Triangle.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ var Triangle = new Class({
1414

1515
function Triangle (x1, y1, x2, y2, x3, y3)
1616
{
17-
this.x1 = 0;
18-
this.y1 = 0;
17+
if (x1 === undefined) { x1 = 0; }
18+
if (y1 === undefined) { y1 = 0; }
19+
if (x2 === undefined) { x2 = 0; }
20+
if (y2 === undefined) { y2 = 0; }
21+
if (x3 === undefined) { x3 = 0; }
22+
if (y3 === undefined) { y3 = 0; }
1923

20-
this.x2 = 0;
21-
this.y2 = 0;
24+
this.x1 = x1;
25+
this.y1 = y1;
2226

23-
this.x3 = 0;
24-
this.y3 = 0;
27+
this.x2 = x2;
28+
this.y2 = y2;
2529

26-
this.setTo(x1, y1, x2, y2, x3, y3);
30+
this.x3 = x3;
31+
this.y3 = y3;
2732
},
2833

2934
contains: function (x, y)

0 commit comments

Comments
 (0)