Point add/subtract/divideBy
This commit is contained in:
parent
a9677fca55
commit
a8d55d0d47
@ -14,4 +14,10 @@ describe("Point", function() {
|
||||
expect(p.y).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#subtract', noSpecs);
|
||||
|
||||
describe('#add', noSpecs);
|
||||
|
||||
describe('#divideBy', noSpecs);
|
||||
});
|
@ -6,3 +6,17 @@ L.Point = function(/*Number*/ x, /*Number*/ y, /*Boolean*/ round) {
|
||||
this.x = (round ? Math.round(x) : x);
|
||||
this.y = (round ? Math.round(y) : y);
|
||||
};
|
||||
|
||||
L.Point.prototype = {
|
||||
add: function(point) {
|
||||
return L.Point(this.x + point.x, this.y + point.y);
|
||||
},
|
||||
|
||||
subtract: function(point) {
|
||||
return L.Point(this.x - point.x, this.y - point.y);
|
||||
},
|
||||
|
||||
divideBy: function(num, round) {
|
||||
return L.Point(this.x/2, this.y/2, round);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user